2023-07-10 05:38:08

by Pankaj Gupta

[permalink] [raw]
Subject: [PATCH] caam: init-clk based on caam-page0-access

CAAM clock initialization to be done based on, soc specific
info stored in struct caam_imx_data:
- caam-page0-access flag
- num_clks

Signed-off-by: Pankaj Gupta <[email protected]>
---
drivers/crypto/caam/ctrl.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index ff9ddbbca377..74d0b7541d54 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -511,6 +511,7 @@ static const struct of_device_id caam_match[] = {
MODULE_DEVICE_TABLE(of, caam_match);

struct caam_imx_data {
+ bool page0_access;
const struct clk_bulk_data *clks;
int num_clks;
};
@@ -523,6 +524,7 @@ static const struct clk_bulk_data caam_imx6_clks[] = {
};

static const struct caam_imx_data caam_imx6_data = {
+ .page0_access = true,
.clks = caam_imx6_clks,
.num_clks = ARRAY_SIZE(caam_imx6_clks),
};
@@ -533,6 +535,7 @@ static const struct clk_bulk_data caam_imx7_clks[] = {
};

static const struct caam_imx_data caam_imx7_data = {
+ .page0_access = true,
.clks = caam_imx7_clks,
.num_clks = ARRAY_SIZE(caam_imx7_clks),
};
@@ -544,6 +547,7 @@ static const struct clk_bulk_data caam_imx6ul_clks[] = {
};

static const struct caam_imx_data caam_imx6ul_data = {
+ .page0_access = true,
.clks = caam_imx6ul_clks,
.num_clks = ARRAY_SIZE(caam_imx6ul_clks),
};
@@ -553,15 +557,23 @@ static const struct clk_bulk_data caam_vf610_clks[] = {
};

static const struct caam_imx_data caam_vf610_data = {
+ .page0_access = true,
.clks = caam_vf610_clks,
.num_clks = ARRAY_SIZE(caam_vf610_clks),
};

+static const struct caam_imx_data caam_imx8ulp_data = {
+ .page0_access = false,
+ .clks = NULL,
+ .num_clks = 0,
+};
+
static const struct soc_device_attribute caam_imx_soc_table[] = {
{ .soc_id = "i.MX6UL", .data = &caam_imx6ul_data },
{ .soc_id = "i.MX6*", .data = &caam_imx6_data },
{ .soc_id = "i.MX7*", .data = &caam_imx7_data },
{ .soc_id = "i.MX8M*", .data = &caam_imx7_data },
+ { .soc_id = "i.MX8ULP", .data = &caam_imx8ulp_data },
{ .soc_id = "VF*", .data = &caam_vf610_data },
{ .family = "Freescale i.MX" },
{ /* sentinel */ }
@@ -756,6 +768,7 @@ static int caam_probe(struct platform_device *pdev)
int pg_size;
int BLOCK_OFFSET = 0;
bool reg_access = true;
+ const struct caam_imx_data *imx_soc_data;

ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL);
if (!ctrlpriv)
@@ -772,6 +785,15 @@ static int caam_probe(struct platform_device *pdev)
caam_imx = (bool)imx_soc_match;

if (imx_soc_match) {
+ if (imx_soc_match->data) {
+ imx_soc_data = imx_soc_match->data;
+ reg_access = imx_soc_data->page0_access;
+ /*
+ * CAAM clocks cannot be controlled from kernel.
+ */
+ if (!imx_soc_data->num_clks)
+ goto iomap_ctrl;
+ }
/*
* Until Layerscape and i.MX OP-TEE get in sync,
* only i.MX OP-TEE use cases disallow access to
@@ -781,7 +803,7 @@ static int caam_probe(struct platform_device *pdev)
ctrlpriv->optee_en = !!np;
of_node_put(np);

- reg_access = !ctrlpriv->optee_en;
+ reg_access = reg_access && !ctrlpriv->optee_en;

if (!imx_soc_match->data) {
dev_err(dev, "No clock data provided for i.MX SoC");
@@ -793,7 +815,7 @@ static int caam_probe(struct platform_device *pdev)
return ret;
}

-
+iomap_ctrl:
/* Get configuration properties from device tree */
/* First, get register page */
ctrl = devm_of_iomap(dev, nprop, 0, NULL);
--
2.34.1



2023-07-17 17:21:17

by Horia Geanta

[permalink] [raw]
Subject: Re: [PATCH] caam: init-clk based on caam-page0-access

On 7/10/2023 8:34 AM, Pankaj Gupta wrote:
> CAAM clock initialization to be done based on, soc specific
> info stored in struct caam_imx_data:
> - caam-page0-access flag
> - num_clks
>
Any specific reason for deviating from downstream implementation
(based on DT)?
https://github.com/nxp-imx/linux-imx/blob/lf-6.1.1-1.0.1/drivers/crypto/caam/ctrl.c#L911

Thanks,
Horia


2023-07-27 08:00:46

by Pankaj Gupta

[permalink] [raw]
Subject: RE: [PATCH] caam: init-clk based on caam-page0-access



> -----Original Message-----
> From: Horia Geanta <[email protected]>
> Sent: Monday, July 17, 2023 10:39 PM
> To: Pankaj Gupta <[email protected]>; Gaurav Jain
> <[email protected]>; Varun Sethi <[email protected]>; Herbert Xu
> <[email protected]>; David S . Miller <[email protected]>;
> Iuliana Prodan <[email protected]>
> Cc: [email protected]; [email protected]; dl-linux-imx
> <[email protected]>
> Subject: Re: [PATCH] caam: init-clk based on caam-page0-access
>
> On 7/10/2023 8:34 AM, Pankaj Gupta wrote:
> > CAAM clock initialization to be done based on, soc specific info
> > stored in struct caam_imx_data:
> > - caam-page0-access flag
> > - num_clks
> >
> Any specific reason for deviating from downstream implementation (based on
> DT)?

Implementing based on DT will lead to multiple DT entries in the same code section:
- one entry for imx8ulp(fsl,imx8ulp-ele)
- then for imx8dxl(fsl,imx-scu)
- then for imx93 (fsl,imx93-ele)
- Similar entries for future SoC as well.

Hence, followed this approach.

> https://github.com/nxp-imx/linux-imx/blob/lf-6.1.1-
> 1.0.1/drivers/crypto/caam/ctrl.c#L911
>
> Thanks,
> Horia

2024-04-09 07:01:02

by Pankaj Gupta

[permalink] [raw]
Subject: RE: [PATCH] caam: init-clk based on caam-page0-access

Hi Horia/Gaurav,

Are there any further comments? Please share.

Regards
Pankaj
> -----Original Message-----
> From: Pankaj Gupta
> Sent: Thursday, July 27, 2023 1:14 PM
> To: Horia Geanta <[email protected]>; Gaurav Jain
> <[email protected]>; Varun Sethi <[email protected]>; Herbert Xu
> <[email protected]>; David S . Miller <[email protected]>;
> Iuliana Prodan <[email protected]>
> Cc: [email protected]; [email protected]; dl-linux-imx
> <[email protected]>
> Subject: RE: [PATCH] caam: init-clk based on caam-page0-access
>
>
>
> > -----Original Message-----
> > From: Horia Geanta <[email protected]>
> > Sent: Monday, July 17, 2023 10:39 PM
> > To: Pankaj Gupta <[email protected]>; Gaurav Jain
> > <[email protected]>; Varun Sethi <[email protected]>; Herbert Xu
> > <[email protected]>; David S . Miller <[email protected]>;
> > Iuliana Prodan <[email protected]>
> > Cc: [email protected]; [email protected];
> > dl-linux-imx <[email protected]>
> > Subject: Re: [PATCH] caam: init-clk based on caam-page0-access
> >
> > On 7/10/2023 8:34 AM, Pankaj Gupta wrote:
> > > CAAM clock initialization to be done based on, soc specific info
> > > stored in struct caam_imx_data:
> > > - caam-page0-access flag
> > > - num_clks
> > >
> > Any specific reason for deviating from downstream implementation
> > (based on DT)?
>
> Implementing based on DT will lead to multiple DT entries in the same code
> section:
> - one entry for imx8ulp(fsl,imx8ulp-ele)
> - then for imx8dxl(fsl,imx-scu)
> - then for imx93 (fsl,imx93-ele)
> - Similar entries for future SoC as well.
>
> Hence, followed this approach.
>
> > https://github.com/nxp-imx/linux-imx/blob/lf-6.1.1-
> > 1.0.1/drivers/crypto/caam/ctrl.c#L911
> >
> > Thanks,
> > Horia

2024-04-09 07:26:04

by Francesco Dolcini

[permalink] [raw]
Subject: Re: [PATCH] caam: init-clk based on caam-page0-access

Hello,

On Mon, Jul 10, 2023 at 11:04:18AM +0530, Pankaj Gupta wrote:
> CAAM clock initialization to be done based on, soc specific
> info stored in struct caam_imx_data:
> - caam-page0-access flag
> - num_clks
>
> Signed-off-by: Pankaj Gupta <[email protected]>
> ---
> drivers/crypto/caam/ctrl.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
> index ff9ddbbca377..74d0b7541d54 100644
> --- a/drivers/crypto/caam/ctrl.c
> +++ b/drivers/crypto/caam/ctrl.c

[...]

> static const struct soc_device_attribute caam_imx_soc_table[] = {
> { .soc_id = "i.MX6UL", .data = &caam_imx6ul_data },
> { .soc_id = "i.MX6*", .data = &caam_imx6_data },
> { .soc_id = "i.MX7*", .data = &caam_imx7_data },
> { .soc_id = "i.MX8M*", .data = &caam_imx7_data },
> + { .soc_id = "i.MX8ULP", .data = &caam_imx8ulp_data },

This change seems unrelated to the change described in the commit message.
Should it be a separate patch?

Francesco


2024-04-10 07:05:54

by Pankaj Gupta

[permalink] [raw]
Subject: RE: [PATCH] caam: init-clk based on caam-page0-access



> -----Original Message-----
> From: Gaurav Jain <[email protected]>
> Sent: Wednesday, April 10, 2024 12:29 PM
> To: Pankaj Gupta <[email protected]>; Horia Geanta
> <[email protected]>; Varun Sethi <[email protected]>; 'Herbert Xu'
> <[email protected]>; 'David S . Miller' <[email protected]>;
> Iuliana Prodan <[email protected]>
> Cc: '[email protected]' <[email protected]>; 'linux-
> [email protected]' <[email protected]>; dl-linux-imx <linux-
> [email protected]>
> Subject: RE: [PATCH] caam: init-clk based on caam-page0-access
>
> Hi Pankaj
>
> Please check the below comments.
>
> Regards
> Gaurav Jain
>
> > -----Original Message-----
> > From: Pankaj Gupta <[email protected]>
> > Sent: Monday, July 10, 2023 11:03 AM
> > To: Horia Geanta <[email protected]>; Gaurav Jain
> > <[email protected]>
> > Cc: Pankaj Gupta <[email protected]>
> > Subject: [PATCH] caam: init-clk based on caam-page0-access
> >
> > CAAM clock initialization to be done based on, soc specific info
> > stored in struct
> > caam_imx_data:
> > - caam-page0-access flag
> > - num_clks
> >
> > Signed-off-by: Pankaj Gupta <[email protected]>
> > ---
> > drivers/crypto/caam/ctrl.c | 26 ++++++++++++++++++++++++--
> > 1 file changed, 24 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
> > index
> > ff9ddbbca377..74d0b7541d54 100644
> > --- a/drivers/crypto/caam/ctrl.c
> > +++ b/drivers/crypto/caam/ctrl.c
> > @@ -511,6 +511,7 @@ static const struct of_device_id caam_match[] = {
> > MODULE_DEVICE_TABLE(of, caam_match);
> >
> > struct caam_imx_data {
> > + bool page0_access;
> > const struct clk_bulk_data *clks;
> > int num_clks;
> > };
> > @@ -523,6 +524,7 @@ static const struct clk_bulk_data caam_imx6_clks[]
> > = { };
> >
> > static const struct caam_imx_data caam_imx6_data = {
> > + .page0_access = true,
> > .clks = caam_imx6_clks,
> > .num_clks = ARRAY_SIZE(caam_imx6_clks), }; @@ -533,6 +535,7 @@
> > static const struct clk_bulk_data caam_imx7_clks[] = { };
> >
> > static const struct caam_imx_data caam_imx7_data = {
> > + .page0_access = true,
> > .clks = caam_imx7_clks,
> > .num_clks = ARRAY_SIZE(caam_imx7_clks), }; @@ -544,6 +547,7 @@
> > static const struct clk_bulk_data caam_imx6ul_clks[] = { };
> >
> > static const struct caam_imx_data caam_imx6ul_data = {
> > + .page0_access = true,
> > .clks = caam_imx6ul_clks,
> > .num_clks = ARRAY_SIZE(caam_imx6ul_clks), }; @@ -553,15 +557,23
> @@
> > static const struct clk_bulk_data caam_vf610_clks[] = { };
> >
> > static const struct caam_imx_data caam_vf610_data = {
> > + .page0_access = true,
> > .clks = caam_vf610_clks,
> > .num_clks = ARRAY_SIZE(caam_vf610_clks), };
> >
> > +static const struct caam_imx_data caam_imx8ulp_data = {
> > + .page0_access = false,
> > + .clks = NULL,
> > + .num_clks = 0,
> > +};
> > +
> > static const struct soc_device_attribute caam_imx_soc_table[] = {
> > { .soc_id = "i.MX6UL", .data = &caam_imx6ul_data },
> > { .soc_id = "i.MX6*", .data = &caam_imx6_data },
> > { .soc_id = "i.MX7*", .data = &caam_imx7_data },
> > { .soc_id = "i.MX8M*", .data = &caam_imx7_data },
> > + { .soc_id = "i.MX8ULP", .data = &caam_imx8ulp_data },
> > { .soc_id = "VF*", .data = &caam_vf610_data },
> > { .family = "Freescale i.MX" },
> > { /* sentinel */ }
> > @@ -756,6 +768,7 @@ static int caam_probe(struct platform_device *pdev)
> > int pg_size;
> > int BLOCK_OFFSET = 0;
> > bool reg_access = true;
> > + const struct caam_imx_data *imx_soc_data;
> >
> > ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL);
> > if (!ctrlpriv)
> > @@ -772,6 +785,15 @@ static int caam_probe(struct platform_device
> *pdev)
> > caam_imx = (bool)imx_soc_match;
> >
> > if (imx_soc_match) {
> > + if (imx_soc_match->data) {
> > + imx_soc_data = imx_soc_match->data;
> > + reg_access = imx_soc_data->page0_access;
> > + /*
> > + * CAAM clocks cannot be controlled from kernel.
> > + */
> > + if (!imx_soc_data->num_clks)
> > + goto iomap_ctrl;
>
> OPTEE enablement check is ignored because of this goto statement.
> Regards
> Gaurav Jain

[Accepted] Will be corrected in V2.
>
> > + }
> > /*
> > * Until Layerscape and i.MX OP-TEE get in sync,
> > * only i.MX OP-TEE use cases disallow access to @@ -781,7
> > +803,7 @@ static int caam_probe(struct platform_device *pdev)
> > ctrlpriv->optee_en = !!np;
> > of_node_put(np);
> >
> > - reg_access = !ctrlpriv->optee_en;
> > + reg_access = reg_access && !ctrlpriv->optee_en;
> >
> > if (!imx_soc_match->data) {
> > dev_err(dev, "No clock data provided for i.MX SoC");
> @@ -793,7
> > +815,7 @@ static int caam_probe(struct platform_device *pdev)
> > return ret;
> > }
> >
> > -
> > +iomap_ctrl:
> > /* Get configuration properties from device tree */
> > /* First, get register page */
> > ctrl = devm_of_iomap(dev, nprop, 0, NULL);
> > --
> > 2.34.1