From: Hyeoncheol Jeong <hyenc.jeong@samsung.com>
To: "James.Bottomley@HansenPartnership.com"
<James.Bottomley@HansenPartnership.com>,
"mkp@kernel.org" <mkp@kernel.org>,
"avri.altman@sandisk.com" <avri.altman@sandisk.com>,
"bvanassche@acm.org" <bvanassche@acm.org>,
"peter.wang@mediatek.com" <peter.wang@mediatek.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: Jinyoung Choi <j-young.choi@samsung.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
"beanhuo@micron.com" <beanhuo@micron.com>,
"can.guo@oss.qualcomm.com" <can.guo@oss.qualcomm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 1/2] scsi: ufs: Add the aggregated read query opcode and its reply format
Date: Wed, 30 Sep 2026 14:15:48 +0900 [thread overview]
Message-ID: <1860250540.01790752381858.JavaMail.epsvc@epcpadp2new> (raw)
In-Reply-To: <20260930050201epcms2p13ab67182445b0555acc8d27b927cda86@epcms2p1>
UFS 5.0 adds the AGGREGATED READ query opcode (0x9): a single QUERY
RESPONSE UPIU returns many descriptors, attributes and flags as a chain
of typed groups (JESD220H 10.7.9.14).
Add the AGGREGATION TYPE mask, the group types and the group header, and
let ufshcd_copy_query_response() copy the reply's data segment like a
descriptor read, recording its length in struct ufs_query_res.
Signed-off-by: Hyeoncheol Jeong <hyenc.jeong@samsung.com>
---
drivers/ufs/core/ufshcd.c | 7 +++++--
include/ufs/ufs.h | 44 +++++++++++++++++++++++++++++++++++++++
include/ufs/ufshcd.h | 2 ++
3 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 54f4e7d7de02..d07834fc4646 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2473,10 +2473,13 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
struct ufs_query_res *query_res = &hba->dev_cmd.query.response;
memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE);
+ query_res->data_segment_length =
+ be16_to_cpu(lrbp->ucd_rsp_ptr->header.data_segment_length);
- /* Get the descriptor */
+ /* Get the descriptor or aggregated data packet */
if (hba->dev_cmd.query.descriptor &&
- lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC) {
+ (lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC ||
+ lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_AGGREGATED_READ)) {
u8 *descp = (u8 *)lrbp->ucd_rsp_ptr +
GENERAL_UPIU_REQUEST_SIZE;
u16 resp_len;
diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h
index afbb32654fab..1e6ea87a5dc7 100644
--- a/include/ufs/ufs.h
+++ b/include/ufs/ufs.h
@@ -30,6 +30,7 @@ static_assert(sizeof(struct utp_upiu_query) == 20);
* (ALIGNED_DEVMAN_RSP_SIZE) minus the fixed UPIU header it follows.
*/
#define QUERY_AGGREGATED_MAX_SIZE (4096 - GENERAL_UPIU_REQUEST_SIZE)
+#define QUERY_AGG_GROUP_HDR_SIZE 4
#define QUERY_DESC_MIN_SIZE 2
#define QUERY_DESC_HDR_SIZE 2
#define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \
@@ -569,6 +570,49 @@ enum ufs_dev_pwr_mode {
#define UFS_WB_BUF_REMAIN_PERCENT(val) ((val) / 10)
+/* AGGREGATION TYPE field of an AGGREGATED READ query request */
+enum ufs_agg_type {
+ UFS_AGG_TYPE_ALL_FLAGS = BIT(0),
+ UFS_AGG_TYPE_ALL_ATTRS = BIT(1),
+ UFS_AGG_TYPE_DEVICE_DESC = BIT(2),
+ /* Unit descriptors and the RPMB unit descriptor */
+ UFS_AGG_TYPE_UNIT_RPMB_DESC = BIT(3),
+ UFS_AGG_TYPE_INTERCONNECT_DESC = BIT(4),
+ UFS_AGG_TYPE_STRING_DESC = BIT(5),
+ /* Geometry descriptor and power descriptor */
+ UFS_AGG_TYPE_GEOMETRY_POWER_DESC = BIT(6),
+ UFS_AGG_TYPE_HEALTH_DESC = BIT(7),
+};
+
+/* Group Type field of an aggregated data packet group header. */
+enum ufs_agg_group_type {
+ UFS_AGG_GROUP_RESERVED = 0x00,
+ UFS_AGG_GROUP_FLAGS = 0x01,
+ UFS_AGG_GROUP_ATTRS = 0x02,
+ /* Any descriptor with a unique IDN, i.e. all but the string ones */
+ UFS_AGG_GROUP_DESCS = 0x03,
+ UFS_AGG_GROUP_MANUFACTURER_STR = 0x04,
+ UFS_AGG_GROUP_PRODUCT_NAME_STR = 0x05,
+ UFS_AGG_GROUP_OEM_ID_STR = 0x06,
+ UFS_AGG_GROUP_SERIAL_NUMBER_STR = 0x07,
+ UFS_AGG_GROUP_PRODUCT_REV_STR = 0x08,
+};
+
+/**
+ * struct utp_agg_group_header - aggregated data packet group header
+ * @group_type: type of the data carried by this group, see ufs_agg_group_type
+ * @reserved: reserved
+ * @next_group_offset: byte offset from the start of the packet to the next
+ * group; zero ends the chain
+ */
+struct utp_agg_group_header {
+ u8 group_type;
+ u8 reserved;
+ __be16 next_group_offset;
+};
+
+static_assert(sizeof(struct utp_agg_group_header) == QUERY_AGG_GROUP_HDR_SIZE);
+
/**
* struct utp_cmd_rsp - RESPONSE UPIU structure
* @residual_transfer_count: Residual transfer count DW-3
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index dfd302f2dc7c..1a5e181ff9e3 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -213,9 +213,11 @@ struct ufs_query_req {
/**
* struct ufs_query_res - UPIU QUERY
* @upiu_res: query response data
+ * @data_segment_length: response data segment length
*/
struct ufs_query_res {
struct utp_upiu_query upiu_res;
+ u16 data_segment_length;
};
/**
--
2.25.1
next parent reply other threads:[~2026-09-30 7:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260930050201epcms2p13ab67182445b0555acc8d27b927cda86@epcms2p7>
[not found] ` <20260930050201epcms2p13ab67182445b0555acc8d27b927cda86@epcms2p1>
2026-09-30 5:15 ` Hyeoncheol Jeong [this message]
2026-09-30 7:54 ` [PATCH v2 1/2] scsi: ufs: Add the aggregated read query opcode and its reply format Peter Wang
2026-09-30 5:18 ` [PATCH v2 2/2] scsi: ufs: Serve the device init reads from one aggregated read Hyeoncheol Jeong
2026-09-30 7:28 ` sashiko-bot
2026-09-30 7:55 ` Peter Wang
2026-10-01 5:53 ` Stanley Jhu
2026-10-02 5:11 ` Hyeoncheol Jeong
2026-10-02 15:50 ` Bean Huo
2026-10-06 8:01 ` Hyeoncheol Jeong
2026-09-30 7:54 [PATCH v2 1/2] scsi: ufs: Add the aggregated read query opcode and its reply format Peter Wang (王信友)
[not found] <CGME20260930050201epcms2p13ab67182445b0555acc8d27b927cda86@epcms2p1>
2026-09-30 5:02 ` [PATCH v2 0/2] scsi: ufs: batch device-init reads with UFS 5.0 aggregated read Hyeoncheol Jeong
2026-10-02 9:24 ` Bean Huo
2026-10-06 7:17 ` Hyeoncheol Jeong
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=1860250540.01790752381858.JavaMail.epsvc@epcpadp2new \
--to=hyenc.jeong@samsung.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@sandisk.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=can.guo@oss.qualcomm.com \
--cc=j-young.choi@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=peter.wang@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.