Add support for Texas Instruments DTHE V2 crypto accelerator
Subsystems (3)
T Pratham
maintainerv4 cover Add support for Texas Instruments DTHE V2 crypto accelerator
This series adds support for TI DTHE V2 crypto accelerator. DTHE V2 is a new crypto accelerator which contains multiple crypto IPs [1]. This series implements support for ECB and CBC modes of AES for the AES Engine of the DTHE, using skcipher APIs of the kernel.
Tested with:CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not setCONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y
and tcrypt,
sudo modprobe tcrypt mode=500 sec=1
---
[1]: Section 14.6.3 (DMA Control Registers -> DMASS_DTHE)
Change log:
v4:
- Corrected dt-bindings example indentation
- Simplified dt-bindings example, removing the node surrounding crypto
- Fixed typo in dthev2-common.h header guard
- Removed unused ctx field in dev_data struct
- Moved per-op data into request context
v3:
- Corrected dt-bindings reg length is too long error
- Converted AES driver code to use crypto_engine APIs for using internal crypto queue instead of mutex.
- Removed calls to skcipher_request_complete in paths not returning -EINPROGRESS before.
- Added missing KConfig import, which was accidentally removed in v2.
v2:
- Corrected dt-bindings syntax errors and other review comments in v1.
- Completely changed driver code structure, splitting code into multiple files
Link to previous versions:
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
---
T Pratham (2):
dt-bindings: crypto: Add binding for TI DTHE V2
crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
.../bindings/crypto/ti,am62l-dthev2.yaml | 50 ++ MAINTAINERS | 7 + drivers/crypto/Kconfig | 1 + drivers/crypto/Makefile | 1 + drivers/crypto/ti/Kconfig | 13 + drivers/crypto/ti/Makefile | 3 + drivers/crypto/ti/dthev2-aes.c | 428 ++++++++++++++++++ drivers/crypto/ti/dthev2-common.c | 220 +++++++++ drivers/crypto/ti/dthev2-common.h | 111 +++++ 9 files changed, 834 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml create mode 100644 drivers/crypto/ti/Kconfig create mode 100644 drivers/crypto/ti/Makefile create mode 100644 drivers/crypto/ti/dthev2-aes.c create mode 100644 drivers/crypto/ti/dthev2-common.c create mode 100644 drivers/crypto/ti/dthev2-common.h
Signature · 1 line
2.43.0
T Pratham
maintainerPATCH v4 1/2 dt-bindings: crypto: Add binding for TI DTHE V2
Add DT binding for Texas Instruments DTHE V2 crypto accelerator.
DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.
--- .../bindings/crypto/ti,am62l-dthev2.yaml | 50 +++++++++++++++++++ MAINTAINERS | 6 +++ 2 files changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml
Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml new file +50 -0
@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/ti,am62l-dthev2.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: K3 SoC DTHE V2 crypto module + +maintainers: + - T Pratham <[email protected]> + +properties: + compatible: + enum: + - ti,am62l-dthev2 + + reg: + maxItems: 1 + + dmas: + items: + - description: AES Engine RX DMA Channel + - description: AES Engine TX DMA Channel + - description: SHA Engine TX DMA Channel + + dma-names: + items: + - const: rx + - const: tx1 + - const: tx2 + +required: + - compatible + - reg + - dmas + - dma-names + +additionalProperties: false + +examples: + - | + crypto@40800000 { + compatible = "ti,am62l-dthev2"; + reg = <0x40800000 0x10000>; + + dmas = <&main_bcdma 0 0 0x4700 0>, + <&main_bcdma 0 0 0xc701 0>, + <&main_bcdma 0 0 0xc700 0>; + dma-names = "rx", "tx1", "tx2"; + };
MAINTAINERS +6 -0
@@ -24552,6 +24552,12 @@ S: Odd Fixes F: drivers/clk/ti/ F: include/linux/clk/ti.h +TI DATA TRANSFORM AND HASHING ENGINE (DTHE) V2 CRYPTO ACCELERATOR DRIVER +M: T Pratham <[email protected]> +L: [email protected] +S: Supported +F: Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml + TI DAVINCI MACHINE SUPPORT M: Bartosz Golaszewski <[email protected]> L: [email protected] (moderated for non-subscribers)
Signature · 1 line
2.43.0
Re: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2
Quoted 6 lines · T Pratham
Add DT binding for Texas Instruments DTHE V2 crypto accelerator.
DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.
Signed-off-by T Pratham <[email protected]>
Best regards,
Krzysztof
Rob Herring (Arm)
maintainerRe: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2
In reply to T PrathamQuoted 5 lines · T Pratham
Add DT binding for Texas Instruments DTHE V2 crypto accelerator.
DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.
Quoted 7 lines
Signed-off-by T Pratham <[email protected]>--- .../bindings/crypto/ti,am62l-dthev2.yaml | 50 +++++++++++++++++++ MAINTAINERS | 6 +++ 2 files changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
T Pratham
maintainerRe: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2
Quoted 17 lines · Rob Herring (Arm)
Quoted 5 lines · T Pratham
Add DT binding for Texas Instruments DTHE V2 crypto accelerator.
DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.
Quoted 7 lines
Signed-off-by T Pratham <[email protected]>--- .../bindings/crypto/ti,am62l-dthev2.yaml | 50 +++++++++++++++++++ MAINTAINERS | 6 +++ 2 files changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yamlMy bot found errors running 'make
dt_binding_check' on your patch:
Quoted 9 lines
yamllint warnings/errors:
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
Hi, the error logs here are empty. What does this mean (error, no error)?
Also, I ran make dt_binding_check locally and did not see any errors. Below dependencies are installed and up to date.
Quoted 7 lines
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
Quoted 6 lines
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that
DT_SCHEMA_FILEScan be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Regards
T Pratham <[email protected]>
Re: [PATCH v4 1/2] dt-bindings: crypto: Add binding for TI DTHE V2
Quoted 23 lines · T Pratham
Quoted 22 lines · Rob Herring (Arm)
Quoted 5 lines · T Pratham
Add DT binding for Texas Instruments DTHE V2 crypto accelerator.
DTHE V2 is introduced as a part of TI AM62L SoC and can currently be only found in it.
Quoted 7 lines
Signed-off-by T Pratham <[email protected]>--- .../bindings/crypto/ti,am62l-dthev2.yaml | 50 +++++++++++++++++++ MAINTAINERS | 6 +++ 2 files changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
Quoted 7 lines
Quoted 4 lines
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
Hi, the error logs here are empty. What does this mean (error, no error)?
Also, I ran
make dt_binding_checklocally and did not see any errors. Below dependencies are installed and up to date.
Probably false-positive. This happens sometimes, sorry for this. Service is provided as is, in good faith.
Best regards,
Krzysztof
T Pratham
maintainerPATCH v4 2/2 crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
In reply to T PrathamAdd support for ECB and CBC modes in the AES Engine of the DTHE V2 hardware crypto accelerator.
--- MAINTAINERS | 1 + drivers/crypto/Kconfig | 1 + drivers/crypto/Makefile | 1 + drivers/crypto/ti/Kconfig | 13 + drivers/crypto/ti/Makefile | 3 + drivers/crypto/ti/dthev2-aes.c | 428 ++++++++++++++++++++++++++++++ drivers/crypto/ti/dthev2-common.c | 220 +++++++++++++++ drivers/crypto/ti/dthev2-common.h | 111 ++++++++ 8 files changed, 778 insertions(+) create mode 100644 drivers/crypto/ti/Kconfig create mode 100644 drivers/crypto/ti/Makefile create mode 100644 drivers/crypto/ti/dthev2-aes.c create mode 100644 drivers/crypto/ti/dthev2-common.c create mode 100644 drivers/crypto/ti/dthev2-common.h
MAINTAINERS +1 -0
@@ -24557,6 +24557,7 @@ M: T Pratham <[email protected]> L: [email protected] S: Supported F: Documentation/devicetree/bindings/crypto/ti,am62l-dthev2.yaml +F: drivers/crypto/ti/ TI DAVINCI MACHINE SUPPORT M: Bartosz Golaszewski <[email protected]>
drivers/crypto/Kconfig +1 -0
@@ -849,5 +849,6 @@ config CRYPTO_DEV_SA2UL source "drivers/crypto/aspeed/Kconfig" source "drivers/crypto/starfive/Kconfig" source "drivers/crypto/inside-secure/eip93/Kconfig" +source "drivers/crypto/ti/Kconfig" endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -48,3 +48,4 @@ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/ obj-y += intel/ obj-y += starfive/ obj-y += cavium/ +obj-$(CONFIG_ARCH_K3) += ti/
drivers/crypto/ti/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +config CRYPTO_DEV_TI_DTHEV2 + tristate "Support for TI DTHE V2 crypto accelerators" + depends on CRYPTO && CRYPTO_HW && ARCH_K3 + select CRYPTO_ENGINE + select CRYPTO_SKCIPHER + select CRYPTO_ECB + select CRYPTO_CBC + help + This enables support for the TI DTHE V2 hw crypto accelerator + which can be found on TI K3 SOCs. Selecting this enables use + of hardware acceleration for cryptographic algorithms on + these devices.
drivers/crypto/ti/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_CRYPTO_DEV_TI_DTHEV2) += dthev2.o +dthev2-objs := dthev2-common.o dthev2-aes.o
drivers/crypto/ti/dthev2-aes.c new file +428 -0
428 lines not on this page · raw message
drivers/crypto/ti/dthev2-common.c new file +220 -0
220 lines not on this page · raw message
drivers/crypto/ti/dthev2-common.h new file +111 -0
111 lines not on this page · raw message
Signature · 1 line
2.43.0
Herbert Xu
maintainerRe: [PATCH v4 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
Quoted 5 lines · T Pratham
drivers/crypto/ti/dthev2-aes.c new file +4
-0+static int dthe_cipher_init_tfm (struct crypto_skcipher *tfm) +{ +struct dthe_tfm_ctx *ctx =crypto_skcipher_ctx (tfm); +struct dthe_data *dev_data =dthe_get_dev (ctx);
drivers/crypto/ti/dthev2-aes.c line 93
Quoted 10 lines
drivers/crypto/ti/dthev2-aes.c new file +10
-0+ +void __iomem *aes_base_reg = dev_data->regs +DTHE_P_AES_BASE ; +u32 aes_irqenable_val =readl_relaxed (aes_base_reg +DTHE_P_AES_IRQENABLE ); +u32 aes_sysconfig_val =readl_relaxed (aes_base_reg +DTHE_P_AES_SYSCONFIG ); + +memzero_explicit (ctx,sizeof (*ctx)); + ctx->dev_data = dev_data; + ctx->ctx_info.aes_ctx =kzalloc (sizeof (*ctx->ctx_info.aes_ctx),GFP_KERNEL ); +if (!ctx->ctx_info.aes_ctx) +return -ENOMEM ;
The ctx_info union should just become part of ctx instead of a separate allocation.
drivers/crypto/ti/dthev2-aes.c line 95
Quoted 1 line
drivers/crypto/ti/dthev2-aes.c new file +1
-0+crypto_skcipher_set_reqsize (tfm,sizeof (struct dthe_aes_req_ctx ));
Please set cra_reqsize instead in the algorithm.
drivers/crypto/ti/dthev2-aes.c line 101
Quoted 5 lines
drivers/crypto/ti/dthev2-aes.c new file +5
-0+ aes_sysconfig_val |=DTHE_AES_SYSCONFIG_DMA_DATA_IN_OUT_EN ; +writel_relaxed (aes_sysconfig_val, aes_base_reg +DTHE_P_AES_SYSCONFIG ); + + aes_irqenable_val |=DTHE_AES_IRQENABLE_EN_ALL ; +writel_relaxed (aes_irqenable_val, aes_base_reg +DTHE_P_AES_IRQENABLE );
This does not look right. The tfm allocation happens once for each key, and they could be done concurrently. You should not be operating on the hardware in the init_tfm function.
Cheers,
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