mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] caam: init-clk based on caam-page0-access
@ 2024-04-29  6:28 Pankaj Gupta
  2024-04-29  6:28 ` Pankaj Gupta
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Pankaj Gupta @ 2024-04-29  6:28 UTC (permalink / raw)
  To: gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx
  Cc: Pankaj Gupta

v4:
 - Correct the null pointer checking

v3:
 - Splitting the patch into two.
 - Disposed-off comments received on v2.

v2:
 - Considering the OPTEE enablement check too, for setting the
   variable 'reg_access'.

Pankaj Gupta (2):
  caam: init-clk based on caam-page0-access
  drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access

 drivers/crypto/caam/ctrl.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

-- 
2.34.1


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

* [PATCH v4 0/2] caam: init-clk based on caam-page0-access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
@ 2024-04-29  6:28 ` Pankaj Gupta
  2024-04-29  6:28 ` [PATCH v4 1/2] " Pankaj Gupta
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Pankaj Gupta @ 2024-04-29  6:28 UTC (permalink / raw)
  To: gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx
  Cc: Pankaj Gupta

v4:
 - Correct the null pointer checking

v3:
 - Splitting the patch into two.
 - Disposed-off comments received on v2.

v2:
 - Considering the OPTEE enablement check too, for setting the
   variable 'reg_access'.

Pankaj Gupta (2):
  caam: init-clk based on caam-page0-access
  drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access

 drivers/crypto/caam/ctrl.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

-- 
2.34.1


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

* [PATCH v4 1/2] caam: init-clk based on caam-page0-access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
  2024-04-29  6:28 ` Pankaj Gupta
@ 2024-04-29  6:28 ` Pankaj Gupta
  2024-04-29  6:28 ` Pankaj Gupta
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Pankaj Gupta @ 2024-04-29  6:28 UTC (permalink / raw)
  To: gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx
  Cc: Pankaj Gupta

CAAM clock initializat is done based on the basis of soc specific
info stored in struct caam_imx_data:
- caam-page0-access flag
- num_clks

CAAM driver needs to be aware of access rights to CAAM control page
i.e., page0, to do things differently.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
---
 drivers/crypto/caam/ctrl.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index bdf367f3f679..02363c467cf3 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -512,6 +512,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;
 };
@@ -524,6 +525,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),
 };
@@ -534,6 +536,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),
 };
@@ -545,6 +548,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),
 };
@@ -554,6 +558,7 @@ 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),
 };
@@ -860,6 +865,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)
@@ -894,12 +900,20 @@ static int caam_probe(struct platform_device *pdev)
 			return -EINVAL;
 		}
 
+		imx_soc_data = imx_soc_match->data;
+		reg_access = reg_access && imx_soc_data->page0_access;
+		/*
+		 * CAAM clocks cannot be controlled from kernel.
+		 */
+		if (!imx_soc_data->num_clks)
+			goto iomap_ctrl;
+
 		ret = init_clocks(dev, imx_soc_match->data);
 		if (ret)
 			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


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

* [PATCH v4 1/2] caam: init-clk based on caam-page0-access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
  2024-04-29  6:28 ` Pankaj Gupta
  2024-04-29  6:28 ` [PATCH v4 1/2] " Pankaj Gupta
@ 2024-04-29  6:28 ` Pankaj Gupta
  2024-04-29  6:28 ` [PATCH v4 2/2] drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access Pankaj Gupta
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Pankaj Gupta @ 2024-04-29  6:28 UTC (permalink / raw)
  To: gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx
  Cc: Pankaj Gupta

CAAM clock initializat is done based on the basis of soc specific
info stored in struct caam_imx_data:
- caam-page0-access flag
- num_clks

CAAM driver needs to be aware of access rights to CAAM control page
i.e., page0, to do things differently.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
---
 drivers/crypto/caam/ctrl.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index bdf367f3f679..02363c467cf3 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -512,6 +512,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;
 };
@@ -524,6 +525,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),
 };
@@ -534,6 +536,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),
 };
@@ -545,6 +548,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),
 };
@@ -554,6 +558,7 @@ 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),
 };
@@ -860,6 +865,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)
@@ -894,12 +900,20 @@ static int caam_probe(struct platform_device *pdev)
 			return -EINVAL;
 		}
 
+		imx_soc_data = imx_soc_match->data;
+		reg_access = reg_access && imx_soc_data->page0_access;
+		/*
+		 * CAAM clocks cannot be controlled from kernel.
+		 */
+		if (!imx_soc_data->num_clks)
+			goto iomap_ctrl;
+
 		ret = init_clocks(dev, imx_soc_match->data);
 		if (ret)
 			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


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

* [PATCH v4 2/2] drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
                   ` (2 preceding siblings ...)
  2024-04-29  6:28 ` Pankaj Gupta
@ 2024-04-29  6:28 ` Pankaj Gupta
  2024-04-29  6:28 ` Pankaj Gupta
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Pankaj Gupta @ 2024-04-29  6:28 UTC (permalink / raw)
  To: gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx
  Cc: Pankaj Gupta

iMX8ULP have a secure-enclave hardware IP called EdgeLock Enclave(ELE),
that control access to caam controller's register page, i.e., page0.

At all, if the ELE release access to CAAM controller's register page,
it will release to secure-world only.

Clocks are turned on automatically for iMX8ULP. There exists the caam
clock gating bit, but it is not advised to gate the clock at linux, as
optee-os or any other entity might be using it.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Reviewed-by: Horia Geanta <horia.geanta@nxp.com>
---
 drivers/crypto/caam/ctrl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 02363c467cf3..bd418dea586d 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -563,11 +563,14 @@ static const struct caam_imx_data caam_vf610_data = {
 	.num_clks = ARRAY_SIZE(caam_vf610_clks),
 };
 
+static const struct caam_imx_data caam_imx8ulp_data;
+
 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 */ }
-- 
2.34.1


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

* [PATCH v4 2/2] drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
                   ` (3 preceding siblings ...)
  2024-04-29  6:28 ` [PATCH v4 2/2] drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access Pankaj Gupta
@ 2024-04-29  6:28 ` Pankaj Gupta
  2024-04-29  7:19 ` [PATCH v4 0/2] caam: init-clk based on caam-page0-access Krzysztof Kozlowski
  2024-05-10  9:18 ` Herbert Xu
  6 siblings, 0 replies; 8+ messages in thread
From: Pankaj Gupta @ 2024-04-29  6:28 UTC (permalink / raw)
  To: gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx
  Cc: Pankaj Gupta

iMX8ULP have a secure-enclave hardware IP called EdgeLock Enclave(ELE),
that control access to caam controller's register page, i.e., page0.

At all, if the ELE release access to CAAM controller's register page,
it will release to secure-world only.

Clocks are turned on automatically for iMX8ULP. There exists the caam
clock gating bit, but it is not advised to gate the clock at linux, as
optee-os or any other entity might be using it.

Signed-off-by: Pankaj Gupta <pankaj.gupta@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
Reviewed-by: Horia Geanta <horia.geanta@nxp.com>
---
 drivers/crypto/caam/ctrl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 02363c467cf3..bd418dea586d 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -563,11 +563,14 @@ static const struct caam_imx_data caam_vf610_data = {
 	.num_clks = ARRAY_SIZE(caam_vf610_clks),
 };
 
+static const struct caam_imx_data caam_imx8ulp_data;
+
 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 */ }
-- 
2.34.1


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

* Re: [PATCH v4 0/2] caam: init-clk based on caam-page0-access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
                   ` (4 preceding siblings ...)
  2024-04-29  6:28 ` Pankaj Gupta
@ 2024-04-29  7:19 ` Krzysztof Kozlowski
  2024-05-10  9:18 ` Herbert Xu
  6 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-29  7:19 UTC (permalink / raw)
  To: Pankaj Gupta, gaurav.jain, horia.geanta, V.Sethi, herbert, davem,
	iuliana.prodan, linux-crypto, linux-kernel, linux-imx

On 29/04/2024 08:28, Pankaj Gupta wrote:
> v4:
>  - Correct the null pointer checking
> 
> v3:
>  - Splitting the patch into two.
>  - Disposed-off comments received on v2.
> 
> v2:
>  - Considering the OPTEE enablement check too, for setting the
>    variable 'reg_access'.
> 
> Pankaj Gupta (2):
>   caam: init-clk based on caam-page0-access
>   drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access
> 

Two patches here, 5 patches in patchset, some with entirely different
patch prefixes.

Bring some order to this.

Best regards,
Krzysztof


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

* Re: [PATCH v4 0/2] caam: init-clk based on caam-page0-access
  2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
                   ` (5 preceding siblings ...)
  2024-04-29  7:19 ` [PATCH v4 0/2] caam: init-clk based on caam-page0-access Krzysztof Kozlowski
@ 2024-05-10  9:18 ` Herbert Xu
  6 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2024-05-10  9:18 UTC (permalink / raw)
  To: Pankaj Gupta
  Cc: gaurav.jain, horia.geanta, V.Sethi, davem, iuliana.prodan,
	linux-crypto, linux-kernel, linux-imx

On Mon, Apr 29, 2024 at 11:58:50AM +0530, Pankaj Gupta wrote:
> v4:
>  - Correct the null pointer checking
> 
> v3:
>  - Splitting the patch into two.
>  - Disposed-off comments received on v2.
> 
> v2:
>  - Considering the OPTEE enablement check too, for setting the
>    variable 'reg_access'.
> 
> Pankaj Gupta (2):
>   caam: init-clk based on caam-page0-access
>   drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access
> 
>  drivers/crypto/caam/ctrl.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> -- 
> 2.34.1

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2024-05-10  9:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-29  6:28 [PATCH v4 0/2] caam: init-clk based on caam-page0-access Pankaj Gupta
2024-04-29  6:28 ` Pankaj Gupta
2024-04-29  6:28 ` [PATCH v4 1/2] " Pankaj Gupta
2024-04-29  6:28 ` Pankaj Gupta
2024-04-29  6:28 ` [PATCH v4 2/2] drivers: crypto: caam: i.MX8ULP donot have CAAM page0 access Pankaj Gupta
2024-04-29  6:28 ` Pankaj Gupta
2024-04-29  7:19 ` [PATCH v4 0/2] caam: init-clk based on caam-page0-access Krzysztof Kozlowski
2024-05-10  9:18 ` Herbert Xu

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®