crypto: Add Qcom PRNG support
Subsystems (4)
v5 cover crypto: Add Qcom PRNG support
This series removes the hwrng qcom driver and replaces it with crypto qcom driver and then adds support for Execution Environment (EE) found in v2 version of the hardware and ACPI support for these
Changes in v5:
- Update ACPI check and use generic driver data API
Changes in v4:
- Use memcpy for data copy
- Fix trailing bytes copy
- Fix ACPI ID table name
Timur Tabi (1):
crypto: qcom: Add ACPI support
Vinod Koul (5):
hwrng: remove msm hw_random driver
dt-bindings: crypto: Move prng binding to crypto
crypto: Add Qcom prng driver
dt-bindings: crypto: Add new compatible qcom,prng-ee
crypto: qcom: Add support for prng-ee
.../bindings/{rng => crypto}/qcom,prng.txt | 4 +-
drivers/char/hw_random/Kconfig | 13 --
drivers/char/hw_random/Makefile | 1 -
drivers/char/hw_random/msm-rng.c | 183 ----------------
drivers/crypto/Kconfig | 11 +
drivers/crypto/Makefile | 1 +
drivers/crypto/qcom-rng.c | 229 +++++++++++++++++++++
7 files changed, 244 insertions(+), 198 deletions(-)
rename Documentation/devicetree/bindings/{rng => crypto}/qcom,prng.txt (73%)
delete mode 100644 drivers/char/hw_random/msm-rng.c
create mode 100644 drivers/crypto/qcom-rng.cSignature · 1 line
2.14.4
PATCH v5 1/6 hwrng: remove msm hw_random driver
This driver is for a psedo-rng so should not be added in hwrng. Remove it so that it's replacement can be added.
--- drivers/char/hw_random/Kconfig | 13 --- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/msm-rng.c | 183 --------------------------------------- 3 files changed, 197 deletions(-) delete mode 100644 drivers/char/hw_random/msm-rng.c
drivers/char/hw_random/Kconfig +0 -13
@@ -307,19 +307,6 @@ config HW_RANDOM_HISI If unsure, say Y. -config HW_RANDOM_MSM - tristate "Qualcomm SoCs Random Number Generator support" - depends on HW_RANDOM && ARCH_QCOM - default HW_RANDOM - ---help--- - This driver provides kernel-side support for the Random Number - Generator hardware found on Qualcomm SoCs. - - To compile this driver as a module, choose M here. the - module will be called msm-rng. - - If unsure, say Y. - config HW_RANDOM_ST tristate "ST Microelectronics HW Random Number Generator support" depends on HW_RANDOM && ARCH_STI
drivers/char/hw_random/Makefile +0 -1
@@ -29,7 +29,6 @@ obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o obj-$(CONFIG_HW_RANDOM_HISI) += hisi-rng.o obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o -obj-$(CONFIG_HW_RANDOM_MSM) += msm-rng.o obj-$(CONFIG_HW_RANDOM_ST) += st-rng.o obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o obj-$(CONFIG_HW_RANDOM_STM32) += stm32-rng.o
drivers/char/hw_random/msm-rng.c deleted +0 -183
183 lines not on this page · raw message
Signature · 1 line
2.14.4
PATCH v5 2/6 dt-bindings: crypto: Move prng binding to crypto
In reply to Vinod KoulNow that we are adding new driver for prng in crypto, move the binding as well.
---
Documentation/devicetree/bindings/{rng => crypto}/qcom,prng.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Documentation/devicetree/bindings/{rng => crypto}/qcom,prng.txt (100%)Documentation/devicetree/bindings/crypto/qcom,prng.txt renamed from Documentation/devicetree/bindings/rng/qcom,prng.txt +0 -0
Signature · 1 line
2.14.4
PATCH v5 3/6 crypto: Add Qcom prng driver
In reply to Vinod KoulThis ports the Qcom prng from older hw_random driver.
No change of functionality and move from hw_random to crypto APIs is done.
--- drivers/crypto/Kconfig | 11 +++ drivers/crypto/Makefile | 1 + drivers/crypto/qcom-rng.c | 208 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100644 drivers/crypto/qcom-rng.c
drivers/crypto/Kconfig +11 -0
@@ -585,6 +585,17 @@ config CRYPTO_DEV_QCE hardware. To compile this driver as a module, choose M here. The module will be called qcrypto. +config CRYPTO_DEV_QCOM_RNG + tristate "Qualcomm Randon Number Generator Driver" + depends on ARCH_QCOM || COMPILE_TEST + select CRYPTO_RNG + help + This driver provides support for the Random Number + Generator hardware found on Qualcomm SoCs. + + To compile this driver as a module, choose M here. the + module will be called qcom-rng. If unsure, say N. + config CRYPTO_DEV_VMX bool "Support for VMX cryptographic acceleration instructions" depends on PPC64 && VSX
drivers/crypto/Makefile +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_CRYPTO_DEV_PICOXCELL) += picoxcell_crypto.o obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/ obj-$(CONFIG_CRYPTO_DEV_QAT) += qat/ obj-$(CONFIG_CRYPTO_DEV_QCE) += qce/ +obj-$(CONFIG_CRYPTO_DEV_QCOM_RNG) += qcom-rng.o obj-$(CONFIG_CRYPTO_DEV_ROCKCHIP) += rockchip/ obj-$(CONFIG_CRYPTO_DEV_S5P) += s5p-sss.o obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o
drivers/crypto/qcom-rng.c new file +208 -0
208 lines not on this page · raw message
Signature · 1 line
2.14.4
Re: [PATCH v5 3/6] crypto: Add Qcom prng driver
Quoted 6 lines · Vinod Koul
This ports the Qcom prng from older
hw_randomdriver.No change of functionality and move from
hw_randomto crypto APIs is done.Signed-off-by Vinod Koul <[email protected]>
FWIW:
drivers/crypto/Kconfig config CRYPTO_DEV_QCE · line 589
Quoted 2 lines
drivers/crypto/Kconfig +2
-0+config CRYPTO_DEV_QCOM_RNG + tristate "Qualcomm Randon Number Generator Driver"
Random speling error.
Quoted 1 line
+#include <
linux/of_device.h>
Do you need this? It seems like a platform device fair and square.
Yours,
Linus Walleij
Re: [PATCH v5 3/6] crypto: Add Qcom prng driver
Quoted 11 lines · Linus Walleij
Quoted 6 lines · Vinod Koul
This ports the Qcom prng from older
hw_randomdriver.No change of functionality and move from
hw_randomto crypto APIs is done.Signed-off-by Vinod Koul <[email protected]>FWIW:
Reviewed-by Linus Walleij <[email protected]>
Thanks
Quoted 4 lines
drivers/crypto/Kconfig config CRYPTO_DEV_QCE · line 589
Quoted 2 lines
drivers/crypto/Kconfig +2
-0+config CRYPTO_DEV_QCOM_RNG + tristate "Qualcomm Randon Number Generator Driver"Random speling error.
Will fix, thanks for pointing
Quoted 3 lines
Quoted 1 line
+#include <
linux/of_device.h>Do you need this? It seems like a platform device fair and square.
It was required for of_device_get_match_data() but then the change is in subsequent patch, I should move that
Signature · 1 line
~Vinod
Re: [PATCH v5 3/6] crypto: Add Qcom prng driver
Quoted 9 lines · Vinod
Quoted 5 lines · Linus Walleij
Quoted 1 line · Vinod Koul
+#include <
linux/of_device.h>Do you need this? It seems like a platform device fair and square.
It was required for
of_device_get_match_data()but then the change is in subsequent patch, I should move that
And I need of.h here for of_match_ptr. Added that and removed of_device.h.
Signature · 1 line
~Vinod
PATCH v5 4/6 dt-bindings: crypto: Add new compatible qcom,prng-ee
In reply to Vinod KoulLater qcom chips support v2 of the prng, which exposes an EE (Execution Environment) for OS to use so add new compatible qcom,prng-ee for this.
--- Documentation/devicetree/bindings/crypto/qcom,prng.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/crypto/qcom,prng.txt +3 -1
@@ -2,7 +2,9 @@ Qualcomm MSM pseudo random number generator. Required properties: -- compatible : should be "qcom,prng" +- compatible : should be "qcom,prng" for 8916 etc + : should be "qcom,prng-ee" for 8996 and later using EE + (Execution Environment) slice of prng - reg : specifies base physical address and size of the registers map - clocks : phandle to clock-controller plus clock-specifier pair - clock-names : "core" clocks all registers, FIFO and circuits in PRNG IP block
Signature · 1 line
2.14.4
PATCH v5 5/6 crypto: qcom: Add support for prng-ee
In reply to Vinod KoulQcom 8996 and later chips features multiple Execution Environments (EE) and secure world is typically responsible for configuring the prng.
Add driver data for qcom,prng as 0 and qcom,prng-ee as 1 and use that to skip initialization routine.
--- drivers/crypto/qcom-rng.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/crypto/qcom-rng.c +9 -2
@@ -28,6 +28,7 @@ struct qcom_rng {struct mutex lock;void __iomem *base;struct clk *clk; +unsigned int skip_init; };struct qcom_rng_ctx {
@@ -128,7 +129,10 @@ static int qcom_rng_init(struct crypto_tfm *tfm) ctx->rng = qcom_rng_dev; -return qcom_rng_enable (ctx->rng); +if (!ctx->rng->skip_init) +return qcom_rng_enable (ctx->rng); + +return 0 ; }static struct rng_alg qcom_rng_alg = {
@@ -168,6 +172,8 @@ static int qcom_rng_probe(struct platform_device *pdev)if (IS_ERR (rng->clk))return PTR_ERR (rng->clk); + rng->skip_init = (unsigned long )of_device_get_match_data (&pdev->dev); + qcom_rng_dev = rng; ret =crypto_register_rng (&qcom_rng_alg);if (ret) {
@@ -188,7 +194,8 @@ static int qcom_rng_remove(struct platform_device *pdev) }static const struct of_device_id qcom_rng_of_match[] = { - { .compatible ="qcom,prng" }, + { .compatible ="qcom,prng" , .data = (void *)0 }, + { .compatible ="qcom,prng-ee" , .data = (void *)1 }, {} };MODULE_DEVICE_TABLE (of, qcom_rng_of_match);
Signature · 1 line
2.14.4
PATCH v5 6/6 crypto: qcom: Add ACPI support
In reply to Vinod KoulFrom: Timur Tabi <[email protected]>
Add support for probing on ACPI systems, with ACPI HID QCOM8160.
On ACPI systems, clocks are always enabled, the PRNG should already be enabled, and the register region is read-only. The driver only verifies that the hardware is already enabled never tries to disable or configure it.
--- drivers/crypto/qcom-rng.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/crypto/qcom-rng.c +18 -4
@@ -4,6 +4,7 @@// Based on msm-rng.c and downstream driver #include <crypto/internal/rng.h> +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/crypto.h> #include <linux/module.h>
@@ -168,13 +169,17 @@ static int qcom_rng_probe(struct platform_device *pdev)if (IS_ERR (rng->base))return PTR_ERR (rng->base); - rng->clk =devm_clk_get (&pdev->dev,"core" ); -if (IS_ERR (rng->clk)) -return PTR_ERR (rng->clk); - rng->skip_init = (unsigned long )of_device_get_match_data (&pdev->dev); +/* ACPI systems have clk already on, so skip clk_get */ +if (!has_acpi_companion (&pdev->dev)) { + rng->clk =devm_clk_get (&pdev->dev,"core" ); +if (IS_ERR (rng->clk)) +return PTR_ERR (rng->clk); + } + rng->skip_init = (unsigned long )device_get_match_data (&pdev->dev); qcom_rng_dev = rng; + ret =crypto_register_rng (&qcom_rng_alg);if (ret) {dev_err (&pdev->dev,"Register crypto rng failed: %d\n" , ret);
@@ -193,6 +198,14 @@ static int qcom_rng_remove(struct platform_device *pdev)return 0 ; } +#if IS_ENABLED (CONFIG_ACPI ) +static const struct acpi_device_id qcom_rng_acpi_match[] = { + { .id ="QCOM8160" , .driver_data =1 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, qcom_rng_acpi_match); +#endif +static const struct of_device_id qcom_rng_of_match[] = { { .compatible ="qcom,prng" , .data = (void *)0 }, { .compatible ="qcom,prng-ee" , .data = (void *)1 },
@@ -206,6 +219,7 @@ static struct platform_driver qcom_rng_driver = { .driver = { .name = KBUILD_MODNAME, .of_match_table = of_match_ptr(qcom_rng_of_match), + .acpi_match_table = ACPI_PTR(qcom_rng_acpi_match), } };module_platform_driver (qcom_rng_driver);
Signature · 1 line
2.14.4
Re: [PATCH v5 6/6] crypto: qcom: Add ACPI support
Quoted 4 lines · Vinod Koul
From: Timur Tabi <[email protected]>
Add support for probing on ACPI systems, with ACPI HID QCOM8160.
Quoted 8 lines
On ACPI systems, clocks are always enabled, the PRNG should already be enabled, and the register region is read-only. The driver only verifies that the hardware is already enabled never tries to disable or configure it.
Signed-off-by Timur Tabi <[email protected]>[port to crypto API]Signed-off-by Vinod Koul <[email protected]>
Quoted 62 lines
--- drivers/crypto/qcom-rng.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)drivers/crypto/qcom-rng.c +18
-4@@ -4,6 +4,7 @@// Based on msm-rng.c and downstream driver #include <crypto/internal/rng.h> +#include <linux/acpi.h> #include <linux/clk.h> #include <linux/crypto.h> #include <linux/module.h> @@ -168,13 +169,17 @@ static int qcom_rng_probe(struct platform_device *pdev)if (IS_ERR (rng->base))return PTR_ERR (rng->base); - rng->clk =devm_clk_get (&pdev->dev,"core" ); -if (IS_ERR (rng->clk)) -return PTR_ERR (rng->clk); - rng->skip_init = (unsigned long )of_device_get_match_data (&pdev->dev); +/* ACPI systems have clk already on, so skip clk_get */ +if (!has_acpi_companion (&pdev->dev)) { + rng->clk =devm_clk_get (&pdev->dev,"core" ); +if (IS_ERR (rng->clk)) +return PTR_ERR (rng->clk); + } + rng->skip_init = (unsigned long )device_get_match_data (&pdev->dev); qcom_rng_dev = rng; + ret =crypto_register_rng (&qcom_rng_alg);if (ret) {dev_err (&pdev->dev,"Register crypto rng failed: %d\n" , ret);@@ -193,6 +198,14 @@ static int qcom_rng_remove(struct platform_device *pdev)return 0 ; } +#if IS_ENABLED (CONFIG_ACPI ) +static const struct acpi_device_id qcom_rng_acpi_match[] = { + { .id ="QCOM8160" , .driver_data =1 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, qcom_rng_acpi_match); +#endif +static const struct of_device_id qcom_rng_of_match[] = { { .compatible ="qcom,prng" , .data = (void *)0 }, { .compatible ="qcom,prng-ee" , .data = (void *)1 },@@ -206,6 +219,7 @@ static struct platform_driver qcom_rng_driver = { .driver = { .name = KBUILD_MODNAME, .of_match_table = of_match_ptr(qcom_rng_of_match), + .acpi_match_table = ACPI_PTR(qcom_rng_acpi_match), } };module_platform_driver (qcom_rng_driver);
Signature · 4 lines
Jeffrey Hugo Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH v5 6/6] crypto: qcom: Add ACPI support
Quoted 8 lines · Jeffrey Hugo
Quoted 8 lines
Add support for probing on ACPI systems, with ACPI HID QCOM8160.
On ACPI systems, clocks are always enabled, the PRNG should already be enabled, and the register region is read-only. The driver only verifies that the hardware is already enabled never tries to disable or configure it.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Timur Tabi <[email protected]>[port to crypto API]Signed-off-by Vinod Koul <[email protected]>Tested-by Jeffrey Hugo <[email protected]>
Thanks, Jeff. I appreciate it.
Re: [PATCH v5 6/6] crypto: qcom: Add ACPI support
In reply to Jeffrey HugoQuoted 10 lines · Jeffrey Hugo
Quoted 9 lines · Vinod Koul
From: Timur Tabi <[email protected]>
Add support for probing on ACPI systems, with ACPI HID QCOM8160.
On ACPI systems, clocks are always enabled, the PRNG should already be enabled, and the register region is read-only. The driver only verifies that the hardware is already enabled never tries to disable or configure it.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Timur Tabi <[email protected]>[port to crypto API]Signed-off-by Vinod Koul <[email protected]>Tested-by Jeffrey Hugo <[email protected]>
Thanks Jeffrey.
Signature · 1 line
~Vinod