* [PATCH v1 1/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
@ 2023-06-12 8:58 ` Po-Wen Kao
2023-06-12 8:58 ` [PATCH v1 2/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC Po-Wen Kao
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Po-Wen Kao @ 2023-06-12 8:58 UTC (permalink / raw)
To: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Martin K. Petersen, Matthias Brugger, AngeloGioacchino Del Regno
Cc: wsd_upstream, peter.wang, stanley.chu, powen.kao, alice.chao,
naomi.chu, chun-hung.wu, cc.chou, eddie.huang
Quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR is introduced for host that
implement different interrupt topology from UFSHCI 4.0 spec.
Some host raise per hw queue interrupt in addition to
CQES (traditional) when ESI is disabled.
Enable this quirk will disable CQES and use only per hw queue
interrupt.
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
---
drivers/ufs/core/ufshcd.c | 6 +++++-
include/ufs/ufshcd.h | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 5da62248ebc4..5e093eba897b 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8608,11 +8608,15 @@ static int ufshcd_alloc_mcq(struct ufs_hba *hba)
static void ufshcd_config_mcq(struct ufs_hba *hba)
{
int ret;
+ u32 intrs;
ret = ufshcd_mcq_vops_config_esi(hba);
dev_info(hba->dev, "ESI %sconfigured\n", ret ? "is not " : "");
- ufshcd_enable_intr(hba, UFSHCD_ENABLE_MCQ_INTRS);
+ intrs = UFSHCD_ENABLE_MCQ_INTRS;
+ if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_INTR)
+ intrs &= ~MCQ_CQ_EVENT_STATUS;
+ ufshcd_enable_intr(hba, intrs);
ufshcd_mcq_make_queues_operational(hba);
ufshcd_mcq_config_mac(hba, hba->nutrs);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 9b2d1859f885..ea43ceaf881c 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -611,6 +611,13 @@ enum ufshcd_quirks {
* to reinit the device after switching to maximum gear.
*/
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH = 1 << 19,
+
+ /*
+ * Some host raises interrupt (per queue) in addition to
+ * CQES (traditional) when ESI is disabled.
+ * Enable this quirk will disable CQES and use per queue interrupt.
+ */
+ UFSHCD_QUIRK_MCQ_BROKEN_INTR = 1 << 20,
};
enum ufshcd_caps {
--
2.18.0
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v1 2/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
2023-06-12 8:58 ` [PATCH v1 1/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Po-Wen Kao
@ 2023-06-12 8:58 ` Po-Wen Kao
2023-06-12 8:58 ` [PATCH v1 3/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Po-Wen Kao @ 2023-06-12 8:58 UTC (permalink / raw)
To: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
Martin K. Petersen, Matthias Brugger, AngeloGioacchino Del Regno
Cc: wsd_upstream, peter.wang, stanley.chu, powen.kao, alice.chao,
naomi.chu, chun-hung.wu, cc.chou, eddie.huang
Some host does not implement SQ Run Time Command (SQRTC) register
thus need this quirk to skip related flow.
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
drivers/ufs/core/ufs-mcq.c | 12 ++++++++++++
include/ufs/ufshcd.h | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 785fc9762cad..e5be3445c4ab 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -458,6 +458,9 @@ static int ufshcd_mcq_sq_stop(struct ufs_hba *hba, struct ufs_hw_queue *hwq)
u32 id = hwq->id, val;
int err;
+ if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
+ return -ETIMEDOUT;
+
writel(SQ_STOP, mcq_opr_base(hba, OPR_SQD, id) + REG_SQRTC);
reg = mcq_opr_base(hba, OPR_SQD, id) + REG_SQRTS;
err = read_poll_timeout(readl, val, val & SQ_STS, 20,
@@ -474,6 +477,9 @@ static int ufshcd_mcq_sq_start(struct ufs_hba *hba, struct ufs_hw_queue *hwq)
u32 id = hwq->id, val;
int err;
+ if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
+ return -ETIMEDOUT;
+
writel(SQ_START, mcq_opr_base(hba, OPR_SQD, id) + REG_SQRTC);
reg = mcq_opr_base(hba, OPR_SQD, id) + REG_SQRTS;
err = read_poll_timeout(readl, val, !(val & SQ_STS), 20,
@@ -501,6 +507,9 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
u32 nexus, id, val;
int err;
+ if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
+ return -ETIMEDOUT;
+
if (task_tag != hba->nutrs - UFSHCD_NUM_RESERVED) {
if (!cmd)
return -EINVAL;
@@ -583,6 +592,9 @@ static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba,
u64 addr, match;
u32 sq_head_slot;
+ if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
+ return true;
+
mutex_lock(&hwq->sq_mutex);
ufshcd_mcq_sq_stop(hba, hwq);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index ea43ceaf881c..86b4aae5aa2c 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -618,6 +618,12 @@ enum ufshcd_quirks {
* Enable this quirk will disable CQES and use per queue interrupt.
*/
UFSHCD_QUIRK_MCQ_BROKEN_INTR = 1 << 20,
+
+ /*
+ * Some host does not implement SQ Run Time Command (SQRTC) register
+ * thus need this quirk to skip related flow.
+ */
+ UFSHCD_QUIRK_MCQ_BROKEN_RTC = 1 << 21,
};
enum ufshcd_caps {
--
2.18.0
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v1 3/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
2023-06-12 8:58 ` [PATCH v1 1/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Po-Wen Kao
2023-06-12 8:58 ` [PATCH v1 2/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC Po-Wen Kao
@ 2023-06-12 8:58 ` Po-Wen Kao
2023-06-12 8:58 ` [PATCH v1 4/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_RTC quirk Po-Wen Kao
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Po-Wen Kao @ 2023-06-12 8:58 UTC (permalink / raw)
To: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Stanley Chu, James E.J. Bottomley, Martin K. Petersen,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: wsd_upstream, peter.wang, powen.kao, alice.chao, naomi.chu,
chun-hung.wu, cc.chou, eddie.huang
Enable UFSHCD_QUIRK_MCQ_BROKEN_INTR for MediaTek host
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
drivers/ufs/host/ufs-mediatek.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 33b301649757..269a26d72784 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -898,6 +898,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
hba->caps |= UFSHCD_CAP_CLK_SCALING;
hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL;
+ hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR;
hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80);
if (host->caps & UFS_MTK_CAP_DISABLE_AH8)
--
2.18.0
^ permalink raw reply [flat|nested] 9+ messages in thread* [PATCH v1 4/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_RTC quirk
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
` (2 preceding siblings ...)
2023-06-12 8:58 ` [PATCH v1 3/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
@ 2023-06-12 8:58 ` Po-Wen Kao
2023-06-12 14:40 ` [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Bart Van Assche
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Po-Wen Kao @ 2023-06-12 8:58 UTC (permalink / raw)
To: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Stanley Chu, James E.J. Bottomley, Martin K. Petersen,
Matthias Brugger, AngeloGioacchino Del Regno
Cc: wsd_upstream, peter.wang, powen.kao, alice.chao, naomi.chu,
chun-hung.wu, cc.chou, eddie.huang
Enable UFSHCD_QUIRK_MCQ_BROKEN_RTC for MediaTek host
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
drivers/ufs/host/ufs-mediatek.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 269a26d72784..e68b05976f9e 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -899,6 +899,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL;
hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR;
+ hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC;
hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80);
if (host->caps & UFS_MTK_CAP_DISABLE_AH8)
--
2.18.0
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
` (3 preceding siblings ...)
2023-06-12 8:58 ` [PATCH v1 4/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_RTC quirk Po-Wen Kao
@ 2023-06-12 14:40 ` Bart Van Assche
2023-06-12 15:27 ` Stanley Chu
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2023-06-12 14:40 UTC (permalink / raw)
To: Po-Wen Kao, linux-scsi, linux-kernel, linux-arm-kernel,
linux-mediatek, Matthias Brugger, AngeloGioacchino Del Regno
Cc: wsd_upstream, peter.wang, stanley.chu, alice.chao, naomi.chu,
chun-hung.wu, cc.chou, eddie.huang
On 6/12/23 01:58, Po-Wen Kao wrote:
> v1
> Introduce quirks for non-standard part of UFSHCI and address Bart's comment
> from last patch
> https://lore.kernel.org/all/20230328103801.11198-1-powen.kao@mediatek.com/
For the entire series:
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
` (4 preceding siblings ...)
2023-06-12 14:40 ` [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Bart Van Assche
@ 2023-06-12 15:27 ` Stanley Chu
2023-06-15 1:46 ` Martin K. Petersen
2023-06-22 1:26 ` Martin K. Petersen
7 siblings, 0 replies; 9+ messages in thread
From: Stanley Chu @ 2023-06-12 15:27 UTC (permalink / raw)
To: Po-Wen Kao
Cc: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Matthias Brugger, AngeloGioacchino Del Regno, wsd_upstream,
peter.wang, stanley.chu, alice.chao, naomi.chu, chun-hung.wu,
cc.chou, eddie.huang
On Mon, Jun 12, 2023 at 5:11 PM Po-Wen Kao <powen.kao@mediatek.com> wrote:
>
> v1
> Introduce quirks for non-standard part of UFSHCI and address Bart's comment
> from last patch
> https://lore.kernel.org/all/20230328103801.11198-1-powen.kao@mediatek.com/
>
>
> Po-Wen Kao (4):
> scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
> scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC
> scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
> scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_RTC quirk
>
> drivers/ufs/core/ufs-mcq.c | 12 ++++++++++++
> drivers/ufs/core/ufshcd.c | 6 +++++-
> drivers/ufs/host/ufs-mediatek.c | 2 ++
> include/ufs/ufshcd.h | 13 +++++++++++++
> 4 files changed, 32 insertions(+), 1 deletion(-)
>
> --
> 2.18.0
>
The entire series looks good to me.
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
` (5 preceding siblings ...)
2023-06-12 15:27 ` Stanley Chu
@ 2023-06-15 1:46 ` Martin K. Petersen
2023-06-22 1:26 ` Martin K. Petersen
7 siblings, 0 replies; 9+ messages in thread
From: Martin K. Petersen @ 2023-06-15 1:46 UTC (permalink / raw)
To: Po-Wen Kao
Cc: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Matthias Brugger, AngeloGioacchino Del Regno, wsd_upstream,
peter.wang, stanley.chu, alice.chao, naomi.chu, chun-hung.wu,
cc.chou, eddie.huang
Po-Wen,
> Introduce quirks for non-standard part of UFSHCI and address Bart's comment
> from last patch
Applied to 6.5/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host
2023-06-12 8:58 [PATCH v1 0/4] ufs: Introduce MCQ Quirks for MediaTek host Po-Wen Kao
` (6 preceding siblings ...)
2023-06-15 1:46 ` Martin K. Petersen
@ 2023-06-22 1:26 ` Martin K. Petersen
7 siblings, 0 replies; 9+ messages in thread
From: Martin K. Petersen @ 2023-06-22 1:26 UTC (permalink / raw)
To: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
Matthias Brugger, AngeloGioacchino Del Regno, Po-Wen Kao
Cc: Martin K . Petersen, wsd_upstream, peter.wang, stanley.chu,
alice.chao, naomi.chu, chun-hung.wu, cc.chou, eddie.huang
On Mon, 12 Jun 2023 16:58:08 +0800, Po-Wen Kao wrote:
> v1
> Introduce quirks for non-standard part of UFSHCI and address Bart's comment
> from last patch
> https://lore.kernel.org/all/20230328103801.11198-1-powen.kao@mediatek.com/
>
>
> Po-Wen Kao (4):
> scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
> scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC
> scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
> scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_RTC quirk
>
> [...]
Applied to 6.5/scsi-queue, thanks!
[1/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
https://git.kernel.org/mkp/scsi/c/c4ad4f2e6646
[2/4] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC
https://git.kernel.org/mkp/scsi/c/aa9d5d0015a8
[3/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
https://git.kernel.org/mkp/scsi/c/95cd364ccc97
[4/4] scsi: ufs: ufs-mediatek: Set UFSHCD_QUIRK_MCQ_BROKEN_RTC quirk
https://git.kernel.org/mkp/scsi/c/3c9b49be6666
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 9+ messages in thread