From: Can Guo <can.guo@oss.qualcomm.com>
To: Bean Huo <beanhuo@iokpp.de>,
avri.altman@wdc.com, bvanassche@acm.org, beanhuo@micron.com,
peter.wang@mediatek.com, martin.petersen@oracle.com,
mani@kernel.org
Cc: linux-scsi@vger.kernel.org, Alim Akhtar <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Keoseong Park <keosung.park@samsung.com>,
Daniel Lee <chullee@google.com>,
Ram Kumar Dwivedi <ram.dwivedi@oss.qualcomm.com>,
Huan Tang <tanghuan@vivo.com>, Liu Song <liu.song13@zte.com.cn>,
vamshi gajjela <vamshigajjela@google.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] scsi: ufs: core: Introduce function ufshcd_query_attr_qword()
Date: Thu, 23 Apr 2026 21:30:56 +0800 [thread overview]
Message-ID: <a7e2d542-0453-4c14-afbd-c073a6565d02@oss.qualcomm.com> (raw)
In-Reply-To: <dab22e8ea2b47207e8e4a9264f0421f959891fca.camel@iokpp.de>
On 4/21/2026 6:04 AM, Bean Huo wrote:
> Can,
>
>
> On Sun, 2026-04-19 at 06:52 -0700, Can Guo wrote:
>> static int wb_read_resize_attrs(struct ufs_hba *hba,
>> enum attr_idn idn, u32 *attr_val)
>> {
>> @@ -1736,6 +1747,7 @@ static ssize_t _name##_show(struct device
>> *dev, \
>> struct device_attribute *attr, char *buf) \
>> { \
>> struct ufs_hba *hba = dev_get_drvdata(dev); \
>> + u64
>> qword_value; \
> u64 qword_value __maybe_unused;
>
>
>> u32 value; \
>> int ret; \
>> u8 index = 0; \
>> @@ -1748,14 +1760,24 @@ static ssize_t _name##_show(struct device
>> *dev, \
>> if (ufshcd_is_wb_attrs(QUERY_ATTR_IDN##_uname)) \
>> index = ufshcd_wb_get_query_index(hba); \
>> ufshcd_rpm_get_sync(hba); \
>> - ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR, \
>> - QUERY_ATTR_IDN##_uname, index, 0, &value); \
>> + if (ufshcd_is_qword_attrs(QUERY_ATTR_IDN##_uname)) \
>> + ret = ufshcd_query_attr_qword(hba, \
>> + UPIU_QUERY_OPCODE_READ_ATTR, \
>> + QUERY_ATTR_IDN##_uname, \
>> + index, 0,
>> &qword_value); \
>> + else \
>> + ret = ufshcd_query_attr(hba, \
>> + UPIU_QUERY_OPCODE_READ_ATTR, \
>> + QUERY_ATTR_IDN##_uname, index, 0, &value); \
>> ufshcd_rpm_put_sync(hba); \
>> if (ret) { \
>> ret = -EINVAL; \
>> goto out; \
>> } \
>> - ret = sysfs_emit(buf, "0x%08X\n", value); \
>> + if (ufshcd_is_qword_attrs(QUERY_ATTR_IDN##_uname)) \
>> + ret = sysfs_emit(buf, "0x%016llX\n",
>> qword_value); \
>> + else \
>> + ret = sysfs_emit(buf, "0x%08X\n", value); \
>> out: \
>> up(&hba->host_sem); \
>> return ret; \
>>
> ...
>
>
>>
>> +/**
>> + * ufshcd_query_attr_qword - API function of sending query requests for quad-
>> word attributes
>> + * @hba: per-adapter instance
>> + * @opcode: attribute opcode
>> + * @idn: attribute idn to access
>> + * @index: index field
>> + * @sel: selector field
>> + * @attr_val: the attribute value after the query request completes
>> + *
>> + * Return: 0 for success, non-zero in case of failure.
>> + */
>> +int ufshcd_query_attr_qword(struct ufs_hba *hba, enum query_opcode opcode,
>> + enum attr_idn idn, u8 index, u8 sel, u64
>> *attr_val)
>> +{
>> + struct utp_upiu_query_v4_0 *upiu_req;
>> + struct utp_upiu_query_v4_0 *upiu_resp;
>> + struct ufs_query_req *request = NULL;
>> + struct ufs_query_res *response = NULL;
>> + int err;
>> +
>> + if (!attr_val) {
>> + dev_err(hba->dev, "%s: attribute value required for opcode
>> 0x%x\n",
>> + __func__, opcode);
>> + return -EINVAL;
>> + }
>> +
>> + ufshcd_dev_man_lock(hba);
>> +
>> + ufshcd_init_query(hba, &request, &response, opcode, idn, index, sel);
>> +
>> + switch (opcode) {
>> + case UPIU_QUERY_OPCODE_WRITE_ATTR:
>> + request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST;
>> + upiu_req = (struct utp_upiu_query_v4_0 *)&request->upiu_req;
>> + put_unaligned_be64(*attr_val, &upiu_req->osf3);
>> + break;
>> + case UPIU_QUERY_OPCODE_READ_ATTR:
>> + request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST;
>> + break;
>> + default:
>> + dev_err(hba->dev, "%s: Expected query attr opcode but got =
>> 0x%.2x\n",
>> + __func__, opcode);
>> + err = -EINVAL;
>> + goto out_unlock;
>> + }
>> +
>> + err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY, dev_cmd_timeout);
>> + if (err) {
>> + dev_err(hba->dev, "%s: opcode 0x%.2x for idn %d failed, index
>> %d, selector %d, err = %d\n",
>> + __func__, opcode, idn, index, sel, err);
>> + goto out_unlock;
>> + }
>> +
>> + upiu_resp = (struct utp_upiu_query_v4_0 *)response;
>> + *attr_val = get_unaligned_be64(&upiu_resp->osf3);
>> +
>> +out_unlock:
>> + ufshcd_dev_man_unlock(hba);
>> + return err;
>> +}
>> +
> this needs a wrapper for retry? In ufshcd_extract_tx_eq_settings_attrs(), the
> 32-bit dTxEQGnSettingsExt read uses ufshcd_query_attr_retry(), but the 64-bit
> qTxEQGnSettings read uses bare ufshcd_query_attr_qword() with no retries.
I will use the non-retry version in ufs_txeq.c to be symmetrical,
because I don't really need
retry - retry never helped in real cases.
Thanks,
Can Guo.
>
> Kind regards,
> Bean
next prev parent reply other threads:[~2026-04-23 13:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-19 13:52 [PATCH 0/2] scsi: ufs: Add persistent TX Equalization settings support Can Guo
2026-04-19 13:52 ` [PATCH 1/2] scsi: ufs: core: Introduce function ufshcd_query_attr_qword() Can Guo
2026-04-20 12:31 ` Peter Wang (王信友)
2026-04-20 16:58 ` Bart Van Assche
2026-04-23 12:59 ` Can Guo
2026-04-20 22:04 ` Bean Huo
2026-04-23 13:30 ` Can Guo [this message]
2026-04-19 13:52 ` [PATCH 2/2] scsi: ufs: core: Add support to retrieve and store TX Equalization settings Can Guo
2026-04-20 12:33 ` Peter Wang (王信友)
2026-04-20 13:23 ` Can Guo
2026-04-20 16:28 ` Bart Van Assche
2026-04-23 13:49 ` Can Guo
2026-04-20 17:01 ` Bart Van Assche
2026-04-23 13:50 ` Can Guo
2026-04-20 22:09 ` Bean Huo
[not found] <CGME20260421110151epcas2p40628a13eb86c5c9b90626d14efc3b3ba@epcas2p4.samsung.com>
2026-04-21 11:01 ` [PATCH 1/2] scsi: ufs: core: Introduce function ufshcd_query_attr_qword() hoyoung seo
2026-04-23 12:55 ` Can Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a7e2d542-0453-4c14-afbd-c073a6565d02@oss.qualcomm.com \
--to=can.guo@oss.qualcomm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@iokpp.de \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=chullee@google.com \
--cc=keosung.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liu.song13@zte.com.cn \
--cc=mani@kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=rafael.j.wysocki@intel.com \
--cc=ram.dwivedi@oss.qualcomm.com \
--cc=tanghuan@vivo.com \
--cc=vamshigajjela@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox