* [PATCH v9, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number
2022-10-06 4:34 [PATCH v9, 0/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
@ 2022-10-06 4:34 ` Yongqiang Niu
2022-10-06 9:25 ` AngeloGioacchino Del Regno
2022-10-06 4:34 ` [PATCH v9, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data Yongqiang Niu
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Yongqiang Niu @ 2022-10-06 4:34 UTC (permalink / raw)
To: CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang, Yongqiang Niu
Use GCE_CTRL_BY_SW definition instead of number
Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 9465f9081515..c3cb24f51699 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -38,6 +38,7 @@
#define CMDQ_THR_PRIORITY 0x40
#define GCE_GCTL_VALUE 0x48
+#define GCE_CTRL_BY_SW GENMASK(2, 0)
#define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
#define CMDQ_THR_ENABLED 0x1
@@ -129,7 +130,8 @@ static void cmdq_init(struct cmdq *cmdq)
WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
if (cmdq->control_by_sw)
- writel(0x7, cmdq->base + GCE_GCTL_VALUE);
+ writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+
writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
for (i = 0; i <= CMDQ_MAX_EVENT; i++)
writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v9, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number
2022-10-06 4:34 ` [PATCH v9, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number Yongqiang Niu
@ 2022-10-06 9:25 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-10-06 9:25 UTC (permalink / raw)
To: Yongqiang Niu, CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang
Il 06/10/22 06:34, Yongqiang Niu ha scritto:
> Use GCE_CTRL_BY_SW definition instead of number
>
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v9, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data
2022-10-06 4:34 [PATCH v9, 0/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
2022-10-06 4:34 ` [PATCH v9, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number Yongqiang Niu
@ 2022-10-06 4:34 ` Yongqiang Niu
2022-10-06 9:29 ` AngeloGioacchino Del Regno
2022-10-06 4:34 ` [PATCH v9, 3/4] mailbox: mtk-cmdq: add gce ddr enable support flow Yongqiang Niu
2022-10-06 4:34 ` [PATCH v9, 4/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
3 siblings, 1 reply; 10+ messages in thread
From: Yongqiang Niu @ 2022-10-06 4:34 UTC (permalink / raw)
To: CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang, Yongqiang Niu
if gce work control by software, we need set software enable
for MT8186 Soc
there is a handshake flow between gce and ddr hardware,
if not set ddr enable flag of gce, ddr will fall into idle
mode, then gce instructions will not process done.
we need set this flag of gce to tell ddr when gce is idle or busy
controlled by software flow.
0x48[2:0] means control by software
0x48[18:16] means ddr enable
0x48[2:0] is pre-condition of 0x48[18:16].
if we want set 0x48[18:16] ddr enable, 0x48[2:0] must be set at same
time.
and only these bits is useful, other bits is useless bits
Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index c3cb24f51699..04eb44d89119 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -39,6 +39,7 @@
#define GCE_GCTL_VALUE 0x48
#define GCE_CTRL_BY_SW GENMASK(2, 0)
+#define GCE_DDR_EN GENMASK(18, 16)
#define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
#define CMDQ_THR_ENABLED 0x1
@@ -81,6 +82,7 @@ struct cmdq {
bool suspended;
u8 shift_pa;
bool control_by_sw;
+ bool sw_ddr_en;
u32 gce_num;
};
@@ -88,6 +90,7 @@ struct gce_plat {
u32 thread_nr;
u8 shift;
bool control_by_sw;
+ bool sw_ddr_en;
u32 gce_num;
};
@@ -132,6 +135,9 @@ static void cmdq_init(struct cmdq *cmdq)
if (cmdq->control_by_sw)
writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+ if (cmdq->sw_ddr_en)
+ writel(GCE_DDR_EN | GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+
writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
for (i = 0; i <= CMDQ_MAX_EVENT; i++)
writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);
@@ -545,6 +551,7 @@ static int cmdq_probe(struct platform_device *pdev)
cmdq->thread_nr = plat_data->thread_nr;
cmdq->shift_pa = plat_data->shift;
cmdq->control_by_sw = plat_data->control_by_sw;
+ cmdq->sw_ddr_en = plat_data->sw_ddr_en;
cmdq->gce_num = plat_data->gce_num;
cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v9, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data
2022-10-06 4:34 ` [PATCH v9, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data Yongqiang Niu
@ 2022-10-06 9:29 ` AngeloGioacchino Del Regno
[not found] ` <a4b0e7744f6934dee8f0247492cc399bbf3973bf.camel@mediatek.com>
0 siblings, 1 reply; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-10-06 9:29 UTC (permalink / raw)
To: Yongqiang Niu, CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang
Il 06/10/22 06:34, Yongqiang Niu ha scritto:
> if gce work control by software, we need set software enable
> for MT8186 Soc
>
> there is a handshake flow between gce and ddr hardware,
> if not set ddr enable flag of gce, ddr will fall into idle
> mode, then gce instructions will not process done.
> we need set this flag of gce to tell ddr when gce is idle or busy
> controlled by software flow.
>
> 0x48[2:0] means control by software
> 0x48[18:16] means ddr enable
> 0x48[2:0] is pre-condition of 0x48[18:16].
> if we want set 0x48[18:16] ddr enable, 0x48[2:0] must be set at same
> time.
> and only these bits is useful, other bits is useless bits
>
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> ---
> drivers/mailbox/mtk-cmdq-mailbox.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index c3cb24f51699..04eb44d89119 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -39,6 +39,7 @@
>
> #define GCE_GCTL_VALUE 0x48
> #define GCE_CTRL_BY_SW GENMASK(2, 0)
> +#define GCE_DDR_EN GENMASK(18, 16)
>
> #define CMDQ_THR_ACTIVE_SLOT_CYCLES 0x3200
> #define CMDQ_THR_ENABLED 0x1
> @@ -81,6 +82,7 @@ struct cmdq {
> bool suspended;
> u8 shift_pa;
> bool control_by_sw;
> + bool sw_ddr_en;
> u32 gce_num;
> };
>
> @@ -88,6 +90,7 @@ struct gce_plat {
> u32 thread_nr;
> u8 shift;
> bool control_by_sw;
> + bool sw_ddr_en;
> u32 gce_num;
> };
>
> @@ -132,6 +135,9 @@ static void cmdq_init(struct cmdq *cmdq)
> if (cmdq->control_by_sw)
> writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
>
> + if (cmdq->sw_ddr_en)
> + writel(GCE_DDR_EN | GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
> +
No. That's redundant.
Here's a better way:
u32 gctl_regval = 0;
if (cmdq->control_by_sw)
gctl_regval = GCE_CTRL_BY_SW;
if (cmdq->sw_ddr_en)
gctl_regval |= GCE_DDR_EN;
if (val)
writel(gctl_regval, cmdq->base + GCE_GCTL_VALUE);
Regards,
Angelo
> writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
> for (i = 0; i <= CMDQ_MAX_EVENT; i++)
> writel(i, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE);
> @@ -545,6 +551,7 @@ static int cmdq_probe(struct platform_device *pdev)
> cmdq->thread_nr = plat_data->thread_nr;
> cmdq->shift_pa = plat_data->shift;
> cmdq->control_by_sw = plat_data->control_by_sw;
> + cmdq->sw_ddr_en = plat_data->sw_ddr_en;
> cmdq->gce_num = plat_data->gce_num;
> cmdq->irq_mask = GENMASK(cmdq->thread_nr - 1, 0);
> err = devm_request_irq(dev, cmdq->irq, cmdq_irq_handler, IRQF_SHARED,
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v9, 3/4] mailbox: mtk-cmdq: add gce ddr enable support flow
2022-10-06 4:34 [PATCH v9, 0/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
2022-10-06 4:34 ` [PATCH v9, 1/4] mailbox: mtk-cmdq: Use GCE_CTRL_BY_SW definition instead of number Yongqiang Niu
2022-10-06 4:34 ` [PATCH v9, 2/4] mailbox: mtk-cmdq: add gce software ddr enable private data Yongqiang Niu
@ 2022-10-06 4:34 ` Yongqiang Niu
2022-10-06 9:30 ` AngeloGioacchino Del Regno
2022-10-06 4:34 ` [PATCH v9, 4/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
3 siblings, 1 reply; 10+ messages in thread
From: Yongqiang Niu @ 2022-10-06 4:34 UTC (permalink / raw)
To: CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang, Yongqiang Niu
add gce ddr enable control flow when gce suspend/resume
when all cmdq instruction task has been processed done,
we need set this gce ddr enable to disable status to tell
cmdq hardware gce there is none task need process, and the hardware
can go into idle mode and no access ddr anymore, then the spm can go
into suspend.
the original issue is gce still access ddr when cmdq suspend function
call, but there is no task run.
so, we need control gce access ddr with this flow.
when cmdq suspend function, there is no task need process, we can
disable gce access ddr, to make sure system go into suspend success.
Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 04eb44d89119..2db82ff838ed 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -94,6 +94,18 @@ struct gce_plat {
u32 gce_num;
};
+static void cmdq_sw_ddr_enable(struct cmdq *cmdq, bool enable)
+{
+ WARN_ON(clk_bulk_enable(cmdq->gce_num, cmdq->clocks));
+
+ if (enable)
+ writel(GCE_DDR_EN | GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+ else
+ writel(GCE_CTRL_BY_SW, cmdq->base + GCE_GCTL_VALUE);
+
+ clk_bulk_disable(cmdq->gce_num, cmdq->clocks);
+}
+
u8 cmdq_get_shift_pa(struct mbox_chan *chan)
{
struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);
@@ -319,6 +331,9 @@ static int cmdq_suspend(struct device *dev)
if (task_running)
dev_warn(dev, "exist running task(s) in suspend\n");
+ if (cmdq->sw_ddr_en)
+ cmdq_sw_ddr_enable(cmdq, false);
+
clk_bulk_unprepare(cmdq->gce_num, cmdq->clocks);
return 0;
@@ -330,6 +345,10 @@ static int cmdq_resume(struct device *dev)
WARN_ON(clk_bulk_prepare(cmdq->gce_num, cmdq->clocks));
cmdq->suspended = false;
+
+ if (cmdq->sw_ddr_en)
+ cmdq_sw_ddr_enable(cmdq, true);
+
return 0;
}
@@ -337,6 +356,9 @@ static int cmdq_remove(struct platform_device *pdev)
{
struct cmdq *cmdq = platform_get_drvdata(pdev);
+ if (cmdq->sw_ddr_en)
+ cmdq_sw_ddr_enable(cmdq, false);
+
clk_bulk_unprepare(cmdq->gce_num, cmdq->clocks);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v9, 3/4] mailbox: mtk-cmdq: add gce ddr enable support flow
2022-10-06 4:34 ` [PATCH v9, 3/4] mailbox: mtk-cmdq: add gce ddr enable support flow Yongqiang Niu
@ 2022-10-06 9:30 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-10-06 9:30 UTC (permalink / raw)
To: Yongqiang Niu, CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang
Il 06/10/22 06:34, Yongqiang Niu ha scritto:
> add gce ddr enable control flow when gce suspend/resume
>
> when all cmdq instruction task has been processed done,
> we need set this gce ddr enable to disable status to tell
> cmdq hardware gce there is none task need process, and the hardware
> can go into idle mode and no access ddr anymore, then the spm can go
> into suspend.
>
> the original issue is gce still access ddr when cmdq suspend function
> call, but there is no task run.
> so, we need control gce access ddr with this flow.
> when cmdq suspend function, there is no task need process, we can
> disable gce access ddr, to make sure system go into suspend success.
>
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
I already gave you my Reviewed-by tag for this patch and here nothing has
changed from v8 to v9. Please retain tags that were given to you in these cases.
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v9, 4/4] mailbox: mtk-cmdq: add MT8186 support
2022-10-06 4:34 [PATCH v9, 0/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
` (2 preceding siblings ...)
2022-10-06 4:34 ` [PATCH v9, 3/4] mailbox: mtk-cmdq: add gce ddr enable support flow Yongqiang Niu
@ 2022-10-06 4:34 ` Yongqiang Niu
2022-10-06 9:31 ` AngeloGioacchino Del Regno
3 siblings, 1 reply; 10+ messages in thread
From: Yongqiang Niu @ 2022-10-06 4:34 UTC (permalink / raw)
To: CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang, Yongqiang Niu
add MT8186 cmdq support
Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 2db82ff838ed..98eed8d22688 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -691,9 +691,18 @@ static const struct gce_plat gce_plat_v6 = {
.gce_num = 2
};
+static const struct gce_plat gce_plat_v7 = {
+ .thread_nr = 24,
+ .shift = 3,
+ .control_by_sw = true,
+ .sw_ddr_en = true,
+ .gce_num = 1
+};
+
static const struct of_device_id cmdq_of_ids[] = {
{.compatible = "mediatek,mt8173-gce", .data = (void *)&gce_plat_v2},
{.compatible = "mediatek,mt8183-gce", .data = (void *)&gce_plat_v3},
+ {.compatible = "mediatek,mt8186-gce", .data = (void *)&gce_plat_v7},
{.compatible = "mediatek,mt6779-gce", .data = (void *)&gce_plat_v4},
{.compatible = "mediatek,mt8192-gce", .data = (void *)&gce_plat_v5},
{.compatible = "mediatek,mt8195-gce", .data = (void *)&gce_plat_v6},
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v9, 4/4] mailbox: mtk-cmdq: add MT8186 support
2022-10-06 4:34 ` [PATCH v9, 4/4] mailbox: mtk-cmdq: add MT8186 support Yongqiang Niu
@ 2022-10-06 9:31 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-10-06 9:31 UTC (permalink / raw)
To: Yongqiang Niu, CK Hu, Chun-Kuang Hu
Cc: Jassi Brar, Matthias Brugger, linux-kernel, linux-arm-kernel,
linux-mediatek, Project_Global_Chrome_Upstream_Group,
Hsin-Yi Wang
Il 06/10/22 06:34, Yongqiang Niu ha scritto:
> add MT8186 cmdq support
>
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 10+ messages in thread