All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arthur Simchaev <Arthur.Simchaev@wdc.com>
To: martin.petersen@oracle.com
Cc: beanhuo@micron.com, bvanassche@acm.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Arthur Simchaev <Arthur.Simchaev@wdc.com>
Subject: [PATCH 1/2] include: uapi: scsi: Change utp_upiu_query struct
Date: Wed, 22 Feb 2023 17:12:49 +0200	[thread overview]
Message-ID: <1677078770-30994-2-git-send-email-Arthur.Simchaev@wdc.com> (raw)
In-Reply-To: <1677078770-30994-1-git-send-email-Arthur.Simchaev@wdc.com>

In UFS 4.0 the attribute value was extended to 8 bytes. Therefore the
current definition is incorrect. Change the struct fields to osf
(Opcode Specific Field) in order define the struct generally.
Remove redundant reserved field

Signed-off-by: Arthur Simchaev <Arthur.Simchaev@wdc.com>
---
 drivers/ufs/core/ufs_bsg.c       |  2 +-
 drivers/ufs/core/ufshcd.c        | 24 ++++++++++++------------
 include/uapi/scsi/scsi_bsg_ufs.h | 17 +++++++++--------
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
index 0d38e7f..335e0ef 100644
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -16,7 +16,7 @@
 static int ufs_bsg_get_query_desc_size(struct ufs_hba *hba, int *desc_len,
 				       struct utp_upiu_query *qr)
 {
-	int desc_size = be16_to_cpu(qr->length);
+	int desc_size = be16_to_cpu(qr->osf5);
 
 	if (desc_size <= 0)
 		return -EINVAL;
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 629442c..b08760d 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -80,7 +80,7 @@
 /* Maximum number of error handler retries before giving up */
 #define MAX_ERR_HANDLER_RETRIES 5
 
-/* Expose the flag value from utp_upiu_query.value */
+/* Expose the flag value from utp_upiu_query.osf6 */
 #define MASK_QUERY_UPIU_FLAG_LOC 0xFF
 
 /* Interrupt aggregation default timeout, unit: 40us */
@@ -2280,8 +2280,7 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		/* data segment length */
 		resp_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2) &
 						MASK_QUERY_DATA_SEG_LEN;
-		buf_len = be16_to_cpu(
-				hba->dev_cmd.query.request.upiu_req.length);
+		buf_len = be16_to_cpu(hba->dev_cmd.query.request.upiu_req.osf5);
 		if (likely(buf_len >= resp_len)) {
 			memcpy(hba->dev_cmd.query.descriptor, descp, resp_len);
 		} else {
@@ -2681,7 +2680,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
 {
 	struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
 	struct ufs_query *query = &hba->dev_cmd.query;
-	u16 len = be16_to_cpu(query->request.upiu_req.length);
+	u16 len;
 
 	/* Query request header */
 	ucd_req_ptr->header.dword_0 = UPIU_HEADER_DWORD(
@@ -2691,12 +2690,13 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
 			0, query->request.query_func, 0, 0);
 
 	/* Data segment length only need for WRITE_DESC */
-	if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC)
+	if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC) {
+		len = be16_to_cpu(query->request.upiu_req.osf5);
 		ucd_req_ptr->header.dword_2 =
 			UPIU_HEADER_DWORD(0, 0, (len >> 8), (u8)len);
-	else
+	} else {
 		ucd_req_ptr->header.dword_2 = 0;
-
+	}
 	/* Copy the Query Request buffer as is */
 	memcpy(&ucd_req_ptr->qr, &query->request.upiu_req,
 			QUERY_OSF_SIZE);
@@ -3287,7 +3287,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
 	}
 
 	if (flag_res)
-		*flag_res = (be32_to_cpu(response->upiu_res.value) &
+		*flag_res = (be32_to_cpu(response->upiu_res.osf6) &
 				MASK_QUERY_UPIU_FLAG_LOC) & 0x1;
 
 out_unlock:
@@ -3331,7 +3331,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
 	switch (opcode) {
 	case UPIU_QUERY_OPCODE_WRITE_ATTR:
 		request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST;
-		request->upiu_req.value = cpu_to_be32(*attr_val);
+		request->upiu_req.osf6 = cpu_to_be32(*attr_val);
 		break;
 	case UPIU_QUERY_OPCODE_READ_ATTR:
 		request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST;
@@ -3351,7 +3351,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
 		goto out_unlock;
 	}
 
-	*attr_val = be32_to_cpu(response->upiu_res.value);
+	*attr_val = be32_to_cpu(response->upiu_res.osf6);
 
 out_unlock:
 	mutex_unlock(&hba->dev_cmd.lock);
@@ -3424,7 +3424,7 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
 	ufshcd_init_query(hba, &request, &response, opcode, idn, index,
 			selector);
 	hba->dev_cmd.query.descriptor = desc_buf;
-	request->upiu_req.length = cpu_to_be16(*buf_len);
+	request->upiu_req.osf5 = cpu_to_be16(*buf_len);
 
 	switch (opcode) {
 	case UPIU_QUERY_OPCODE_WRITE_DESC:
@@ -3449,7 +3449,7 @@ static int __ufshcd_query_descriptor(struct ufs_hba *hba,
 		goto out_unlock;
 	}
 
-	*buf_len = be16_to_cpu(response->upiu_res.length);
+	*buf_len = be16_to_cpu(response->upiu_res.osf5);
 
 out_unlock:
 	hba->dev_cmd.query.descriptor = NULL;
diff --git a/include/uapi/scsi/scsi_bsg_ufs.h b/include/uapi/scsi/scsi_bsg_ufs.h
index 2801b65..cccc07d 100644
--- a/include/uapi/scsi/scsi_bsg_ufs.h
+++ b/include/uapi/scsi/scsi_bsg_ufs.h
@@ -54,20 +54,21 @@ struct utp_upiu_header {
  * @idn: a value that indicates the particular type of data B-1
  * @index: Index to further identify data B-2
  * @selector: Index to further identify data B-3
- * @reserved_osf: spec reserved field B-4,5
- * @length: number of descriptor bytes to read/write B-6,7
- * @value: Attribute value to be written DW-5
- * @reserved: spec reserved DW-6,7
+ * @osf4: spec field B-5
+ * @osf5: spec field B 6,7
+ * @osf6: spec field DW 8,9
+ * @osf7: spec field DW 10,11
  */
 struct utp_upiu_query {
 	__u8 opcode;
 	__u8 idn;
 	__u8 index;
 	__u8 selector;
-	__be16 reserved_osf;
-	__be16 length;
-	__be32 value;
-	__be32 reserved[2];
+	__u8 osf3;
+	__u8 osf4;
+	__be16 osf5;
+	__be32 osf6;
+	__be32 osf7;
 };
 
 /**
-- 
2.7.4


  reply	other threads:[~2023-02-22 15:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 15:12 [PATCH 0/2] ufs: core: Add support for qTimestamp attribute Arthur Simchaev
2023-02-22 15:12 ` Arthur Simchaev [this message]
2023-02-22 15:25   ` [PATCH 1/2] include: uapi: scsi: Change utp_upiu_query struct Bart Van Assche
2023-02-27 16:03     ` Arthur Simchaev
2023-02-27 16:59       ` Bart Van Assche
2023-03-01  9:46         ` Arthur Simchaev
2023-03-01 18:44           ` Bart Van Assche
2023-03-02  7:52             ` Arthur Simchaev
2023-02-23  2:23   ` kernel test robot
2023-02-22 15:12 ` [PATCH 2/2] ufs: core: Providing Timestamp information to the device Arthur Simchaev

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=1677078770-30994-2-git-send-email-Arthur.Simchaev@wdc.com \
    --to=arthur.simchaev@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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.