mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems
@ 2024-09-06  0:25 Brian Masney
  2024-09-06  0:25 ` [PATCH v3 1/2] " Brian Masney
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Brian Masney @ 2024-09-06  0:25 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel, ernesto.mnd.fernandez,
	quic_jhugo

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 (ACPI based) and
on a Qualcomm SA8775p Automotive Development Board (DT based). I also
verified that qcom-rng shows up in /proc/crypto on both systems.

Changes since v2:
- Simplify ACPI fix based on what's done with other drivers (Brian)

Changes since v1:
- Use qcom_prng_ee_match_data instead of qcom_prng_match_data for the
  true skip_init to match previous behavior (Ernesto)
- Reordered patches so fix is first (Dmitry)

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

 drivers/crypto/qcom-rng.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

-- 
2.46.0


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

* [PATCH v3 1/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-09-06  0:25 [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
@ 2024-09-06  0:25 ` Brian Masney
  2024-09-06  0:44   ` Dmitry Baryshkov
  2024-09-06  0:25 ` [PATCH v3 2/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Brian Masney @ 2024-09-06  0:25 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel, ernesto.mnd.fernandez,
	quic_jhugo

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 adding the appropriate driver data to the
ACPI match table, and change the of_device_get_match_data() call to
device_get_match_data() so that it will also work on ACPI-based systems.

This fix was boot tested on a Qualcomm Amberwing server (ACPI based) and
on a Qualcomm SA8775p Automotive Development Board (DT based). I also
verified that qcom-rng shows up in /proc/crypto on both systems.

Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
Reported-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Closes: https://lore.kernel.org/linux-arm-msm/20240828184019.GA21181@eaf/
Cc: stable@vger.kernel.org
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
 drivers/crypto/qcom-rng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index c670d7d0c11e..6496b075a48d 100644
--- a/drivers/crypto/qcom-rng.c
+++ b/drivers/crypto/qcom-rng.c
@@ -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->of_data = (struct qcom_rng_of_data *)device_get_match_data(&pdev->dev);
 
 	qcom_rng_dev = rng;
 	ret = crypto_register_rng(&qcom_rng_alg);
@@ -247,7 +247,7 @@ static struct qcom_rng_of_data qcom_trng_of_data = {
 };
 
 static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = {
-	{ .id = "QCOM8160", .driver_data = 1 },
+	{ .id = "QCOM8160", .driver_data = (kernel_ulong_t)&qcom_prng_ee_of_data },
 	{}
 };
 MODULE_DEVICE_TABLE(acpi, qcom_rng_acpi_match);
-- 
2.46.0


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

* [PATCH v3 2/2] crypto: qcom-rng: rename *_of_data to *_match_data
  2024-09-06  0:25 [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
  2024-09-06  0:25 ` [PATCH v3 1/2] " Brian Masney
@ 2024-09-06  0:25 ` Brian Masney
  2024-09-06  0:52   ` Dmitry Baryshkov
  2024-09-06  2:04 ` [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Bjorn Andersson
  2024-09-13 10:31 ` Herbert Xu
  3 siblings, 1 reply; 7+ messages in thread
From: Brian Masney @ 2024-09-06  0:25 UTC (permalink / raw)
  To: herbert
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel, ernesto.mnd.fernandez,
	quic_jhugo

The qcom-rng driver supports both ACPI and device tree based systems.
Let's rename all instances of *of_data to *match_data so that it's
not implied that this driver only supports device tree-based systems.

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

diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c
index 6496b075a48d..09419e79e34c 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 *)device_get_match_data(&pdev->dev);
+	rng->match_data = (struct qcom_rng_match_data *)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,31 +231,31 @@ 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,
 };
 
 static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = {
-	{ .id = "QCOM8160", .driver_data = (kernel_ulong_t)&qcom_prng_ee_of_data },
+	{ .id = "QCOM8160", .driver_data = (kernel_ulong_t)&qcom_prng_ee_match_data },
 	{}
 };
 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	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-09-06  0:25 ` [PATCH v3 1/2] " Brian Masney
@ 2024-09-06  0:44   ` Dmitry Baryshkov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Baryshkov @ 2024-09-06  0:44 UTC (permalink / raw)
  To: Brian Masney
  Cc: herbert, davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel, ernesto.mnd.fernandez,
	quic_jhugo

On Thu, Sep 05, 2024 at 08:25:20PM 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 adding the appropriate driver data to the
> ACPI match table, and change the of_device_get_match_data() call to
> device_get_match_data() so that it will also work on ACPI-based systems.
> 
> This fix was boot tested on a Qualcomm Amberwing server (ACPI based) and
> on a Qualcomm SA8775p Automotive Development Board (DT based). I also
> verified that qcom-rng shows up in /proc/crypto on both systems.
> 
> Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
> Reported-by: Ernesto A. Fern??ndez <ernesto.mnd.fernandez@gmail.com>
> Closes: https://lore.kernel.org/linux-arm-msm/20240828184019.GA21181@eaf/
> Cc: stable@vger.kernel.org
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
>  drivers/crypto/qcom-rng.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 2/2] crypto: qcom-rng: rename *_of_data to *_match_data
  2024-09-06  0:25 ` [PATCH v3 2/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
@ 2024-09-06  0:52   ` Dmitry Baryshkov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Baryshkov @ 2024-09-06  0:52 UTC (permalink / raw)
  To: Brian Masney
  Cc: herbert, davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel, ernesto.mnd.fernandez,
	quic_jhugo

On Thu, Sep 05, 2024 at 08:25:21PM GMT, Brian Masney wrote:
> The qcom-rng driver supports both ACPI and device tree based systems.
> Let's rename all instances of *of_data to *match_data so that it's
> not implied that this driver only supports device tree-based systems.
> 
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> ---
>  drivers/crypto/qcom-rng.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-09-06  0:25 [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
  2024-09-06  0:25 ` [PATCH v3 1/2] " Brian Masney
  2024-09-06  0:25 ` [PATCH v3 2/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
@ 2024-09-06  2:04 ` Bjorn Andersson
  2024-09-13 10:31 ` Herbert Xu
  3 siblings, 0 replies; 7+ messages in thread
From: Bjorn Andersson @ 2024-09-06  2:04 UTC (permalink / raw)
  To: Brian Masney
  Cc: herbert, davem, quic_omprsing, neil.armstrong, linux-arm-msm,
	linux-crypto, linux-kernel, ernesto.mnd.fernandez, quic_jhugo

On Thu, Sep 05, 2024 at 08:25:19PM -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.
> This small series gets that working again.
> 
> This fix was boot tested on a Qualcomm Amberwing server (ACPI based) and
> on a Qualcomm SA8775p Automotive Development Board (DT based). I also
> verified that qcom-rng shows up in /proc/crypto on both systems.
> 

Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com>

Regards,
Bjorn

> Changes since v2:
> - Simplify ACPI fix based on what's done with other drivers (Brian)
> 
> Changes since v1:
> - Use qcom_prng_ee_match_data instead of qcom_prng_match_data for the
>   true skip_init to match previous behavior (Ernesto)
> - Reordered patches so fix is first (Dmitry)
> 
> Brian Masney (2):
>   crypto: qcom-rng: fix support for ACPI-based systems
>   crypto: qcom-rng: rename *_of_data to *_match_data
> 
>  drivers/crypto/qcom-rng.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> -- 
> 2.46.0
> 

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

* Re: [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems
  2024-09-06  0:25 [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
                   ` (2 preceding siblings ...)
  2024-09-06  2:04 ` [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Bjorn Andersson
@ 2024-09-13 10:31 ` Herbert Xu
  3 siblings, 0 replies; 7+ messages in thread
From: Herbert Xu @ 2024-09-13 10:31 UTC (permalink / raw)
  To: Brian Masney
  Cc: davem, quic_omprsing, neil.armstrong, quic_bjorande,
	linux-arm-msm, linux-crypto, linux-kernel, ernesto.mnd.fernandez,
	quic_jhugo

On Thu, Sep 05, 2024 at 08:25:19PM -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.
> This small series gets that working again.
> 
> This fix was boot tested on a Qualcomm Amberwing server (ACPI based) and
> on a Qualcomm SA8775p Automotive Development Board (DT based). I also
> verified that qcom-rng shows up in /proc/crypto on both systems.
> 
> Changes since v2:
> - Simplify ACPI fix based on what's done with other drivers (Brian)
> 
> Changes since v1:
> - Use qcom_prng_ee_match_data instead of qcom_prng_match_data for the
>   true skip_init to match previous behavior (Ernesto)
> - Reordered patches so fix is first (Dmitry)
> 
> Brian Masney (2):
>   crypto: qcom-rng: fix support for ACPI-based systems
>   crypto: qcom-rng: rename *_of_data to *_match_data
> 
>  drivers/crypto/qcom-rng.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> -- 
> 2.46.0

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] 7+ messages in thread

end of thread, other threads:[~2024-09-13 10:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06  0:25 [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Brian Masney
2024-09-06  0:25 ` [PATCH v3 1/2] " Brian Masney
2024-09-06  0:44   ` Dmitry Baryshkov
2024-09-06  0:25 ` [PATCH v3 2/2] crypto: qcom-rng: rename *_of_data to *_match_data Brian Masney
2024-09-06  0:52   ` Dmitry Baryshkov
2024-09-06  2:04 ` [PATCH v3 0/2] crypto: qcom-rng: fix support for ACPI-based systems Bjorn Andersson
2024-09-13 10:31 ` 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®