ufs: introduce UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR quirk
PATCH 1/1 ufs: introduce UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR quirk
Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTLRCLR/UTMLRCLR to 1, not 0. That's opposite to what UFS spec decribes.
--- drivers/scsi/ufs/ufshcd.c | 32 ++++++++++++++++++++++++++++---- drivers/scsi/ufs/ufshcd.h | 1 + 2 files changed, 29 insertions(+), 4 deletions(-)
drivers/scsi/ufs/ufshcd.c +28 -4
@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(struct ufs_hba *hba, int slot)*/ static inline void ufshcd_utrl_clear (struct ufs_hba *hba,u32 pos) { -ufshcd_writel (hba, ~(1 << pos),REG_UTP_TRANSFER_REQ_LIST_CLEAR ); +u32 clear; + +if (hba->quirks &UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR ) + clear = (1 << pos); +else + clear = ~(1 << pos); + +ufshcd_writel (hba, clear,REG_UTP_TRANSFER_REQ_LIST_CLEAR ); +} + +/** +* ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register +* @hba: per adapter instance +* @pos: position of the bit to be cleared +*/ +static inline void ufshcd_utmrl_clear (struct ufs_hba *hba,u32 pos) +{ +u32 clear; + +if (hba->quirks &UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR ) + clear = (1 << pos); +else + clear = ~(1 << pos); + +ufshcd_writel (hba, clear,REG_UTP_TASK_REQ_LIST_CLEAR ); }/**
@@ -1147,7 +1171,7 @@ ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)* * Returns 0 in case of success, non-zero value in case of failure */ -static int ufshcd_map_sg (struct ufshcd_lrb *lrbp) +static int ufshcd_map_sg (struct ufs_hba *hba,struct ufshcd_lrb *lrbp) {struct ufshcd_sg_entry *prd_table;struct scatterlist *sg;
@@ -1529,7 +1553,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)ufshcd_comp_scsi_upiu (hba, lrbp); - err =ufshcd_map_sg (lrbp); + err =ufshcd_map_sg (hba, lrbp);if (err) { lrbp->cmd =NULL ;clear_bit_unlock (tag, &hba->lrb_in_use);
@@ -4329,7 +4353,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) goto out;spin_lock_irqsave (hba->host->host_lock, flags); -ufshcd_writel (hba, ~(1 << tag),REG_UTP_TASK_REQ_LIST_CLEAR ); +ufshcd_utmrl_clear (hba, tag);spin_unlock_irqrestore (hba->host->host_lock, flags);/* poll for max. 1 sec to clear door bell register by h/w */
drivers/scsi/ufs/ufshcd.h +1 -0
@@ -495,6 +495,7 @@ struct ufs_hba {#define UFSHCD_QUIRK_GET_VS_RESULT UFS_BIT(6)#define UFSHCD_QUIRK_BROKEN_DWORD_UTRD UFS_BIT(7) +#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR UFS_BIT(8)unsigned int quirks;/* Deviations from standard UFSHCI spec. */
Signature · 1 line
2.1.4
Quoted 2 lines · Kiwoong Kim
Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTLRCLR/UTMLRCLR to 1, not 0.
s/UTLRCLR/UTRLCLR
s/UTMLRCLR/UTMRLCLR
Quoted 47 lines
That's opposite to what UFS spec decribes.
Signed-off-by Kiwoong Kim <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 32 ++++++++++++++++++++++++++++---- drivers/scsi/ufs/ufshcd.h | 1 + 2 files changed, 29 insertions(+), 4 deletions(-)drivers/scsi/ufs/ufshcd.c +25
-1@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(structufs_hba *hba, int slot) */ static inline void ufshcd_utrl_clear (struct ufs_hba *hba,u32 pos) { -ufshcd_writel (hba, ~(1 << pos),REG_UTP_TRANSFER_REQ_LIST_CLEAR ); +u32 clear; + +if (hba->quirks &UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR ) + clear = (1 << pos); +else + clear = ~(1 << pos); + +ufshcd_writel (hba, clear,REG_UTP_TRANSFER_REQ_LIST_CLEAR ); +} + +/** +* ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register +* @hba: per adapter instance +* @pos: position of the bit to be cleared +*/ +static inline void ufshcd_utmrl_clear (struct ufs_hba *hba,u32 pos) +{ +u32 clear; + +if (hba->quirks &UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR ) + clear = (1 << pos); +else + clear = ~(1 << pos); + +ufshcd_writel (hba, clear,REG_UTP_TASK_REQ_LIST_CLEAR ); }/**
drivers/scsi/ufs/ufshcd.c ufshcd_send_uic_cmd(struct ufs_hba *hba, struct · line 1175
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +1
-1@@ -1147,7 +1171,7 @@ ufshcd_send_uic_cmd(struct ufs_hba *hba, structuic_command *uic_cmd) * * Returns 0 in case of success, non-zero value in case of failure */ -static int ufshcd_map_sg (struct ufshcd_lrb *lrbp) +static int ufshcd_map_sg (struct ufs_hba *hba,struct ufshcd_lrb *lrbp)
unrelated change. Please remove it.
drivers/scsi/ufs/ufshcd.c static int ufshcd_queuecommand(struct Scsi_Host · line 1557
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +0
-0{struct ufshcd_sg_entry *prd_table;drivers/scsi/ufs/ufshcd.c +1
-1struct scatterlist *sg;@@ -1529,7 +1553,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)ufshcd_comp_scsi_upiu (hba, lrbp); - err =ufshcd_map_sg (lrbp); + err =ufshcd_map_sg (hba, lrbp);
unrelated change. Please remove it.
Quoted 25 lines
drivers/scsi/ufs/ufshcd.c +0
-0if (err) { lrbp->cmd =NULL ;drivers/scsi/ufs/ufshcd.c +1
-1clear_bit_unlock (tag, &hba->lrb_in_use);@@ -4329,7 +4353,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) goto out;spin_lock_irqsave (hba->host->host_lock, flags); -ufshcd_writel (hba, ~(1 << tag),REG_UTP_TASK_REQ_LIST_CLEAR ); +ufshcd_utmrl_clear (hba, tag);spin_unlock_irqrestore (hba->host->host_lock, flags);drivers/scsi/ufs/ufshcd.c +0
-0/* poll for max. 1 sec to clear door bell register by h/w */ drivers/scsi/ufs/ufshcd.h +1
-0@@ -495,6 +495,7 @@ struct ufs_hba {#define UFSHCD_QUIRK_GET_VS_RESULT UFS_BIT(6)#define UFSHCD_QUIRK_BROKEN_DWORD_UTRD UFS_BIT(7) +#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR UFS_BIT(8)unsigned int quirks;/* Deviations from standard UFSHCI spec. */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 6 lines
Quoted 2 lines
Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTLRCLR/UTMLRCLR to 1, not 0.
s/UTLRCLR/UTRLCLR
s/UTMLRCLR/UTMRLCLR
Okay
Quoted 42 lines
Quoted 42 lines
That's opposite to what UFS spec decribes.
Signed-off-by Kiwoong Kim <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 32 ++++++++++++++++++++++++++++---- drivers/scsi/ufs/ufshcd.h | 1 + 2 files changed, 29 insertions(+), 4 deletions(-)drivers/scsi/ufs/ufshcd.c +22
-1@@ -392,7 +392,31 @@ static inline void ufshcd_put_tm_slot(structufs_hba *hba, int slot) */ static inline void ufshcd_utrl_clear (struct ufs_hba *hba,u32 pos) { -ufshcd_writel (hba, ~(1 << pos),REG_UTP_TRANSFER_REQ_LIST_CLEAR ); +u32 clear; + +if (hba->quirks &UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR ) + clear = (1 << pos); +else + clear = ~(1 << pos); + +ufshcd_writel (hba, clear,REG_UTP_TRANSFER_REQ_LIST_CLEAR ); } + +/** +* ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register +* @hba: per adapter instance +* @pos: position of the bit to be cleared */ static inline void +ufshcd_utmrl_clear (struct ufs_hba *hba,u32 pos) { +u32 clear; + +if (hba->quirks &UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR ) + clear = (1 << pos); +else + clear = ~(1 << pos); + +ufshcd_writel (hba, clear,REG_UTP_TASK_REQ_LIST_CLEAR ); }
Quoted 12 lines
drivers/scsi/ufs/ufshcd.c ufshcd_send_uic_cmd(struct ufs_hba *hba, struct · line 1176
Quoted 9 lines
drivers/scsi/ufs/ufshcd.c +2
-1/** @@ -1147,7 +1171,7 @@ ufshcd_send_uic_cmd(struct ufs_hba *hba, structuic_command *uic_cmd) * * Returns 0 in case of success, non-zero value in case of failure */ -static int ufshcd_map_sg (struct ufshcd_lrb *lrbp) +static int ufshcd_map_sg (struct ufs_hba *hba,struct ufshcd_lrb +*lrbp)unrelated change. Please remove it.
Okay
Quoted 6 lines
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +0
-0{struct ufshcd_sg_entry *prd_table;struct scatterlist *sg;@@ -1529,7 +1553,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · line 1556
Quoted 4 lines
drivers/scsi/ufs/ufshcd.c +1
-1ufshcd_comp_scsi_upiu (hba, lrbp); - err =ufshcd_map_sg (lrbp); + err =ufshcd_map_sg (hba, lrbp);unrelated change. Please remove it.
Okay
Quoted 36 lines
Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +0
-0if (err) { lrbp->cmd =NULL ;
clear_bit_unlock(tag, &hba->lrb_in_use); @@ -4329,7 +4353,7@@
Quoted 14 lines
static int
ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag)drivers/scsi/ufs/ufshcd.c +1
-2goto out;spin_lock_irqsave (hba->host->host_lock, flags); -ufshcd_writel (hba, ~(1 << tag),REG_UTP_TASK_REQ_LIST_CLEAR ); +ufshcd_utmrl_clear (hba, tag);spin_unlock_irqrestore (hba->host->host_lock, flags);/* poll for max. 1 sec to clear door bell register by h/w */ diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index565f005..c4abd76 100644
drivers/scsi/ufs/ufshcd.h struct ufs_hba { · line 501
Quoted 7 lines
drivers/scsi/ufs/ufshcd.h +1
-0@@ -495,6 +495,7 @@ struct ufs_hba {#define UFSHCD_QUIRK_GET_VS_RESULT UFS_BIT(6)#define UFSHCD_QUIRK_BROKEN_DWORD_UTRD UFS_BIT(7) +#define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR UFS_BIT(8)unsigned int quirks;/* Deviations from standard UFSHCI spec. */
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html