summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ufs/ufshpb.c
diff options
context:
space:
mode:
authorBean Huo <beanhuo@micron.com>2021-08-04 20:21:27 +0200
committerMartin K. Petersen <martin.petersen@oracle.com>2021-08-05 23:21:08 -0400
commit63522bf3aced0a782b59f0314dbad5cdc8b14c59 (patch)
treeb0623d9474dc9676a1b20f30c8e73fe118e2e3bc /drivers/scsi/ufs/ufshpb.c
parentf0101af435c4640e78c0fa0dbacb443c0f31cfb7 (diff)
downloadlinux-63522bf3aced0a782b59f0314dbad5cdc8b14c59.tar.gz
linux-63522bf3aced0a782b59f0314dbad5cdc8b14c59.tar.bz2
linux-63522bf3aced0a782b59f0314dbad5cdc8b14c59.zip
scsi: ufs: core: Add L2P entry swap quirk for Micron UFS
For Micron UFS devices the L2P entry need to be byteswapped before sending an HPB READ command to the UFS device. Add the quirk UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ to address this. Link: https://lore.kernel.org/r/20210804182128.458356-2-huobean@gmail.com Reviewed-by: Avri Altman <avri.altman@wdc.com> Signed-off-by: Bean Huo <beanhuo@micron.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/ufs/ufshpb.c')
-rw-r--r--drivers/scsi/ufs/ufshpb.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
index 54e8e019bdbe..d0eb14be47a3 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -323,15 +323,19 @@ ufshpb_get_pos_from_lpn(struct ufshpb_lu *hpb, unsigned long lpn, int *rgn_idx,
}
static void
-ufshpb_set_hpb_read_to_upiu(struct ufshpb_lu *hpb, struct ufshcd_lrb *lrbp,
- u32 lpn, __be64 ppn, u8 transfer_len, int read_id)
+ufshpb_set_hpb_read_to_upiu(struct ufs_hba *hba, struct ufshpb_lu *hpb,
+ struct ufshcd_lrb *lrbp, u32 lpn, __be64 ppn,
+ u8 transfer_len, int read_id)
{
unsigned char *cdb = lrbp->cmd->cmnd;
-
+ __be64 ppn_tmp = ppn;
cdb[0] = UFSHPB_READ;
+ if (hba->dev_quirks & UFS_DEVICE_QUIRK_SWAP_L2P_ENTRY_FOR_HPB_READ)
+ ppn_tmp = swab64(ppn);
+
/* ppn value is stored as big-endian in the host memory */
- memcpy(&cdb[6], &ppn, sizeof(__be64));
+ memcpy(&cdb[6], &ppn_tmp, sizeof(__be64));
cdb[14] = transfer_len;
cdb[15] = read_id;
@@ -689,7 +693,8 @@ int ufshpb_prep(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
}
}
- ufshpb_set_hpb_read_to_upiu(hpb, lrbp, lpn, ppn, transfer_len, read_id);
+ ufshpb_set_hpb_read_to_upiu(hba, hpb, lrbp, lpn, ppn, transfer_len,
+ read_id);
hpb->stats.hit_cnt++;
return 0;