crypto: caam - iMX8QXP support (and related fixes)
Subsystems (4)
v6 cover crypto: caam - iMX8QXP support (and related fixes)
This series enables the use of the CAAM (Cryptographic Acceleration and Assurance Module) on the iMX8QXP (and its variants).
v6: (detailed changelog in each patch)
- Fix property order in bindings (Frank Li)
- Collect tags
v5: https://lore.kernel.org/linux-crypto/[email protected]/T
- Fix indentation issues in bindings (Rob Herring's bot)
- Collect tags
v4: https://lore.kernel.org/linux-crypto/[email protected]/T
- Declare more compatibles in bindings (Frank Li)
- Move job-ring compat check under the job-ring subschema (Rob Herring)
v3: https://lore.kernel.org/linux-crypto/[email protected]/T
- Fix devicetree CI detected errors (Rob Herring's bot)
- Declare the compatibles correctly in bindings (Krzysztof Kozlowski)
v2: https://lore.kernel.org/linux-crypto/[email protected]/T
- Clarify in the commit message how the crash fix works (Frank Li)
- Restrict power-domains only for iMX8Q* SoCs in bindings (Frank Li)
- Collect tags
v1: https://lore.kernel.org/linux-crypto/[email protected]/T
Horia Geantă (1):
arm64: dts: freescale: imx8qxp/imx8qm: Add CAAM support
John Ernberg (3):
crypto: caam - Prevent crash on suspend with iMX8QM / iMX8ULP
crypto: caam - Support iMX8QXP and variants thereof
dt-bindings: crypto: fsl,sec-v4.0: Add power domains for iMX8QM and
iMX8QXP
.../bindings/crypto/fsl,sec-v4.0.yaml | 41 ++++++++++++++++++- .../boot/dts/freescale/imx8-ss-security.dtsi | 38 +++++++++++++++++ arch/arm64/boot/dts/freescale/imx8qm.dtsi | 1 + .../dts/freescale/imx8qxp-ss-security.dtsi | 16 ++++++++ arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 2 + drivers/crypto/caam/ctrl.c | 7 ++-- drivers/crypto/caam/intern.h | 1 + 7 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 arch/arm64/boot/dts/freescale/imx8-ss-security.dtsi create mode 100644 arch/arm64/boot/dts/freescale/imx8qxp-ss-security.dtsi
Signature · 1 line
2.49.0
PATCH v6 1/4 crypto: caam - Prevent crash on suspend with iMX8QM / iMX8ULP
Since the CAAM on these SoCs is managed by another ARM core, called the SECO (Security Controller) on iMX8QM and Secure Enclave on iMX8ULP, which also reserves access to register page 0 suspend operations cannot touch this page.
This is similar to when running OPTEE, where OPTEE will reserve page 0.
Track this situation using a new state variable no_page0, reflecting if page 0 is reserved elsewhere, either by other management cores in SoC or by OPTEE.
Replace the optee_en check in suspend/resume with the new check.
optee_en cannot go away as it's needed elsewhere to gate OPTEE specific situations.
Fixes the following splat at suspend:
Internal error: synchronous external abort: 0000000096000010 [#1] SMP
Hardware name: Freescale i.MX8QXP ACU6C (DT)
pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : readl+0x0/0x18
lr : rd_reg32+0x18/0x3c
sp : ffffffc08192ba20
x29: ffffffc08192ba20 x28: ffffff8025190000 x27: 0000000000000000
x26: ffffffc0808ae808 x25: ffffffc080922338 x24: ffffff8020e89090
x23: 0000000000000000 x22: ffffffc080922000 x21: ffffff8020e89010
x20: ffffffc080387ef8 x19: ffffff8020e89010 x18: 000000005d8000d5
x17: 0000000030f35963 x16: 000000008f785f3f x15: 000000003b8ef57c
x14: 00000000c418aef8 x13: 00000000f5fea526 x12: 0000000000000001
x11: 0000000000000002 x10: 0000000000000001 x9 : 0000000000000000
x8 : ffffff8025190870 x7 : ffffff8021726880 x6 : 0000000000000002
x5 : ffffff80217268f0 x4 : ffffff8021726880 x3 : ffffffc081200000
x2 : 0000000000000001 x1 : ffffff8020e89010 x0 : ffffffc081200004
Call trace:
readl+0x0/0x18
caam_ctrl_suspend+0x30/0xdc
dpm_run_callback.constprop.0+0x24/0x5c
device_suspend+0x170/0x2e8
dpm_suspend+0xa0/0x104
dpm_suspend_start+0x48/0x50
suspend_devices_and_enter+0x7c/0x45c
pm_suspend+0x148/0x160
state_store+0xb4/0xf8
kobj_attr_store+0x14/0x24
sysfs_kf_write+0x38/0x48
kernfs_fop_write_iter+0xb4/0x178
vfs_write+0x118/0x178
ksys_write+0x6c/0xd0
__arm64_sys_write+0x14/0x1c
invoke_syscall.constprop.0+0x64/0xb0
do_el0_svc+0x90/0xb0
el0_svc+0x18/0x44
el0t_64_sync_handler+0x88/0x124
el0t_64_sync+0x150/0x154
Code: 88dffc21 88dffc21 5ac00800 d65f03c0 (b9400000)---
I noticed this when enabling the iMX8QXP support (next patch), hence the iMX8QXP backtrace, but the iMX8QM CAAM integration works exactly the same and according to the NXP tree [1] the iMX8ULP suffers the same issue.
[1]: https://github.com/nxp-imx/linux-imx/commit/653712ffe52dd59f407af1b781ce318f3d9e17bb
---
v6:
- Collect tags
v5:
- Collect tags
v4:
- Drop 2nd Fixes tag (Frank Li)
v3:
- no changes
v2:
- Adjust commit message to make it clearer what is happening around no_page0 (Frank Li)
--- drivers/crypto/caam/ctrl.c | 5 +++-- drivers/crypto/caam/intern.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/caam/ctrl.c +3 -2
@@ -831,7 +831,7 @@ static int caam_ctrl_suspend(struct device *dev) {const struct caam_drv_private *ctrlpriv =dev_get_drvdata (dev); -if (ctrlpriv->caam_off_during_pm && !ctrlpriv->optee_en) +if (ctrlpriv->caam_off_during_pm && !ctrlpriv->no_page0)caam_state_save (dev);return 0 ;
@@ -842,7 +842,7 @@ static int caam_ctrl_resume(struct device *dev)struct caam_drv_private *ctrlpriv =dev_get_drvdata (dev);int ret =0 ; -if (ctrlpriv->caam_off_during_pm && !ctrlpriv->optee_en) { +if (ctrlpriv->caam_off_during_pm && !ctrlpriv->no_page0) {caam_state_restore (dev);/* HW and rng will be reset so deinstantiation can be removed */
@@ -908,6 +908,7 @@ static int caam_probe(struct platform_device *pdev) imx_soc_data = imx_soc_match->data; reg_access = reg_access && imx_soc_data->page0_access; + ctrlpriv->no_page0 = !reg_access;/* * CAAM clocks cannot be controlled from kernel. */
drivers/crypto/caam/intern.h +1 -0
@@ -115,6 +115,7 @@ struct caam_drv_private {u8 blob_present;/* Nonzero if BLOB support present in device */ u8 mc_en;/* Nonzero if MC f/w is active */ u8 optee_en;/* Nonzero if OP-TEE f/w is active */ +u8 no_page0;/* Nonzero if register page 0 is not controlled by Linux */ bool pr_support;/* RNG prediction resistance available */ int secvio_irq;/* Security violation interrupt number */ int virt_en;/* Virtualization enabled in CAAM */
Signature · 1 line
2.49.0
PATCH v6 2/4 crypto: caam - Support iMX8QXP and variants thereof
In reply to John ErnbergThe iMX8QXP (and variants such as the QX, DX, DXP) all identify as iMX8QXP.
They have the exact same restrictions as the supported iMX8QM introduced at commit 61bb8db6f682 ("crypto: caam - Add support for i.MX8QM")
Loosen the check a little bit with a wildcard to also match the iMX8QXP and its variants.
---
v6:
- no changes
v5:
- Collect tags
v4:
- no changes
v3:
- no changes
v2:
- Collect review tag
--- drivers/crypto/caam/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/caam/ctrl.c +1 -1
@@ -573,7 +573,7 @@ static const struct soc_device_attribute caam_imx_soc_table[] = { { .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 = "i.MX8QM", .data = &caam_imx8ulp_data }, + { .soc_id = "i.MX8Q*", .data = &caam_imx8ulp_data }, { .soc_id = "VF*", .data = &caam_vf610_data }, { .family = "Freescale i.MX" }, {/* sentinel */ }
Signature · 1 line
2.49.0
PATCH v6 3/4 dt-bindings: crypto: fsl,sec-v4.0: Add power domains for iMX8QM and iMX8QXP
In reply to John ErnbergNXP SoCs like the iMX8QM, iMX8QXP or iMX8DXP use power domains for resource management.
Add compatible strings for these SoCs (QXP and DXP gets to share as their only difference is a core-count, Q=Quad core and D=Dual core), and allow power-domains for them only. Keep the old restriction for others.
---
v6:
- no changes
v5:
- Fixup indentation (Rob Herring's bot)
- Collect tags
v4:
- Reword commit message (Frank Li)
- Add explicit imx8qxp compatible (Frank Li)
- Move the job-ring constraints back to the job-ring section under an 'allOf:' to avoid the warning from v2 (Rob Herring)
v3:
- Fix warnings discovered by Rob Herring's bot
- Declare the compatibles correctly (Krzysztof Kozlowski)
v2:
- Adjust commit message (Frank Li)
- Only allow power-domains when compatible with imx8qm (Frank Li)
--- .../bindings/crypto/fsl,sec-v4.0.yaml | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/crypto/fsl,sec-v4.0.yaml +40 -1
@@ -46,6 +46,8 @@ properties: - items: - enum: - fsl,imx6ul-caam + - fsl,imx8qm-caam + - fsl,imx8qxp-caam - fsl,sec-v5.0 - const: fsl,sec-v4.0 - const: fsl,sec-v4.0
@@ -77,6 +79,9 @@ properties: interrupts: maxItems: 1 + power-domains: + maxItems: 1 + fsl,sec-era: description: Defines the 'ERA' of the SEC device. $ref: /schemas/types.yaml#/definitions/uint32
@@ -106,7 +111,10 @@ patternProperties: - const: fsl,sec-v5.0-job-ring - const: fsl,sec-v4.0-job-ring - items: - - const: fsl,sec-v5.0-job-ring + - enum: + - fsl,imx8qm-job-ring + - fsl,imx8qxp-job-ring + - fsl,sec-v5.0-job-ring - const: fsl,sec-v4.0-job-ring - const: fsl,sec-v4.0-job-ring
@@ -116,6 +124,9 @@ patternProperties: interrupts: maxItems: 1 + power-domains: + maxItems: 1 + fsl,liodn: description: Specifies the LIODN to be used in conjunction with the ppid-to-liodn
@@ -125,6 +136,20 @@ patternProperties: $ref: /schemas/types.yaml#/definitions/uint32-array items: - maximum: 0xfff + allOf: + - if: + properties: + compatible: + contains: + enum: + - fsl,imx8qm-job-ring + - fsl,imx8qxp-job-ring + then: + required: + - power-domains + else: + properties: + power-domains: false '^rtic@[0-9a-f]+$': type: object
@@ -212,6 +237,20 @@ required: - reg - ranges +if: + properties: + compatible: + contains: + enum: + - fsl,imx8qm-caam + - fsl,imx8qxp-caam +then: + required: + - power-domains +else: + properties: + power-domains: false + additionalProperties: false examples:
Signature · 1 line
2.49.0
PATCH v6 4/4 arm64: dts: freescale: imx8qxp/imx8qm: Add CAAM support
In reply to John ErnbergFrom: Horia Geantă <[email protected]>
The iMX8QXP and iMX8QM have a CAAM (Cryptographic Acceleration and Assurance Module) like many other iMXs.
Add the definitions for it.
Job Rings 0 and 1 are bound to the SECO (Security Controller) ARM core and are not exposed outside it. There's no point to define them in the bindings as they cannot be used outside the SECO.
---
Imported from NXP tree, trimmed down and fixed the dtbs_check warnings.
Constrained the ranges to the needed ones.
Changed the commit message.
Original here: https://github.com/nxp-imx/linux-imx/commit/699e54b386cb9b53def401798d0a4e646105583d
---
v6:
- Properly sort properties (Frank Li)
- Collect tags
v5:
- Collect tags
v4:
- Drop [ ] rework detailing from commit log. (Frank Li)
- Add an override dtsi to change the compatibles on QXP due to changes in 3/4. (Frank Li)
v3:
- no changes
v2:
- Use new compatibles introduced in 3/4 (Frank Li)
--- .../boot/dts/freescale/imx8-ss-security.dtsi | 38 +++++++++++++++++++ arch/arm64/boot/dts/freescale/imx8qm.dtsi | 1 + .../dts/freescale/imx8qxp-ss-security.dtsi | 16 ++++++++ arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 2 + 4 files changed, 57 insertions(+) create mode 100644 arch/arm64/boot/dts/freescale/imx8-ss-security.dtsi create mode 100644 arch/arm64/boot/dts/freescale/imx8qxp-ss-security.dtsi
arch/arm64/boot/dts/freescale/imx8-ss-security.dtsi new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 NXP + */ + +#include <dt-bindings/firmware/imx/rsrc.h> + +security_subsys: bus@31400000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x31400000 0x0 0x31400000 0x90000>; + + crypto: crypto@31400000 { + compatible = "fsl,imx8qm-caam", "fsl,sec-v4.0"; + reg = <0x31400000 0x90000>; + interrupts = <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x31400000 0x90000>; + power-domains = <&pd IMX_SC_R_CAAM_JR2>; + fsl,sec-era = <9>; + + sec_jr2: jr@30000 { + compatible = "fsl,imx8qm-job-ring", "fsl,sec-v4.0-job-ring"; + reg = <0x30000 0x10000>; + interrupts = <GIC_SPI 453 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pd IMX_SC_R_CAAM_JR2>; + }; + + sec_jr3: jr@40000 { + compatible = "fsl,imx8qm-job-ring", "fsl,sec-v4.0-job-ring"; + reg = <0x40000 0x10000>; + interrupts = <GIC_SPI 454 IRQ_TYPE_LEVEL_HIGH>; + power-domains = <&pd IMX_SC_R_CAAM_JR3>; + }; + }; +};
arch/arm64/boot/dts/freescale/imx8qm.dtsi +1 -0
@@ -612,6 +612,7 @@ vpu_dsp: dsp@556e8000 { }; /* sorted in register address */ + #include "imx8-ss-security.dtsi" #include "imx8-ss-cm41.dtsi" #include "imx8-ss-audio.dtsi" #include "imx8-ss-vpu.dtsi"
arch/arm64/boot/dts/freescale/imx8qxp-ss-security.dtsi new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2025 Actia Nordic AB + */ + +&crypto { + compatible = "fsl,imx8qxp-caam", "fsl,sec-v4.0"; +}; + +&sec_jr2 { + compatible = "fsl,imx8qxp-job-ring", "fsl,sec-v4.0-job-ring"; +}; + +&sec_jr3 { + compatible = "fsl,imx8qxp-job-ring", "fsl,sec-v4.0-job-ring"; +};
arch/arm64/boot/dts/freescale/imx8qxp.dtsi +2 -0
@@ -321,6 +321,7 @@ map0 { /* sorted in register address */ #include "imx8-ss-img.dtsi" #include "imx8-ss-vpu.dtsi" + #include "imx8-ss-security.dtsi" #include "imx8-ss-cm40.dtsi" #include "imx8-ss-gpu0.dtsi" #include "imx8-ss-adma.dtsi"
@@ -332,6 +333,7 @@ map0 { #include "imx8qxp-ss-img.dtsi" #include "imx8qxp-ss-vpu.dtsi" +#include "imx8qxp-ss-security.dtsi" #include "imx8qxp-ss-adma.dtsi" #include "imx8qxp-ss-conn.dtsi" #include "imx8qxp-ss-lsio.dtsi"
Signature · 1 line
2.49.0
Shawn Guo
AppliedRe: [PATCH v6 4/4] arm64: dts: freescale: imx8qxp/imx8qm: Add CAAM support
Quoted 7 lines · John Ernberg
From: Horia Geantă <[email protected]>
The iMX8QXP and iMX8QM have a CAAM (Cryptographic Acceleration and Assurance Module) like many other iMXs.
Add the definitions for it.
Quoted 8 lines
Job Rings 0 and 1 are bound to the SECO (Security Controller) ARM core and are not exposed outside it. There's no point to define them in the bindings as they cannot be used outside the SECO.
Signed-off-by Horia Geantă <[email protected]>Signed-off-by John Ernberg <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Frank Li <[email protected]>
Applied, thanks!
Herbert Xu
maintainerQuoted 35 lines · John Ernberg
This series enables the use of the CAAM (Cryptographic Acceleration and Assurance Module) on the iMX8QXP (and its variants).
v6: (detailed changelog in each patch)
- Fix property order in bindings (Frank Li)
- Collect tagsv5: https://lore.kernel.org/linux-crypto/[email protected]/T
- Fix indentation issues in bindings (Rob Herring's bot)
- Collect tagsv4: https://lore.kernel.org/linux-crypto/[email protected]/T
- Declare more compatibles in bindings (Frank Li)
- Move job-ring compat check under the job-ring subschema (Rob Herring)v3: https://lore.kernel.org/linux-crypto/[email protected]/T
- Fix devicetree CI detected errors (Rob Herring's bot)
- Declare the compatibles correctly in bindings (Krzysztof Kozlowski)v2: https://lore.kernel.org/linux-crypto/[email protected]/T
- Clarify in the commit message how the crash fix works (Frank Li)
- Restrict power-domains only for iMX8Q* SoCs in bindings (Frank Li)
- Collect tagsv1: https://lore.kernel.org/linux-crypto/[email protected]/T
Horia Geantă (1):
arm64: dts: freescale: imx8qxp/imx8qm: Add CAAM supportJohn Ernberg (3):
crypto: caam - Prevent crash on suspend with iMX8QM / iMX8ULP
crypto: caam - Support iMX8QXP and variants thereof
dt-bindings: crypto: fsl,sec-v4.0: Add power domains for iMX8QM and
iMX8QXP
Quoted 13 lines
.../bindings/crypto/fsl,sec-v4.0.yaml | 41 ++++++++++++++++++- .../boot/dts/freescale/imx8-ss-security.dtsi | 38 +++++++++++++++++ arch/arm64/boot/dts/freescale/imx8qm.dtsi | 1 + .../dts/freescale/imx8qxp-ss-security.dtsi | 16 ++++++++ arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 2 + drivers/crypto/caam/ctrl.c | 7 ++-- drivers/crypto/caam/intern.h | 1 + 7 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 arch/arm64/boot/dts/freescale/imx8-ss-security.dtsi create mode 100644 arch/arm64/boot/dts/freescale/imx8qxp-ss-security.dtsiSignature · 1 line
2.49.0
Patches 1-3 applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt