Re: [PATCH v1 1/1] scsi: ufs: core: add device level exception support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/13/2025 10:28 AM, Manivannan Sadhasivam wrote:
+
+What:		/sys/bus/platform/drivers/ufshcd/*/device_lvl_exception
+What:		/sys/bus/platform/devices/*.ufs/device_lvl_exception
+Date:		March 2025
+Contact:	Bao D. Nguyen <quic_nguyenb@xxxxxxxxxxx>
+Description:
+		The device_lvl_exception is a counter indicating the number
+		of times the device level exceptions have occurred since the
+		last time this variable is reset. Read the device_lvl_exception_id
+		sysfs node to know more information about the exception.
+		The file is read only.

No. This attribute is RW and the write of 0 will reset the counter. Please
change it here and also in commit message.

Also document the spec version requirement for these attributes.

Thank you Mani. I will make corrections.

+
+What:		/sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_id
+What:		/sys/bus/platform/devices/*.ufs/device_lvl_exception_id
+Date:		March 2025
+Contact:	Bao D. Nguyen <quic_nguyenb@xxxxxxxxxxx>
+Description:
+		Reading the device_lvl_exception_id returns the device JEDEC
+		standard's qDeviceLevelExceptionID attribute. The definition of the
+		qDeviceLevelExceptionID is the ufs device vendor specific design.
+		Refer to the device manufacturer datasheet for more information
+		on the meaning of the qDeviceLevelExceptionID attribute value.
+		The file is read only.
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index 90b5ab6..0248288a 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -466,6 +466,56 @@ static ssize_t critical_health_show(struct device *dev,
  	return sysfs_emit(buf, "%d\n", hba->critical_health_count);
  }

[...]

+int ufshcd_read_device_lvl_exception_id(struct ufs_hba *hba, u64 *exception_id)
+{
+	struct utp_upiu_query_response_v4_0 *upiu_resp;
+	struct ufs_query_req *request = NULL;
+	struct ufs_query_res *response = NULL;
+	int err;
+
+	if (hba->dev_info.wspecversion < 0x410)
+		return -EOPNOTSUPP;
+
+	ufshcd_hold(hba);
+	mutex_lock(&hba->dev_cmd.lock);
+
+	ufshcd_init_query(hba, &request, &response,
+			  UPIU_QUERY_OPCODE_READ_ATTR,
+			  QUERY_ATTR_IDN_DEV_LVL_EXCEPTION_ID, 0, 0);
+
+	request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST;
+
+	err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY, QUERY_REQ_TIMEOUT);
+
+	if (err) {
+		dev_err(hba->dev, "%s: failed to read device level exception %d\n",
+			__func__, err);
+		goto out;
+	}
+
+	upiu_resp = (struct utp_upiu_query_response_v4_0 *)response;
+	*exception_id = get_unaligned_be64(&upiu_resp->value);
+
+out:
+	mutex_unlock(&hba->dev_cmd.lock);
+	ufshcd_release(hba);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(ufshcd_read_device_lvl_exception_id);

There is no need to export this function.

I will make the correction.

- Mani






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux