mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
@ 2023-03-28 10:37 Po-Wen Kao
  2023-03-28 10:37 ` [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Po-Wen Kao @ 2023-03-28 10:37 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, mason.zhang,
	chaotian.jing, jiajie.hao

Quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR is introduced for plaforms that
implement different interrupt topology from UFSHCI 4.0 spec.
Some platform 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>
---
 drivers/ufs/core/ufshcd.c | 8 ++++++--
 include/ufs/ufshcd.h      | 7 +++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index acae4e194ec4..1e1271aca1f2 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8493,11 +8493,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 = (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_INTR) ?
+		(UFSHCD_ENABLE_MCQ_INTRS & ~MCQ_CQ_EVENT_STATUS) : UFSHCD_ENABLE_MCQ_INTRS;
+
+	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 25aab8ec4f86..7bb9e1a17154 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -616,6 +616,13 @@ enum ufshcd_quirks {
 	 * to reinit the device after switching to maximum gear.
 	 */
 	UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH       = 1 << 19,
+
+	/*
+	 * Some platform 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] 6+ messages in thread

* [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
  2023-03-28 10:37 [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Po-Wen Kao
@ 2023-03-28 10:37 ` Po-Wen Kao
  2023-03-29  1:32   ` Stanley Chu
  2023-03-29  3:08   ` Bart Van Assche
  2023-03-29  1:32 ` [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Stanley Chu
  2023-03-29  3:07 ` Bart Van Assche
  2 siblings, 2 replies; 6+ messages in thread
From: Po-Wen Kao @ 2023-03-28 10:37 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, mason.zhang, chaotian.jing,
	jiajie.hao

Set UFSHCD_QUIRK_MCQ_BROKEN_INTR for mtk driver

Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
 drivers/ufs/host/ufs-mediatek.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 73e217260390..b4a4a580ad37 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -901,6 +901,8 @@ 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] 6+ messages in thread

* Re: [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
  2023-03-28 10:37 [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Po-Wen Kao
  2023-03-28 10:37 ` [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
@ 2023-03-29  1:32 ` Stanley Chu
  2023-03-29  3:07 ` Bart Van Assche
  2 siblings, 0 replies; 6+ messages in thread
From: Stanley Chu @ 2023-03-29  1:32 UTC (permalink / raw)
  To: Po-Wen Kao
  Cc: 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,
	wsd_upstream, peter.wang, stanley.chu, alice.chao, naomi.chu,
	chun-hung.wu, cc.chou, eddie.huang, mason.zhang, chaotian.jing,
	jiajie.hao

Hi Po-Wen,

On Tue, Mar 28, 2023 at 6:42 PM Po-Wen Kao <powen.kao@mediatek.com> wrote:
>
> Quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR is introduced for plaforms that
> implement different interrupt topology from UFSHCI 4.0 spec.
> Some platform 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>
> ---
>  drivers/ufs/core/ufshcd.c | 8 ++++++--
>  include/ufs/ufshcd.h      | 7 +++++++
>  2 files changed, 13 insertions(+), 2 deletions(-)

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
  2023-03-28 10:37 ` [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
@ 2023-03-29  1:32   ` Stanley Chu
  2023-03-29  3:08   ` Bart Van Assche
  1 sibling, 0 replies; 6+ messages in thread
From: Stanley Chu @ 2023-03-29  1:32 UTC (permalink / raw)
  To: Po-Wen Kao
  Cc: linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek,
	Stanley Chu, James E.J. Bottomley, Martin K. Petersen,
	Matthias Brugger, AngeloGioacchino Del Regno, wsd_upstream,
	peter.wang, alice.chao, naomi.chu, chun-hung.wu, cc.chou,
	eddie.huang, mason.zhang, chaotian.jing, jiajie.hao

On Tue, Mar 28, 2023 at 6:42 PM Po-Wen Kao <powen.kao@mediatek.com> wrote:
>
> Set UFSHCD_QUIRK_MCQ_BROKEN_INTR for mtk driver
>
> Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
> ---
>  drivers/ufs/host/ufs-mediatek.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
> index 73e217260390..b4a4a580ad37 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -901,6 +901,8 @@ 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
>

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR
  2023-03-28 10:37 [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Po-Wen Kao
  2023-03-28 10:37 ` [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
  2023-03-29  1:32 ` [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Stanley Chu
@ 2023-03-29  3:07 ` Bart Van Assche
  2 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2023-03-29  3:07 UTC (permalink / raw)
  To: Po-Wen Kao, linux-scsi, linux-kernel, linux-arm-kernel,
	linux-mediatek, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger, AngeloGioacchino Del Regno
  Cc: wsd_upstream, peter.wang, stanley.chu, alice.chao, naomi.chu,
	chun-hung.wu, cc.chou, eddie.huang, mason.zhang, chaotian.jing,
	jiajie.hao

On 3/28/23 03:37, Po-Wen Kao wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index acae4e194ec4..1e1271aca1f2 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8493,11 +8493,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 " : "");

The use of blank lines in the above code is weird. Please make sure 
there is no blank line inside the declaration block and also that there 
is a blank line between declarations and statements as required by the 
kernel coding style.

> -	ufshcd_enable_intr(hba, UFSHCD_ENABLE_MCQ_INTRS);
> +	intrs = (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_INTR) ?
> +		(UFSHCD_ENABLE_MCQ_INTRS & ~MCQ_CQ_EVENT_STATUS) : UFSHCD_ENABLE_MCQ_INTRS;

All parentheses in the above expression are superfluous. Please leave 
these out. Or even better, rewrite the above code as follows:

	intrs = UFSHCD_ENABLE_MCQ_INTRS;
	if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_INTR)
		intrs &= ~MCQ_CQ_EVENT_STATUS;

> +
> +	/*
> +	 * Some platform 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,

Isn't this an UFS controller behavior instead of a platform behavior? 
Please consider changing "platform raises" into "controllers raise".

Thanks,

Bart.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk
  2023-03-28 10:37 ` [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
  2023-03-29  1:32   ` Stanley Chu
@ 2023-03-29  3:08   ` Bart Van Assche
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2023-03-29  3:08 UTC (permalink / raw)
  To: Po-Wen Kao, 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, alice.chao, naomi.chu, chun-hung.wu,
	cc.chou, eddie.huang, mason.zhang, chaotian.jing, jiajie.hao

On 3/28/23 03:37, Po-Wen Kao wrote:
> Set UFSHCD_QUIRK_MCQ_BROKEN_INTR for mtk driver

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-29  3:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 10:37 [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Po-Wen Kao
2023-03-28 10:37 ` [PATCH 2/2] scsi: ufs: ufs-mediatek: Add UFSHCD_QUIRK_MCQ_BROKEN_INTR quirk Po-Wen Kao
2023-03-29  1:32   ` Stanley Chu
2023-03-29  3:08   ` Bart Van Assche
2023-03-29  1:32 ` [PATCH 1/2] scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_INTR Stanley Chu
2023-03-29  3:07 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®