Add support for Texas Instruments DTHE V2 crypto accelerator
Subsystems (5)
T Pratham
maintainerv3 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:
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:
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 driver
crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
.../devicetree/bindings/crypto/ti,dthev2.yaml | 55 +++ 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 | 414 ++++++++++++++++++ drivers/crypto/ti/dthev2-common.c | 220 ++++++++++ drivers/crypto/ti/dthev2-common.h | 110 +++++ 9 files changed, 824 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,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 v3 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.
--- .../devicetree/bindings/crypto/ti,dthev2.yaml | 55 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,dthev2.yaml
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml new file +55 -0
@@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/ti,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: + - | + cbass_main { + #address-cells = <2>; + #size-cells = <2>; + + crypto@40800000 { + compatible = "ti,am62l-dthev2"; + reg = <0x00 0x40800000 0x00 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
@@ -24445,6 +24445,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,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 v3 1/2] dt-bindings: crypto: Add binding for TI DTHE V2
Quoted 8 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]>--- .../devicetree/bindings/crypto/ti,dthev2.yaml | 55 +++++++++++++++++++
Filename: nothing improved.
Quoted 42 lines
MAINTAINERS | 6 ++ 2 files changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/ti,dthev2.yamlDocumentation/devicetree/bindings/crypto/ti,dthev2.yaml new file +32
-0@@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/ti,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:
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml new file +10
-0+ - compatible + - reg + - dmas + - dma-names + +additionalProperties: false + +examples: + - | + cbass_main {
soc or whatever is reasonable, but follow DTS coding style.
I already asked to match coding style, although about wrapping :/
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml line 52
Quoted 10 lines
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml new file +10
-0+ #address-cells = <2>; + #size-cells = <2>; + + crypto@40800000 { + compatible = "ti,am62l-dthev2"; + reg = <0x00 0x40800000 0x00 0x10000>; + + dmas = <&main_bcdma 0 0 0x4700 0>, + <&main_bcdma 0 0 0xc701 0>, + <&main_bcdma 0 0 0xc700 0>;
Looks misaligned, again, see DTS coding style
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml line 54
Quoted 2 lines
Documentation/devicetree/bindings/crypto/ti,dthev2.yaml new file +2
-0+ dma-names = "rx", "tx1", "tx2"; + };
Best regards,
Krzysztof
T Pratham
maintainerPATCH v3 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 | 414 ++++++++++++++++++++++++++++++ drivers/crypto/ti/dthev2-common.c | 220 ++++++++++++++++ drivers/crypto/ti/dthev2-common.h | 110 ++++++++ 8 files changed, 763 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
@@ -24450,6 +24450,7 @@ M: T Pratham <[email protected]> L: [email protected] S: Supported F: Documentation/devicetree/bindings/crypto/ti,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 +414 -0
414 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 +110 -0
110 lines not on this page · raw message
Signature · 1 line
2.43.0
Herbert Xu
maintainerRe: [PATCH v3 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
Quoted 8 lines · T Pratham
drivers/crypto/ti/dthev2-aes.c new file +7
-0+static int dthe_aes_crypt (struct skcipher_request *req,int enc) +{ +struct dthe_tfm_ctx *ctx =crypto_skcipher_ctx (crypto_skcipher_reqtfm (req)); +struct dthe_data *dev_data =dthe_get_dev (ctx); +struct crypto_engine *engine; + +/*
drivers/crypto/ti/dthev2-aes.c line 345
Quoted 10 lines
drivers/crypto/ti/dthev2-aes.c new file +10
-0+* If data is not a multiple of AES_BLOCK_SIZE, need to return -EINVAL +* If data length input is zero, no need to do any operation. +*/ +if (req->cryptlen %AES_BLOCK_SIZE ) +return -EINVAL ; + +if (req->cryptlen ==0 ) +return 0 ; + + ctx->ctx_info.aes_ctx->enc = enc;
You can't modify crypto_skcipher_ctx as a tfm is shared between multiple request objects. If you need to keep track of the operation, it needs to go into the request context (skcipher_request_ctx).
As a general rule, crypto_skcipher_ctx should only be used to store key-related information and it can only be modifeid by setkey.
Anything that is per-op should go into the request context.
Quoted 13 lines
drivers/crypto/ti/dthev2-common.h new file +13
-0+/** +* struct dthe_data - DTHE_V2 driver instance data +* @dev: Device pointer +* @regs: Base address of the register space +* @list: list node for dev +* @engine: Crypto engine instance +* @dma_aes_rx: AES Rx DMA Channel +* @dma_aes_tx: AES Tx DMA Channel +* @dma_sha_tx: SHA Tx DMA Channel +* @ctx: Transform context struct +*/ +struct dthe_data { +struct device *dev;
drivers/crypto/ti/dthev2-common.h line 62
Quoted 10 lines
drivers/crypto/ti/dthev2-common.h new file +10
-0+void __iomem *regs; +struct list_head list; +struct crypto_engine *engine; + +struct dma_chan *dma_aes_rx; +struct dma_chan *dma_aes_tx; + +struct dma_chan *dma_sha_tx; + +struct dthe_tfm_ctx *ctx;
What's this field for? It doesn't seem to be used at all.
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
kernel test robot
build botRe: [PATCH v3 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
In reply to T Prathamkernel test robot noticed the following build warnings:
Hi Pratham,
kernel test robot noticed the following build warnings:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on next-20250505]
[cannot apply to herbert-crypto-2.6/master robh/for-next linus/master v6.15-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/T-Pratham/dt-bindings-crypto-Add-binding-for-TI-DTHE-V2/20250502-201653 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/20250502121253.456974-4-t-pratham%40ti.com patch subject: [PATCH v3 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20250505/[email protected]/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250505/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/crypto/ti/dthev2-common.c:15:
>> drivers/crypto/ti/dthev2-common.h:9:9: warning: '__TI_DTHEV2_H__' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]
9 | #ifndef __TI_DTHEV2_H__
| ^~~~~~~~~~~~~~~
drivers/crypto/ti/dthev2-common.h:10:9: note: '__TI_DTHE2V_H__' is defined here; did you mean '__TI_DTHEV2_H__'?
10 | #define __TI_DTHE2V_H__
| ^~~~~~~~~~~~~~~
| __TI_DTHEV2_H__1 warning generated.
vim +/__TI_DTHEV2_H__ +9 drivers/crypto/ti/dthev2-common.h
> 9 #ifndef __TI_DTHEV2_H__
10 #define __TI_DTHE2V_H__
11 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki