History

Merge patch series "scsi: ufs: Add support for the aggregated read query opcode"

Hyeoncheol Jeong <hyenc.jeong@samsung.com> says: UFS 5.0 / JEDEC 220H introduces the AGGREGATED READ query opcode (0x9), which retrieves an aggregated data packet bundling multiple Descriptors, Attributes and Flags in a single QUERY RESPONSE UPIU. Such a packet can be far larger than a single descriptor, so the reserved (device management) tag gets a dedicated UCD with an enlarged response area. Patch 1 is a preparatory cleanup that switches the BSG query descriptor length to unsigned types. Patch 2 adds the aggregated read support. v3: https://lore.kernel.org/linux-scsi/20260724030812epcms2p4eb2c77cb4dcd5fd51ca9c3eaa5ea4bfa@epcms2p4/ v2: https://lore.kernel.org/linux-scsi/20260722084819epcms2p49c27fce999e821385f7b5d7ea5a02868@epcms2p4/

Martin K. Petersen (Oracle) committed 3 months ago

Commit f574a022 parents 654fdae 8f5bbff6 files · +143 −48Browse files

Showing the changes to include (3 of 6 files). Show all

Unified · Split

3 files
  1. include/ufs/ufs.h +6 −0
  2. include/ufs/ufshcd.h +20 −0
  3. include/ufs/ufshci.h +12 −0
include/ufs/ufs.h+6−0
@@ -25,6 +25,11 @@ static_assert(sizeof(struct utp_upiu_query) == 20); · 24 unmodified lines
2525
2626 #define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))
2727 #define QUERY_DESC_MAX_SIZE 255
28+/*
29+ * Max aggregated read data segment: the devman response area
30+ * (ALIGNED_DEVMAN_RSP_SIZE) minus the fixed UPIU header it follows.
31+ */
32+#define QUERY_AGGREGATED_MAX_SIZE (4096 - GENERAL_UPIU_REQUEST_SIZE)
2833 #define QUERY_DESC_MIN_SIZE 2
2934 #define QUERY_DESC_HDR_SIZE 2
3035 #define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \
@@ -464,6 +469,7 @@ enum query_opcode { · 433 unmodified lines
464469 UPIU_QUERY_OPCODE_SET_FLAG = 0x6,
465470 UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7,
466471 UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8,
472+ UPIU_QUERY_OPCODE_AGGREGATED_READ = 0x9,
467473 };
468474
469475 /* bRefClkFreq attribute values */
include/ufs/ufshcd.h+20−0
@@ -235,11 +235,13 @@ struct ufs_query { · 234 unmodified lines
235235 * @type: device management command type - Query, NOP OUT
236236 * @lock: lock to allow one command at a time
237237 * @query: Device management query information
238+ * @tag: tag of the reserved request in use
238239 */
239240 struct ufs_dev_cmd {
240241 enum dev_cmd_type type;
241242 struct mutex lock;
242243 struct ufs_query query;
244+ u8 tag;
243245 };
244246
245247 /**
@@ -954,9 +956,13 @@ enum ufshcd_mcq_opr { · 708 unmodified lines
954956 * @ucdl_base_addr: UFS Command Descriptor base address
955957 * @utrdl_base_addr: UTP Transfer Request Descriptor base address
956958 * @utmrdl_base_addr: UTP Task Management Descriptor base address
959+ * @devman_ucd_base_addr: UFS Command Descriptor base address for the reserved
960+ * device management tag (has a larger response area)
957961 * @ucdl_dma_addr: UFS Command Descriptor DMA address
958962 * @utrdl_dma_addr: UTRDL DMA address
959963 * @utmrdl_dma_addr: UTMRDL DMA address
964+ * @devman_ucd_dma_addr: UFS Command Descriptor DMA address for the reserved
965+ * device management tag
960966 * @host: Scsi_Host instance of the driver
961967 * @dev: device handle
962968 * @ufs_device_wlun: WLUN that controls the entire UFS device.
@@ -1098,11 +1104,13 @@ struct ufs_hba { · 135 unmodified lines
10981104 struct utp_transfer_cmd_desc *ucdl_base_addr;
10991105 struct utp_transfer_req_desc *utrdl_base_addr;
11001106 struct utp_task_req_desc *utmrdl_base_addr;
1107+ struct utp_devman_cmd_desc *devman_ucd_base_addr;
11011108
11021109 /* DMA memory reference */
11031110 dma_addr_t ucdl_dma_addr;
11041111 dma_addr_t utrdl_dma_addr;
11051112 dma_addr_t utmrdl_dma_addr;
1113+ dma_addr_t devman_ucd_dma_addr;
11061114
11071115 struct Scsi_Host *host;
11081116 struct device *dev;
@@ -1361,6 +1369,18 @@ static inline size_t ufshcd_get_ucd_size(const struct ufs_hba *hba) · 252 unmodified lines
13611369 return sizeof(struct utp_transfer_cmd_desc) + SG_ALL * ufshcd_sg_entry_size(hba);
13621370 }
13631371
1372+/*
1373+ * Two entries should be enough for the largest devman PRDT transfer (4 KiB),
1374+ * like advanced RPMB.
1375+ */
1376+#define UFSHCD_DEVMAN_SG_ENTRIES 2
1377+
1378+static inline size_t ufshcd_get_devman_ucd_size(const struct ufs_hba *hba)
1379+{
1380+ return sizeof(struct utp_devman_cmd_desc) +
1381+ UFSHCD_DEVMAN_SG_ENTRIES * ufshcd_sg_entry_size(hba);
1382+}
1383+
13641384 /* Returns true if clocks can be gated. Otherwise false */
13651385 static inline bool ufshcd_is_clkgating_allowed(struct ufs_hba *hba)
13661386 {
include/ufs/ufshci.h+12−0
@@ -18,6 +18,8 @@ enum { · 17 unmodified lines
1818 TASK_REQ_UPIU_SIZE_DWORDS = 8,
1919 TASK_RSP_UPIU_SIZE_DWORDS = 8,
2020 ALIGNED_UPIU_SIZE = 512,
21+ /* Larger response area, only for the devman UCD */
22+ ALIGNED_DEVMAN_RSP_SIZE = 4096,
2123 };
2224
2325 /* UFSHCI Registers */
@@ -501,6 +503,16 @@ struct utp_transfer_cmd_desc { · 477 unmodified lines
501503 u8 prd_table[];
502504 };
503505
506+/* Dedicated UCD for the devman/reserved slot */
507+struct utp_devman_cmd_desc {
508+ u8 command_upiu[ALIGNED_UPIU_SIZE];
509+ u8 response_upiu[ALIGNED_DEVMAN_RSP_SIZE];
510+ u8 prd_table[];
511+};
512+
513+static_assert(sizeof(struct utp_upiu_req) + QUERY_AGGREGATED_MAX_SIZE <=
514+ ALIGNED_DEVMAN_RSP_SIZE);
515+
504516 /**
505517 * struct request_desc_header - Descriptor Header common to both UTRD and UTMRD
506518 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t