lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250313172826.xzqkrx5rzuqpvz7j@thinkpad>
Date: Thu, 13 Mar 2025 22:58:26 +0530
From: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>
To: "Bao D. Nguyen" <quic_nguyenb@...cinc.com>
Cc: quic_cang@...cinc.com, quic_nitirawa@...cinc.com, bvanassche@....org,
	avri.altman@....com, peter.wang@...iatek.com, minwoo.im@...sung.com,
	adrian.hunter@...el.com, martin.petersen@...cle.com,
	linux-scsi@...r.kernel.org, Alim Akhtar <alim.akhtar@...sung.com>,
	"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
	Bean Huo <beanhuo@...ron.com>,
	Ziqi Chen <quic_ziqichen@...cinc.com>,
	Keoseong Park <keosung.park@...sung.com>,
	Gwendal Grignou <gwendal@...omium.org>,
	Al Viro <viro@...iv.linux.org.uk>,
	Eric Biggers <ebiggers@...gle.com>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 1/1] scsi: ufs: core: add device level exception
 support

On Thu, Mar 06, 2025 at 09:31:06AM -0800, Bao D. Nguyen wrote:
> The device JEDEC standard version 4.1 adds support for the device
> level exception events. To support this new device level exception
> feature, expose two new sysfs nodes below to provide
> the user space access to the device level exception information.
> /sys/bus/platform/drivers/ufshcd/*/device_lvl_exception
> /sys/bus/platform/drivers/ufshcd/*/device_lvl_exception_id
> 
> The device_lvl_exception sysfs node reports the number of
> device level exceptions that have occurred since the last time
> this variable is reset.
> The device_lvl_exception_id sysfs node reports the exception ID
> which is the JEDEC standard qDeviceLevelExceptionID attribute.
> The user space application can query these sysfs nodes to get more
> information about the device level exception.
> 
> Signed-off-by: Bao D. Nguyen <quic_nguyenb@...cinc.com>
> ---
>  Documentation/ABI/testing/sysfs-driver-ufs | 23 +++++++++++
>  drivers/ufs/core/ufs-sysfs.c               | 54 ++++++++++++++++++++++++++
>  drivers/ufs/core/ufshcd-priv.h             |  1 +
>  drivers/ufs/core/ufshcd.c                  | 61 ++++++++++++++++++++++++++++++
>  include/uapi/scsi/scsi_bsg_ufs.h           |  9 +++++
>  include/ufs/ufs.h                          |  5 ++-
>  include/ufs/ufshcd.h                       |  5 +++
>  7 files changed, 157 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-ufs b/Documentation/ABI/testing/sysfs-driver-ufs
> index ae01912..5cf3f43 100644
> --- a/Documentation/ABI/testing/sysfs-driver-ufs
> +++ b/Documentation/ABI/testing/sysfs-driver-ufs
> @@ -1604,3 +1604,26 @@ Description:
>  		prevent the UFS from frequently performing clock gating/ungating.
>  
>  		The attribute is read/write.
> +
> +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@...cinc.com>
> +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.

> +
> +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@...cinc.com>
> +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.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ