* [PATCH 1/1] Revert "scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb()"
@ 2026-04-24 6:35 ed.tsai
2026-04-24 22:55 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: ed.tsai @ 2026-04-24 6:35 UTC (permalink / raw)
To: ed.tsai, Alim Akhtar, Avri Altman, Bart Van Assche,
James E.J. Bottomley, Martin K. Petersen, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: linux-kernel, linux-arm-kernel, linux-mediatek, wsd_upstream,
peter.wang, alice.chao, naomi.chu, chun-hung.wu, linux-scsi
From: Ed Tsai <ed.tsai@mediatek.com>
This reverts commit d5130c5a093257aa4542aaded8034ef116a7624a.
The offsets stored in utp_transfer_req_desc are in double words on
hosts without UFSHCD_QUIRK_PRDT_BYTE_GRAN, using them directly to
compute ucd_rsp_dma_addr and ucd_prdt_dma_addr results in incorrect
DMA addresses. The manual offsetof(struct utp_transfer_cmd_desc, ...)
calculations always yield correct byte offsets regardless of the quirk
and should be used instead.
Note that these DMA addresses are only used in ufshcd_print_tr() for
error logging, so the impact is limited to misleading error logs.
Fixes: d5130c5a0932 ("scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb()")
Signed-off-by: Ed Tsai <ed.tsai@mediatek.com>
---
drivers/ufs/core/ufshcd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 4805e40ed4d7..3df2b44111cc 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2971,8 +2971,9 @@ static void ufshcd_init_lrb(struct ufs_hba *hba, struct scsi_cmnd *cmd)
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 = le16_to_cpu(utrdlp[i].response_upiu_offset);
- u16 prdt_offset = le16_to_cpu(utrdlp[i].prd_table_offset);
+ u16 response_offset = offsetof(struct utp_transfer_cmd_desc,
+ response_upiu);
+ u16 prdt_offset = offsetof(struct utp_transfer_cmd_desc, prd_table);
struct ufshcd_lrb *lrb = scsi_cmd_priv(cmd);
lrb->utr_descriptor_ptr = utrdlp + i;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/1] Revert "scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb()"
2026-04-24 6:35 [PATCH 1/1] Revert "scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb()" ed.tsai
@ 2026-04-24 22:55 ` Bart Van Assche
2026-04-26 23:41 ` Ed Tsai (蔡宗軒)
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2026-04-24 22:55 UTC (permalink / raw)
To: ed.tsai, Alim Akhtar, James E.J. Bottomley, Martin K. Petersen,
Matthias Brugger, AngeloGioacchino Del Regno, Avri Altman
Cc: linux-kernel, linux-arm-kernel, linux-mediatek, wsd_upstream,
peter.wang, alice.chao, naomi.chu, chun-hung.wu, linux-scsi
On 4/23/26 11:35 PM, ed.tsai@mediatek.com wrote:
> Note that these DMA addresses are only used in ufshcd_print_tr() for
> error logging, so the impact is limited to misleading error logs.
Instead of fixing these offsets, please remove the ucd_rsp_dma_addr and
ucd_prdt_dma_addr members from struct ufshcd_lrb.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] Revert "scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb()"
2026-04-24 22:55 ` Bart Van Assche
@ 2026-04-26 23:41 ` Ed Tsai (蔡宗軒)
0 siblings, 0 replies; 3+ messages in thread
From: Ed Tsai (蔡宗軒) @ 2026-04-26 23:41 UTC (permalink / raw)
To: avri.altman@sandisk.com, matthias.bgg@gmail.com,
AngeloGioacchino Del Regno, bvanassche@acm.org,
alim.akhtar@samsung.com, martin.petersen@oracle.com,
James.Bottomley@HansenPartnership.com
Cc: Alice Chao (趙珮均), linux-scsi@vger.kernel.org,
wsd_upstream, linux-kernel@vger.kernel.org,
Chun-Hung Wu (巫駿宏),
linux-arm-kernel@lists.infradead.org,
Naomi Chu (朱詠田),
linux-mediatek@lists.infradead.org,
Peter Wang (王信友)
On Fri, 2026-04-24 at 15:55 -0700, Bart Van Assche wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> On 4/23/26 11:35 PM, ed.tsai@mediatek.com wrote:
> > Note that these DMA addresses are only used in ufshcd_print_tr()
> > for
> > error logging, so the impact is limited to misleading error logs.
>
> Instead of fixing these offsets, please remove the ucd_rsp_dma_addr
> and
> ucd_prdt_dma_addr members from struct ufshcd_lrb.
>
> Thanks,
>
> Bart.
Sounds good, I will send a new patch. Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-26 23:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 6:35 [PATCH 1/1] Revert "scsi: ufs: Use pre-calculated offsets in ufshcd_init_lrb()" ed.tsai
2026-04-24 22:55 ` Bart Van Assche
2026-04-26 23:41 ` Ed Tsai (蔡宗軒)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox