From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Can Guo <cang@codeaurora.org>, Bean Huo <beanhuo@micron.com>,
Stanley Chu <stanley.chu@mediatek.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Asutosh Das <asutoshd@codeaurora.org>,
Avri Altman <avri.altman@wdc.com>,
Caleb Connolly <caleb@connolly.tech>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: [PATCH v2 10/10] scsi: ufs: Micro-optimize ufshcd_map_sg()
Date: Wed, 20 Oct 2021 14:40:24 -0700 [thread overview]
Message-ID: <20211020214024.2007615-11-bvanassche@acm.org> (raw)
In-Reply-To: <20211020214024.2007615-1-bvanassche@acm.org>
Replace two cpu_to_le32() calls by a single cpu_to_le64() call.
Additionally, issue a warning if the length of an scatter gather list
element exceeds what is allowed by the UFSHCI specification.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/ufs/ufshcd.c | 19 +++++++++++++------
drivers/scsi/ufs/ufshci.h | 6 ++----
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index dde4d3f607f2..04cb67995750 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -2379,12 +2379,19 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
prd_table = lrbp->ucd_prdt_ptr;
scsi_for_each_sg(cmd, sg, sg_segments, i) {
- prd_table[i].size =
- cpu_to_le32(((u32) sg_dma_len(sg))-1);
- prd_table[i].base_addr =
- cpu_to_le32(lower_32_bits(sg->dma_address));
- prd_table[i].upper_addr =
- cpu_to_le32(upper_32_bits(sg->dma_address));
+ const unsigned int len = sg_dma_len(sg);
+
+ /*
+ * From the UFSHCI spec: "Data Byte Count (DBC): A '0'
+ * based value that indicates the length, in bytes, of
+ * the data block. A maximum of length of 256KB may
+ * exist for any entry. Bits 1:0 of this field shall be
+ * 11b to indicate Dword granularity. A value of '3'
+ * indicates 4 bytes, '7' indicates 8 bytes, etc."
+ */
+ WARN_ONCE(len > 256 * 1024, "len = %#x\n", len);
+ prd_table[i].size = cpu_to_le32(len - 1);
+ prd_table[i].addr = cpu_to_le64(sg->dma_address);
prd_table[i].reserved = 0;
}
} else {
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index f66cf9e477cb..6a295c88d850 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -415,14 +415,12 @@ enum {
/**
* struct ufshcd_sg_entry - UFSHCI PRD Entry
- * @base_addr: Lower 32bit physical address DW-0
- * @upper_addr: Upper 32bit physical address DW-1
+ * @addr: Physical address; DW-0 and DW-1.
* @reserved: Reserved for future use DW-2
* @size: size of physical segment DW-3
*/
struct ufshcd_sg_entry {
- __le32 base_addr;
- __le32 upper_addr;
+ __le64 addr;
__le32 reserved;
__le32 size;
};
next prev parent reply other threads:[~2021-10-20 21:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 21:40 [PATCH v2 00/10] UFS patches for kernel v5.16 Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 01/10] scsi: ufs: Revert "Retry aborted SCSI commands instead of completing these successfully" Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 02/10] scsi: ufs: Improve source code comments Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 03/10] scsi: ufs: Improve static type checking Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 04/10] scsi: ufs: Log error handler activity Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 05/10] scsi: ufs: Export ufshcd_schedule_eh_work() Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 06/10] scsi: ufs: Make it easier to add new debugfs attributes Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 07/10] scsi: ufs: Add debugfs attributes for triggering the UFS EH Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 08/10] scsi: ufs: Remove three superfluous casts Bart Van Assche
2021-10-20 21:40 ` [PATCH v2 09/10] scsi: ufs: Add a compile-time structure size check Bart Van Assche
2021-10-20 21:40 ` Bart Van Assche [this message]
2021-10-24 7:49 ` [PATCH v2 00/10] UFS patches for kernel v5.16 Avri Altman
2021-10-27 3:25 ` Martin K. Petersen
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=20211020214024.2007615-11-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=adrian.hunter@intel.com \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=caleb@connolly.tech \
--cc=cang@codeaurora.org \
--cc=gustavoars@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stanley.chu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox