diff mbox series

[v2] scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb

Message ID 20240910044543.3812642-1-avri.altman@wdc.com
State New
Headers show
Series [v2] scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb | expand

Commit Message

Avri Altman Sept. 10, 2024, 4:45 a.m. UTC
Replace manual offset calculations for response_upiu and prd_table in
ufshcd_init_lrb() with pre-calculated offsets already stored in the
utp_transfer_req_desc structure. The pre-calculated offsets are set
differently in ufshcd_host_memory_configure() based on the
UFSHCD_QUIRK_PRDT_BYTE_GRAN quirk, ensuring correct alignment and
access.

Fixes: 26f968d7de82 ("scsi: ufs: Introduce UFSHCD_QUIRK_PRDT_BYTE_GRAN quirk")
Cc: stable@vger.kernel.org
Signed-off-by: Avri Altman <avri.altman@wdc.com>

---
Changes in v2:
 - add Fixes: and Cc: stable tags
 - fix kernel test robot warning about type mismatch by using le16_to_cpu
---
 drivers/ufs/core/ufshcd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Bart Van Assche Sept. 11, 2024, 10:32 p.m. UTC | #1
On 9/9/24 9:45 PM, Avri Altman wrote:
> Replace manual offset calculations for response_upiu and prd_table in
> ufshcd_init_lrb() with pre-calculated offsets already stored in the
> utp_transfer_req_desc structure. The pre-calculated offsets are set
> differently in ufshcd_host_memory_configure() based on the
> UFSHCD_QUIRK_PRDT_BYTE_GRAN quirk, ensuring correct alignment and
> access.

With which host controllers has this patch been tested?

Thanks,

Bart.
Avri Altman Sept. 12, 2024, 6:56 a.m. UTC | #2
> On 9/9/24 9:45 PM, Avri Altman wrote:
> > Replace manual offset calculations for response_upiu and prd_table in
> > ufshcd_init_lrb() with pre-calculated offsets already stored in the
> > utp_transfer_req_desc structure. The pre-calculated offsets are set
> > differently in ufshcd_host_memory_configure() based on the
> > UFSHCD_QUIRK_PRDT_BYTE_GRAN quirk, ensuring correct alignment and
> > access.
> 
> With which host controllers has this patch been tested?
Qualcomm RB5 platform.
I guess I'll be needing help with testing it on an exynos platforms?

Thanks,
Avri

> 
> Thanks,
> 
> Bart.
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 8ea5a82503a9..85251c176ef7 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2919,9 +2919,8 @@  static void ufshcd_init_lrb(struct ufs_hba *hba, struct ufshcd_lrb *lrb, int i)
 	struct utp_transfer_req_desc *utrdlp = hba->utrdl_base_addr;
 	dma_addr_t cmd_desc_element_addr = hba->ucdl_dma_addr +
 		i * ufshcd_get_ucd_size(hba);
-	u16 response_offset = offsetof(struct utp_transfer_cmd_desc,
-				       response_upiu);
-	u16 prdt_offset = offsetof(struct utp_transfer_cmd_desc, prd_table);
+	u16 response_offset = le16_to_cpu(utrdlp[i].response_upiu_offset);
+	u16 prdt_offset = le16_to_cpu(utrdlp[i].prd_table_offset);
 
 	lrb->utr_descriptor_ptr = utrdlp + i;
 	lrb->utrd_dma_addr = hba->utrdl_dma_addr +