From: "Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>
To: "fshao@chromium.org" <fshao@chromium.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"Johnson Wang (王聖鑫)" <Johnson.Wang@mediatek.com>,
"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
"Jason-ch Chen (陳建豪)" <Jason-ch.Chen@mediatek.com>,
"Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.com>,
"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
"jkardatzke@google.com" <jkardatzke@google.com>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
Project_Global_Chrome_Upstream_Group
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"krzysztof.kozlowski+dt@linaro.org"
<krzysztof.kozlowski+dt@linaro.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"jassisinghbrar@gmail.com" <jassisinghbrar@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH v2 7/9] mailbox: mediatek: Add secure CMDQ driver support for CMDQ driver
Date: Wed, 25 Oct 2023 02:08:46 +0000 [thread overview]
Message-ID: <8accca79ebcde0b78a9e3026155543e67df3ed7a.camel@mediatek.com> (raw)
In-Reply-To: <CAC=S1niRYwftnmi8VABzENf2g94ELEBZrB3NRRdvwn0Ro6tO1A@mail.gmail.com>
Hi Fei,
Thanks for the reviews.
On Mon, 2023-10-23 at 18:47 +0800, Fei Shao wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> Hi Jason,
>
> On Mon, Oct 23, 2023 at 12:39 PM Jason-JH.Lin <
> jason-jh.lin@mediatek.com> wrote:
> >
> > CMDQ driver will probe a secure CMDQ driver when has_sec flag
> > in platform data is true and its device node in dts has defined a
> > event id of CMDQ_SYNC_TOKEN_SEC_EOF.
> >
> > Secure CMDQ driver support on mt8188 and mt8195 currently.
> > So add a has_sec flag to their driver data to probe it.
> >
> > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > ---
> > drivers/mailbox/mtk-cmdq-mailbox.c | 42
> ++++++++++++++++++++++--
> > include/linux/mailbox/mtk-cmdq-mailbox.h | 11 +++++++
> > 2 files changed, 51 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c
> b/drivers/mailbox/mtk-cmdq-mailbox.c
> > index 3bdfb9a60614..4db5eb76f353 100644
> > --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> > +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> > @@ -87,6 +87,7 @@ struct gce_plat {
> > u8 shift;
> > bool control_by_sw;
> > bool sw_ddr_en;
> > + bool has_sec;
> > u32 gce_num;
> > };
> >
> > @@ -560,14 +561,23 @@ static int cmdq_probe(struct platform_device
> *pdev)
> > int alias_id = 0;
> > static const char * const clk_name = "gce";
> > static const char * const clk_names[] = { "gce0", "gce1" };
> > + struct resource *res;
> > + struct platform_device *mtk_cmdq_sec;
> > + u32 hwid = 0;
> >
> > cmdq = devm_kzalloc(dev, sizeof(*cmdq), GFP_KERNEL);
> > if (!cmdq)
> > return -ENOMEM;
> >
> > - cmdq->base = devm_platform_ioremap_resource(pdev, 0);
> > - if (IS_ERR(cmdq->base))
> > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> The devm_platform_ioremap_resource() helper was added on purpose [1].
> Please stick to it unless you have a strong reason to re-split it.
>
> [1]: a04f30356e75 ("mailbox: mtk-cmdq: Make use of the helper
> function
> devm_platform_ioremap_resource()")
>
OK, because want to get the pa of GCE by resource like this:
gce_sec_plat.base_pa = res->start;
I'll find another way to do that.
> > + if (!res)
> > + return -EINVAL;
> > +
> > + cmdq->base = devm_ioremap_resource(dev, res);
> > + if (IS_ERR(cmdq->base)) {
> > + dev_err(dev, "failed to ioremap cmdq\n");
> > return PTR_ERR(cmdq->base);
> > + }
> >
> > cmdq->irq = platform_get_irq(pdev, 0);
> > if (cmdq->irq < 0)
> > @@ -585,6 +595,8 @@ static int cmdq_probe(struct platform_device
> *pdev)
> > dev, cmdq->base, cmdq->irq);
> >
> > if (cmdq->pdata->gce_num > 1) {
> > + hwid = of_alias_get_id(dev->of_node, clk_name);
> Why get hwid here while it's only used in the has_sec branch?
Because I want to pass the hwid to secure world and let it know what
GCE pa should use in TEE rather than passing GCE pa.
>
> > +
> > for_each_child_of_node(phandle->parent, node) {
> > alias_id = of_alias_get_id(node, clk_name);
> > if (alias_id >= 0 && alias_id < cmdq-
> >pdata->gce_num) {
> > @@ -653,6 +665,30 @@ static int cmdq_probe(struct platform_device
> *pdev)
> > return err;
> > }
> >
> > + if (cmdq->pdata->has_sec) {
> > + struct cmdq_sec_plat gce_sec_plat;
> > +
> > + if (of_property_read_u32_index(dev->of_node,
> "mediatek,gce-events", 0,
> >
> + &gce_sec_plat.cmdq_eve
> nt) == 0) {
> > + gce_sec_plat.gce_dev = dev;
> > + gce_sec_plat.base = cmdq->base;
> > + gce_sec_plat.base_pa = res->start;
> > + gce_sec_plat.hwid = hwid;
> > + gce_sec_plat.gce_num = cmdq->pdata-
> >gce_num;
> > + gce_sec_plat.clocks = cmdq->clocks;
> > + gce_sec_plat.thread_nr = cmdq->pdata-
> >thread_nr;
> > +
> > + mtk_cmdq_sec =
> platform_device_register_data(dev, "mtk_cmdq_sec",
> >
> +
> PLATFORM_DEVID_AUTO,
> >
> +
> &gce_sec_plat,
> >
> +
> sizeof(gce_sec_plat));
> > + if (IS_ERR(mtk_cmdq_sec)) {
> > + dev_err(dev, "failed to register
> platform_device mtk_cmdq_sec\n");
> > + return PTR_ERR(mtk_cmdq_sec);
> > + }
> > + }
> > + }
> > +
> > return 0;
> > }
> >
> > @@ -693,6 +729,7 @@ static const struct gce_plat gce_plat_v6 = {
> > .thread_nr = 24,
> > .shift = 3,
> > .control_by_sw = true,
> > + .has_sec = true,
> > .gce_num = 2
> > };
> >
> > @@ -708,6 +745,7 @@ static const struct gce_plat gce_plat_v8 = {
> > .thread_nr = 32,
> > .shift = 3,
> > .control_by_sw = true,
> > + .has_sec = true,
> > .gce_num = 2
> > };
> >
> > diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h
> b/include/linux/mailbox/mtk-cmdq-mailbox.h
> > index f78a08e7c6ed..fdda995a69ce 100644
> > --- a/include/linux/mailbox/mtk-cmdq-mailbox.h
> > +++ b/include/linux/mailbox/mtk-cmdq-mailbox.h
> > @@ -79,6 +79,17 @@ struct cmdq_pkt {
> > bool loop;
> > };
> >
> > +struct cmdq_sec_plat {
> > + struct device *gce_dev;
> > + void __iomem *base;
> > + dma_addr_t base_pa;
> > + u32 hwid;
> > + u32 gce_num;
> > + struct clk_bulk_data *clocks;
> > + u32 thread_nr;
> > + u32 cmdq_event;
> > +};
> I feel this should be in mtk-cmdq-sec-mailbox.h.
>
That means we have to include <mtk-cmdq-sec-mailbox.h> in this file,
but actually mtk-cmdq-sec-mailbox.h have to include <mtk-cmdq-
mailbox.h>. So I add this here finally.
But I agree with you, I'll try to move this struct into mtk-cmdq-sec-
mailbox.h and include <mtk-cmdq-sec-mailbox.h> in mtk-cmdq-mailbox.c.
Regards,
Jason-JH.Lin
> Regards,
> Fei
>
>
>
> > +
> > u8 cmdq_get_shift_pa(struct mbox_chan *chan);
> >
> > #endif /* __MTK_CMDQ_MAILBOX_H__ */
> > --
> > 2.18.0
> >
> >
>
next prev parent reply other threads:[~2023-10-25 2:29 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-23 4:37 [PATCH v2 0/9] Add CMDQ secure driver for SVP Jason-JH.Lin
2023-10-23 4:37 ` [PATCH v2 1/9] dt-bindings: gce: mt8195: Add CMDQ_SYNC_TOKEN_SECURE_THR_EOF event id Jason-JH.Lin
2023-10-23 7:47 ` Krzysztof Kozlowski
2023-10-23 7:49 ` Krzysztof Kozlowski
2023-10-24 16:21 ` Jason-JH Lin (林睿祥)
2023-10-25 6:26 ` Jason-JH Lin (林睿祥)
2023-10-25 7:03 ` Krzysztof Kozlowski
2023-10-25 7:36 ` Jason-JH Lin (林睿祥)
2023-10-23 8:08 ` Krzysztof Kozlowski
2023-10-25 6:28 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 2/9] dt-bindings: mailbox: Add property for CMDQ secure driver Jason-JH.Lin
2023-10-23 7:49 ` Krzysztof Kozlowski
2023-10-24 16:37 ` Jason-JH Lin (林睿祥)
2023-10-28 9:10 ` Krzysztof Kozlowski
2023-10-31 2:34 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 3/9] soc: mailbox: Add cmdq_pkt_logic_command to support math operation Jason-JH.Lin
2023-10-23 8:26 ` Fei Shao
2023-10-23 9:14 ` Fei Shao
2023-10-24 16:59 ` Jason-JH Lin (林睿祥)
2023-10-23 9:50 ` AngeloGioacchino Del Regno
2023-10-24 17:11 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 4/9] soc: mailbox: Add cmdq_pkt_write_s_reg_value to support write value to reg Jason-JH.Lin
2023-10-23 9:50 ` AngeloGioacchino Del Regno
2023-10-25 0:45 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 5/9] soc: mailbox: Add cmdq_pkt_finalize_loop to support looping cmd with irq Jason-JH.Lin
2023-10-23 9:50 ` AngeloGioacchino Del Regno
2023-10-25 0:55 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 6/9] mailbox: mediatek: Add CMDQ driver support for mt8188 Jason-JH.Lin
2023-10-23 9:41 ` Fei Shao
2023-10-25 6:33 ` Jason-JH Lin (林睿祥)
2023-10-23 9:50 ` AngeloGioacchino Del Regno
2023-10-23 10:14 ` AngeloGioacchino Del Regno
2023-10-25 0:58 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 7/9] mailbox: mediatek: Add secure CMDQ driver support for CMDQ driver Jason-JH.Lin
2023-10-23 10:47 ` Fei Shao
2023-10-25 2:08 ` Jason-JH Lin (林睿祥) [this message]
2023-10-23 4:37 ` [PATCH v2 8/9] mailbox: mediatek: Add CMDQ secure mailbox driver Jason-JH.Lin
2023-10-23 10:48 ` AngeloGioacchino Del Regno
2023-10-25 6:20 ` Jason-JH Lin (林睿祥)
2023-11-06 6:53 ` CK Hu (胡俊光)
2023-11-06 13:07 ` Jason-JH Lin (林睿祥)
2023-10-23 4:37 ` [PATCH v2 9/9] arm64: dts: mediatek: mt8195: Add CMDQ secure driver support for gce0 Jason-JH.Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8accca79ebcde0b78a9e3026155543e67df3ed7a.camel@mediatek.com \
--to=jason-jh.lin@mediatek.com \
--cc=Jason-ch.Chen@mediatek.com \
--cc=Johnson.Wang@mediatek.com \
--cc=Nancy.Lin@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=Shawn.Sung@mediatek.com \
--cc=Singo.Chang@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=conor+dt@kernel.org \
--cc=fshao@chromium.org \
--cc=jassisinghbrar@gmail.com \
--cc=jkardatzke@google.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox