public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] crypto: qcom-rng: fix support for ACPI-based systems
@ 2024-08-29  1:20 Brian Masney
  2024-08-29  1:20 ` [PATCH 1/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Brian Masney @ 2024-08-29  1:20 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel

The qcom-rng driver supports both ACPI and device tree based systems.
ACPI support was broken when the hw_random interface support was added.
This small series gets that working again.

This fix was boot tested on a Qualcomm Amberwing server.

Brian Masney (2):
  crypto: qcom-rng: rename *_of_data to *_match_data
  crypto: qcom-rng: fix support for ACPI-based systems

 drivers/crypto/qcom-rng.c | 50 +++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

-- 
2.46.0


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

* [PATCH 1/2] crypto: qcom-rng: rename *_of_data to *_match_data
  2024-08-29  1:20 [PATCH 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
@ 2024-08-29  1:20 ` Brian Masney
  2024-08-29  1:20 ` [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
  2024-08-29  1:32 ` [PATCH 0/2] " Brian Masney
  2 siblings, 0 replies; 7+ messages in thread
From: Brian Masney @ 2024-08-29  1:20 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel

The qcom-rng driver supports both ACPI and device tree based systems.
Let's rename all instances of *_of_data to *_match_data in preparation
for fixing the ACPI support that was broken with commit
f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support").

Signed-off-by: Brian Masney <bmasney@redhat.com>
---
 drivers/crypto/qcom-rng.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index c670d7d0c11e..4ed545001b77 100644
--- a/drivers/crypto/qcom-rng.c
+++ b/drivers/crypto/qcom-rng.c
@@ -36,14 +36,14 @@ struct qcom_rng {
 	void __iomem *base;
 	struct clk *clk;
 	struct hwrng hwrng;
-	struct qcom_rng_of_data *of_data;
+	struct qcom_rng_match_data *match_data;
 };
 
 struct qcom_rng_ctx {
 	struct qcom_rng *rng;
 };
 
-struct qcom_rng_of_data {
+struct qcom_rng_match_data {
 	bool skip_init;
 	bool hwrng_support;
 };
@@ -155,7 +155,7 @@ static int qcom_rng_init(struct crypto_tfm *tfm)
 
 	ctx->rng = qcom_rng_dev;
 
-	if (!ctx->rng->of_data->skip_init)
+	if (!ctx->rng->match_data->skip_init)
 		return qcom_rng_enable(ctx->rng);
 
 	return 0;
@@ -196,7 +196,7 @@ static int qcom_rng_probe(struct platform_device *pdev)
 	if (IS_ERR(rng->clk))
 		return PTR_ERR(rng->clk);
 
-	rng->of_data = (struct qcom_rng_of_data *)of_device_get_match_data(&pdev->dev);
+	rng->match_data = (struct qcom_rng_match_data *)of_device_get_match_data(&pdev->dev);
 
 	qcom_rng_dev = rng;
 	ret = crypto_register_rng(&qcom_rng_alg);
@@ -206,7 +206,7 @@ static int qcom_rng_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	if (rng->of_data->hwrng_support) {
+	if (rng->match_data->hwrng_support) {
 		rng->hwrng.name = "qcom_hwrng";
 		rng->hwrng.read = qcom_hwrng_read;
 		rng->hwrng.quality = QCOM_TRNG_QUALITY;
@@ -231,17 +231,17 @@ static void qcom_rng_remove(struct platform_device *pdev)
 	qcom_rng_dev = NULL;
 }
 
-static struct qcom_rng_of_data qcom_prng_of_data = {
+static struct qcom_rng_match_data qcom_prng_match_data = {
 	.skip_init = false,
 	.hwrng_support = false,
 };
 
-static struct qcom_rng_of_data qcom_prng_ee_of_data = {
+static struct qcom_rng_match_data qcom_prng_ee_match_data = {
 	.skip_init = true,
 	.hwrng_support = false,
 };
 
-static struct qcom_rng_of_data qcom_trng_of_data = {
+static struct qcom_rng_match_data qcom_trng_match_data = {
 	.skip_init = true,
 	.hwrng_support = true,
 };
@@ -253,9 +253,9 @@ static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, qcom_rng_acpi_match);
 
 static const struct of_device_id __maybe_unused qcom_rng_of_match[] = {
-	{ .compatible = "qcom,prng", .data = &qcom_prng_of_data },
-	{ .compatible = "qcom,prng-ee", .data = &qcom_prng_ee_of_data },
-	{ .compatible = "qcom,trng", .data = &qcom_trng_of_data },
+	{ .compatible = "qcom,prng", .data = &qcom_prng_match_data },
+	{ .compatible = "qcom,prng-ee", .data = &qcom_prng_ee_match_data },
+	{ .compatible = "qcom,trng", .data = &qcom_trng_match_data },
 	{}
 };
 MODULE_DEVICE_TABLE(of, qcom_rng_of_match);
-- 
2.46.0


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

* [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-08-29  1:20 [PATCH 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
  2024-08-29  1:20 ` [PATCH 1/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
@ 2024-08-29  1:20 ` Brian Masney
  2024-08-29 10:18   ` Dmitry Baryshkov
  2024-08-29 15:58   ` Ernesto A. Fernández
  2024-08-29  1:32 ` [PATCH 0/2] " Brian Masney
  2 siblings, 2 replies; 7+ messages in thread
From: Brian Masney @ 2024-08-29  1:20 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel

The qcom-rng driver supports both ACPI and device tree based systems.
ACPI support was broken when the hw_random interface support was added.
Let's go ahead and fix this by checking has_acpi_companion().

This fix was boot tested on a Qualcomm Amberwing server.

Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
 drivers/crypto/qcom-rng.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index 4ed545001b77..470062cb258c 100644
--- a/drivers/crypto/qcom-rng.c
+++ b/drivers/crypto/qcom-rng.c
@@ -176,6 +176,21 @@ static struct rng_alg qcom_rng_alg = {
 	}
 };
 
+static struct qcom_rng_match_data qcom_prng_match_data = {
+	.skip_init = false,
+	.hwrng_support = false,
+};
+
+static struct qcom_rng_match_data qcom_prng_ee_match_data = {
+	.skip_init = true,
+	.hwrng_support = false,
+};
+
+static struct qcom_rng_match_data qcom_trng_match_data = {
+	.skip_init = true,
+	.hwrng_support = true,
+};
+
 static int qcom_rng_probe(struct platform_device *pdev)
 {
 	struct qcom_rng *rng;
@@ -196,7 +211,11 @@ static int qcom_rng_probe(struct platform_device *pdev)
 	if (IS_ERR(rng->clk))
 		return PTR_ERR(rng->clk);
 
-	rng->match_data = (struct qcom_rng_match_data *)of_device_get_match_data(&pdev->dev);
+	if (has_acpi_companion(&pdev->dev))
+		rng->match_data = &qcom_prng_match_data;
+	else
+		rng->match_data =
+			(struct qcom_rng_match_data *)of_device_get_match_data(&pdev->dev);
 
 	qcom_rng_dev = rng;
 	ret = crypto_register_rng(&qcom_rng_alg);
@@ -231,21 +250,6 @@ static void qcom_rng_remove(struct platform_device *pdev)
 	qcom_rng_dev = NULL;
 }
 
-static struct qcom_rng_match_data qcom_prng_match_data = {
-	.skip_init = false,
-	.hwrng_support = false,
-};
-
-static struct qcom_rng_match_data qcom_prng_ee_match_data = {
-	.skip_init = true,
-	.hwrng_support = false,
-};
-
-static struct qcom_rng_match_data qcom_trng_match_data = {
-	.skip_init = true,
-	.hwrng_support = true,
-};
-
 static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = {
 	{ .id = "QCOM8160", .driver_data = 1 },
 	{}
-- 
2.46.0


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

* Re: [PATCH 0/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-08-29  1:20 [PATCH 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
  2024-08-29  1:20 ` [PATCH 1/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
  2024-08-29  1:20 ` [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
@ 2024-08-29  1:32 ` Brian Masney
  2 siblings, 0 replies; 7+ messages in thread
From: Brian Masney @ 2024-08-29  1:32 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel,
	Ernesto A. Fernández

On Wed, Aug 28, 2024 at 9:21 PM Brian Masney <bmasney@redhat.com> wrote:
>
> The qcom-rng driver supports both ACPI and device tree based systems.
> ACPI support was broken when the hw_random interface support was added.
> This small series gets that working again.
>
> This fix was boot tested on a Qualcomm Amberwing server.
>
> Brian Masney (2):
>   crypto: qcom-rng: rename *_of_data to *_match_data
>   crypto: qcom-rng: fix support for ACPI-based systems
>
>  drivers/crypto/qcom-rng.c | 50 +++++++++++++++++++++------------------
>  1 file changed, 27 insertions(+), 23 deletions(-)

Ohh I forgot to add this tag to the series:

Reported-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>


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

* Re: [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-08-29  1:20 ` [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
@ 2024-08-29 10:18   ` Dmitry Baryshkov
  2024-08-29 15:58   ` Ernesto A. Fernández
  1 sibling, 0 replies; 7+ messages in thread
From: Dmitry Baryshkov @ 2024-08-29 10:18 UTC (permalink / raw)
  To: Brian Masney
  Cc: herbert, davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel

On Wed, Aug 28, 2024 at 09:20:05PM GMT, Brian Masney wrote:
> The qcom-rng driver supports both ACPI and device tree based systems.
> ACPI support was broken when the hw_random interface support was added.
> Let's go ahead and fix this by checking has_acpi_companion().
> 
> This fix was boot tested on a Qualcomm Amberwing server.
> 
> Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
> Signed-off-by: Brian Masney <bmasney@redhat.com>

Please reorder the patches so that the Fix comes first (it can get
backported to stable kernels). Renaming the field is a cleanup and as
such it can come afterwards.

> ---
>  drivers/crypto/qcom-rng.c | 36 ++++++++++++++++++++----------------
>  1 file changed, 20 insertions(+), 16 deletions(-)
> 

-- 
With best wishes
Dmitry

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

* Re: [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-08-29  1:20 ` [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
  2024-08-29 10:18   ` Dmitry Baryshkov
@ 2024-08-29 15:58   ` Ernesto A. Fernández
  2024-08-29 16:13     ` Brian Masney
  1 sibling, 1 reply; 7+ messages in thread
From: Ernesto A. Fernández @ 2024-08-29 15:58 UTC (permalink / raw)
  To: Brian Masney, Jeffrey Hugo
  Cc: herbert, davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel

Hi,

thanks for the patch. I have one doubt:

On Wed, Aug 28, 2024 at 09:20:05PM -0400, Brian Masney wrote:
> The qcom-rng driver supports both ACPI and device tree based systems.
> ACPI support was broken when the hw_random interface support was added.
> Let's go ahead and fix this by checking has_acpi_companion().
> 
> This fix was boot tested on a Qualcomm Amberwing server.
> 
> Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
>  drivers/crypto/qcom-rng.c | 36 ++++++++++++++++++++----------------
>  1 file changed, 20 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
> index 4ed545001b77..470062cb258c 100644
> --- a/drivers/crypto/qcom-rng.c
> +++ b/drivers/crypto/qcom-rng.c
> @@ -176,6 +176,21 @@ static struct rng_alg qcom_rng_alg = {
>  	}
>  };
>  
> +static struct qcom_rng_match_data qcom_prng_match_data = {
> +	.skip_init = false,

So with acpi, skip_init will be set to false now, right? But before
f29cd5bb64c2 broke it, skip_init used to be set to true. Was that wrong
before, or now?

Ernesto

> +	.hwrng_support = false,
> +};
> +
> +static struct qcom_rng_match_data qcom_prng_ee_match_data = {
> +	.skip_init = true,
> +	.hwrng_support = false,
> +};
> +
> +static struct qcom_rng_match_data qcom_trng_match_data = {
> +	.skip_init = true,
> +	.hwrng_support = true,
> +};
> +
>  static int qcom_rng_probe(struct platform_device *pdev)
>  {
>  	struct qcom_rng *rng;
> @@ -196,7 +211,11 @@ static int qcom_rng_probe(struct platform_device *pdev)
>  	if (IS_ERR(rng->clk))
>  		return PTR_ERR(rng->clk);
>  
> -	rng->match_data = (struct qcom_rng_match_data *)of_device_get_match_data(&pdev->dev);
> +	if (has_acpi_companion(&pdev->dev))
> +		rng->match_data = &qcom_prng_match_data;
> +	else
> +		rng->match_data =
> +			(struct qcom_rng_match_data *)of_device_get_match_data(&pdev->dev);
>  
>  	qcom_rng_dev = rng;
>  	ret = crypto_register_rng(&qcom_rng_alg);
> @@ -231,21 +250,6 @@ static void qcom_rng_remove(struct platform_device *pdev)
>  	qcom_rng_dev = NULL;
>  }
>  
> -static struct qcom_rng_match_data qcom_prng_match_data = {
> -	.skip_init = false,
> -	.hwrng_support = false,
> -};
> -
> -static struct qcom_rng_match_data qcom_prng_ee_match_data = {
> -	.skip_init = true,
> -	.hwrng_support = false,
> -};
> -
> -static struct qcom_rng_match_data qcom_trng_match_data = {
> -	.skip_init = true,
> -	.hwrng_support = true,
> -};
> -
>  static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = {
>  	{ .id = "QCOM8160", .driver_data = 1 },
>  	{}
> -- 
> 2.46.0
> 

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

* Re: [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-08-29 15:58   ` Ernesto A. Fernández
@ 2024-08-29 16:13     ` Brian Masney
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Masney @ 2024-08-29 16:13 UTC (permalink / raw)
  To: Ernesto A. Fernández
  Cc: Jeffrey Hugo, herbert, davem, quic_omprsing, neil.armstrong,
	quic_bjorande, linux-arm-msm, linux-crypto, linux-kernel

On Thu, Aug 29, 2024 at 11:58 AM Ernesto A. Fernández
<ernesto.mnd.fernandez@gmail.com> wrote:
> thanks for the patch. I have one doubt:
>
> On Wed, Aug 28, 2024 at 09:20:05PM -0400, Brian Masney wrote:
> > The qcom-rng driver supports both ACPI and device tree based systems.
> > ACPI support was broken when the hw_random interface support was added.
> > Let's go ahead and fix this by checking has_acpi_companion().
> >
> > This fix was boot tested on a Qualcomm Amberwing server.
> >
> > Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
> > Signed-off-by: Brian Masney <bmasney@redhat.com>
> > ---
> >  drivers/crypto/qcom-rng.c | 36 ++++++++++++++++++++----------------
> >  1 file changed, 20 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
> > index 4ed545001b77..470062cb258c 100644
> > --- a/drivers/crypto/qcom-rng.c
> > +++ b/drivers/crypto/qcom-rng.c
> > @@ -176,6 +176,21 @@ static struct rng_alg qcom_rng_alg = {
> >       }
> >  };
> >
> > +static struct qcom_rng_match_data qcom_prng_match_data = {
> > +     .skip_init = false,
>
> So with acpi, skip_init will be set to false now, right? But before
> f29cd5bb64c2 broke it, skip_init used to be set to true. Was that wrong
> before, or now?

Good catch! I didn't check the _DSD and assumed it was always false.
I'll verify on the server we have in the lab and post a v2.

Brian


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

end of thread, other threads:[~2024-08-29 16:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29  1:20 [PATCH 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
2024-08-29  1:20 ` [PATCH 1/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
2024-08-29  1:20 ` [PATCH 2/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
2024-08-29 10:18   ` Dmitry Baryshkov
2024-08-29 15:58   ` Ernesto A. Fernández
2024-08-29 16:13     ` Brian Masney
2024-08-29  1:32 ` [PATCH 0/2] " Brian Masney

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