diff mbox series

ufs: fix a bug on printing PRDT

Message ID 20200218233115.8185-1-kwmad.kim@samsung.com (mailing list archive)
State Changes Requested
Headers show
Series ufs: fix a bug on printing PRDT | expand

Commit Message

Kiwoong Kim Feb. 18, 2020, 11:31 p.m. UTC
In some architectures, an unit of PRDTO and PRDTL
in UFSHCI spec assume bytes, not double word specified
in the spec. W/o this patch, when the driver executes
this, kernel panic occurres because of abnormal accesses.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Feb. 18, 2020, 11:38 p.m. UTC | #1
On Wed, Feb 19, 2020 at 08:31:15AM +0900, Kiwoong Kim wrote:
> In some architectures, an unit of PRDTO and PRDTL
> in UFSHCI spec assume bytes, not double word specified
> in the spec. W/o this patch, when the driver executes
> this, kernel panic occurres because of abnormal accesses.

This quirk doesn't have any driver actually setting it, so we need
to remove it.
Kiwoong Kim Feb. 18, 2020, 11:55 p.m. UTC | #2
> On Wed, Feb 19, 2020 at 08:31:15AM +0900, Kiwoong Kim wrote:
> > In some architectures, an unit of PRDTO and PRDTL in UFSHCI spec
> > assume bytes, not double word specified in the spec. W/o this patch,
> > when the driver executes this, kernel panic occurres because of
> > abnormal accesses.
> 
> This quirk doesn't have any driver actually setting it, so we need to
> remove it.

Exynos specific driver sets and is using it but the driver is not updated
yet. I'll do upstream it in the future.
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f4aa10fdbb0c..94c4a0f9fd9b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -462,8 +462,12 @@  void ufshcd_print_trs(struct ufs_hba *hba, unsigned long bitmap, bool pr_prdt)
 		ufshcd_hex_dump("UPIU RSP: ", lrbp->ucd_rsp_ptr,
 				sizeof(struct utp_upiu_rsp));
 
-		prdt_length = le16_to_cpu(
-			lrbp->utr_descriptor_ptr->prd_table_length);
+		if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN)
+			prdt_length = le16_to_cpu(lrbp->utr_descriptor_ptr->prd_table_length)
+				/ sizeof(struct ufshcd_sg_entry);
+		else
+			prdt_length = le16_to_cpu(lrbp->utr_descriptor_ptr->prd_table_length);
+
 		dev_err(hba->dev,
 			"UPIU[%d] - PRDT - %d entries  phys@0x%llx\n",
 			tag, prdt_length,