dt-bindings: accel: add device tree for AMD PKI accelerator
Subsystems (6)
PATCH v2 1/3 dt-bindings: accel: add device tree for AMD PKI accelerator
Add binding documentation for AMD PKI accelerator supported for AMD versal-net SoC.
AMD PKI accelerator is a device on AMD versa-net SoC to execute public key asymmetric crypto operations like ECDSA, ECDH, RSA etc. with high performance. The driver provides accel interface to applications for configuring the device and performing the required operations. AMD PKI device comprises of multiple Barco Silex ba414 PKI engines bundled together, and providing a queue based interface to interact with the device.
+------------------+
| Software |
+------------------+
| |
| v
| +-----------------------------------------------------------+
| | RAM |
| | +----------------------------+ +---------------------+ |
| | | RQ pages | | CQ pages | |
| | | +------------------------+ | | +-----------------+ | |
| | | | START (cmd) | | | | req_id | status | | |
| | | | TFRI (addr, sz)---+ | | | | req_id | status | | |
| | | | +-TFRO (addr, sz) | | | | | ... | | |
| | | | | NTFY (req_id) | | | | +-----------------+ | |
| | | +-|-------------------|--+ | | | |
| | | | v | +---------------------+ |
| | | | +-----------+ | |
| | | | | input | | |
| | | | | data | | |
| | | v +-----------+ | |
| | | +----------------+ | |
| | | | output data | | |
| | | +----------------+ | |
| | +----------------------------+ |
| | |
| +-----------------------------------------------------------+
|
|
+---|----------------------------------------------------+
| v AMD PKI device |
| +-------------------+ +------------------------+ |
| | New request FIFO | --> | PK engines | |
| +-------------------+ +------------------------+ |
+--------------------------------------------------------+To perform a crypto operation, the software writes a sequence of descriptors, into the RQ memory. This includes input data and designated location for the output data. After preparing the request, request offset (from the RQ memory region) is written into the NEW_REQUEST register. Request is then stored in a common hardware FIFO shared among all RQs.
When a PK engine becomes available, device pops the request from the FIFO and fetches the descriptors. It DMAs the input data from RQ memory and executes the necessary computations. After computation is complete, the device writes output data back to RAM via DMA. Device then writes a new entry in CQ ring buffer in RAM, indicating completion of the request. Device also generates an interrupt for notifying completion to the software.
---
The patch series was originally submitted as misc driver:
https://lore.kernel.org/all/[email protected]/
As suggested by Greg, the driver does not fit in misc and should be part of accel or crypto. Accel is well suited for AMD PKI Crypto Accelerator, and thus the driver is updated as an accel driver and yaml moved to newly created accel folder.
Changes RFC->v2:
- updated device tree documentation to be the first patch
- fixed subject
- added documentation in commit log
- fixed compatible string providing correct prefix and SoC
- updated description to be more elaborative, providing datasheet link
- fixed the example
.../bindings/accel/amd,versal-net-pki.yaml | 58 +++++++++++++++++++ MAINTAINERS | 8 +++ 2 files changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +58 -0
@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/accel/amd,versal-net-pki.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMD PKI accelerator device + +maintainers: + - Nipun Gupta <[email protected]> + - Praveen Jain <[email protected]> + +description: | + AMD PKI accelerator handles the public key asymmetric crypto operations. + The driver provides accel interface to the application for configuring the + device and performing the required operations. AMD PKI device comprises of + multiple Barco Silex ba414 PKI engines bundled together, and providing a + queue based interface to interact with these devices on AMD versal-net SoC. + + Link to ba414 datasheet: + https://datasheet.datasheetarchive.com/originals/crawler/barco-silex.com/34b540b9dc5db40c5bc01999401cf1e4.pdf + +properties: + compatible: + const: amd,versal-net-pki + + reg: + description: AMD PKI register space + maxItems: 1 + + interrupts: + maxItems: 1 + + iommus: true + +required: + - compatible + - reg + - interrupts + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + bus { + #address-cells = <2>; + #size-cells = <2>; + + amdpk@20400000000 { + compatible = "amd,versal-net-pki"; + interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>; + reg = <0x204 0x00000000 0x0 0x10000>; + iommus = <&smmu 0x25b>; + }; + };
MAINTAINERS +8 -0
@@ -1154,6 +1154,14 @@ F: Documentation/networking/device_drivers/ethernet/amd/pds_core.rst F: drivers/net/ethernet/amd/pds_core/ F: include/linux/pds/ +AMD PKI DRIVER +M: Nipun Gupta <[email protected]> +M: Praveen Jain <[email protected]> +L: [email protected] +S: Maintained +T: git https://gitlab.freedesktop.org/drm/misc/kernel.git +F: Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml + AMD PMC DRIVER M: Shyam Sundar S K <[email protected]> L: [email protected]
--
2.34.1
PATCH v2 2/3 accel/amdpk: add driver for AMD PKI accelerator
The AMD PKI accelerator driver provides a accel interface to interact with the device for offloading and accelerating asymmetric crypto operations.
---
Changes RFC->v2:
- moved from misc to accel
- added architecture and compile test dependency in Kconfig
- removed sysfs (and added debugfs in new patch 3/3)
- fixed platform compat
- removed redundant resource index 1 configuration (which was there in RFC patch)
MAINTAINERS | 2 + drivers/accel/Kconfig | 1 + drivers/accel/Makefile | 1 + drivers/accel/amdpk/Kconfig | 18 + drivers/accel/amdpk/Makefile | 8 + drivers/accel/amdpk/amdpk_drv.c | 736 ++++++++++++++++++++++++++++++++ drivers/accel/amdpk/amdpk_drv.h | 271 ++++++++++++ include/uapi/drm/amdpk.h | 49 +++ 8 files changed, 1086 insertions(+) create mode 100644 drivers/accel/amdpk/Kconfig create mode 100644 drivers/accel/amdpk/Makefile create mode 100644 drivers/accel/amdpk/amdpk_drv.c create mode 100644 drivers/accel/amdpk/amdpk_drv.h create mode 100644 include/uapi/drm/amdpk.h
MAINTAINERS +2 -0
@@ -1161,6 +1161,8 @@ L: [email protected] S: Maintained T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml +F: drivers/accel/amdpk/ +F: include/uapi/drm/amdpk.h AMD PMC DRIVER M: Shyam Sundar S K <[email protected]>
drivers/accel/Kconfig +1 -0
@@ -28,5 +28,6 @@ source "drivers/accel/amdxdna/Kconfig" source "drivers/accel/habanalabs/Kconfig" source "drivers/accel/ivpu/Kconfig" source "drivers/accel/qaic/Kconfig" +source "drivers/accel/amdpk/Kconfig" endif
drivers/accel/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_ACCEL_AMDXDNA) += amdxdna/ obj-$(CONFIG_DRM_ACCEL_HABANALABS) += habanalabs/ obj-$(CONFIG_DRM_ACCEL_IVPU) += ivpu/ obj-$(CONFIG_DRM_ACCEL_QAIC) += qaic/ +obj-$(CONFIG_DRM_ACCEL_AMDPK) += amdpk/
drivers/accel/amdpk/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for AMD PKI accelerator for versal-net +# + +config DRM_ACCEL_AMDPK + tristate "AMD PKI accelerator for versal-net" + depends on DRM_ACCEL + depends on ARM64 || COMPILE_TEST + help + Enables platform driver for AMD PKI accelerator that are designed + for high performance Public Key asymmetric crypto operations on AMD + versal-net. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called amdpk.
drivers/accel/amdpk/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for AMD PKI accelerator for versal-net +# + +obj-$(CONFIG_DRM_ACCEL_AMDPK) := amdpk.o + +amdpk-y := amdpk_drv.o
drivers/accel/amdpk/amdpk_drv.c new file +736 -0
736 lines not on this page · raw message
drivers/accel/amdpk/amdpk_drv.h new file +271 -0
271 lines not on this page · raw message
include/uapi/drm/amdpk.h new file +49 -0
49 lines not on this page · raw message
--
2.34.1
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 4 lines · Nipun Gupta
The AMD PKI accelerator driver provides a accel interface to interact with the device for offloading and accelerating asymmetric crypto operations.
For me this is clearly a crypto driver and you are supposed to:
1. Cc crypto maintaners,
2. Put it actually into crypto and use crypto API.
Limited review follows.
Quoted 44 lines
Signed-off-by Nipun Gupta <[email protected]>---
Changes
RFC->v2:
- moved from misc to accel
- added architecture and compile test dependency inKconfig
- removed sysfs (and added debugfs in new patch 3/3)
- fixed platform compat
- removed redundant resource index 1 configuration (which was there in RFC patch)MAINTAINERS | 2 + drivers/accel/Kconfig | 1 + drivers/accel/Makefile | 1 + drivers/accel/amdpk/Kconfig | 18 + drivers/accel/amdpk/Makefile | 8 + drivers/accel/amdpk/amdpk_drv.c | 736 ++++++++++++++++++++++++++++++++ drivers/accel/amdpk/amdpk_drv.h | 271 ++++++++++++ include/uapi/drm/amdpk.h | 49 +++ 8 files changed, 1086 insertions(+) create mode 100644 drivers/accel/amdpk/Kconfig create mode 100644 drivers/accel/amdpk/Makefile create mode 100644 drivers/accel/amdpk/amdpk_drv.c create mode 100644 drivers/accel/amdpk/amdpk_drv.h create mode 100644 include/uapi/drm/amdpk.hMAINTAINERS +2
-0@@ -1161,6 +1161,8 @@ L: [email protected] S: Maintained T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml +F: drivers/accel/amdpk/ +F: include/uapi/drm/amdpk.h AMD PMC DRIVER M: Shyam Sundar S K <[email protected]>drivers/accel/Kconfig +0
-0
drivers/accel/Kconfig source "drivers/accel/amdxdna/Kconfig" · line 31
Quoted 4 lines
drivers/accel/Kconfig +1
-0@@ -28,5 +28,6 @@ source "drivers/accel/amdxdna/Kconfig" source "drivers/accel/habanalabs/Kconfig" source "drivers/accel/ivpu/Kconfig" source "drivers/accel/qaic/Kconfig" +source "drivers/accel/amdpk/Kconfig"
Why placing at the end?
drivers/accel/Makefile obj-$(CONFIG_DRM_ACCEL_AMDXDNA) += amdxdna/ · line 7
Quoted 11 lines
drivers/accel/Kconfig +0
-0endifdrivers/accel/Makefile +1
-0@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_ACCEL_AMDXDNA) += amdxdna/ obj-$(CONFIG_DRM_ACCEL_HABANALABS) += habanalabs/ obj-$(CONFIG_DRM_ACCEL_IVPU) += ivpu/ obj-$(CONFIG_DRM_ACCEL_QAIC) += qaic/ +obj-$(CONFIG_DRM_ACCEL_AMDPK) += amdpk/
Did you just add it to the end breaking any ordering? Look, there is already AMD entry in the context.
Quoted 6 lines
drivers/accel/amdpk/Kconfig new file +0
-0
drivers/accel/amdpk/Kconfig line 9
Quoted 9 lines
drivers/accel/amdpk/Kconfig new file +9
-0@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for AMD PKI accelerator for versal-net +# + +config DRM_ACCEL_AMDPK + tristate "AMD PKI accelerator for versal-net" + depends on DRM_ACCEL + depends on ARM64 || COMPILE_TEST
What do you need from arm64? I don't see it from the code at all.
Quoted 9 lines
drivers/accel/amdpk/Kconfig new file +9
-0+ help + Enables platform driver for AMD PKI accelerator that are designed + for high performance Public Key asymmetric crypto operations on AMD + versal-net. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called amdpk.
...
Quoted 15 lines
drivers/accel/amdpk/Kconfig new file +15
-0+static void amdpk_remove_device(struct amdpk_dev *pkdev) +{ + drm_dev_unplug(&pkdev->ddev); + pk_wrreg(pkdev->regs, REG_IRQ_ENABLE, 0); + ida_destroy(&pkdev->avail_queues); +} + +static int amdpk_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct amdpk_dev *pkdev; + struct resource *memres; + int irq, ret; + + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
drivers/accel/amdpk/Kconfig
Quoted 10 lines
drivers/accel/amdpk/Kconfig new file +10
-0+ if (ret < 0) + return ret; + + pkdev = devm_drm_dev_alloc(dev, &amdpk_accel_driver, typeof(*pkdev), ddev); + if (IS_ERR(pkdev)) + return PTR_ERR(pkdev); + pkdev->dev = dev; + + memres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + pkdev->regs = devm_ioremap_resource(dev, memres);
Use wrapper for these two.
drivers/accel/amdpk/Kconfig
Quoted 6 lines
drivers/accel/amdpk/Kconfig new file +6
-0+ if (IS_ERR(pkdev->regs)) + return PTR_ERR(pkdev->regs); + pkdev->regsphys = memres->start; + platform_set_drvdata(pdev, pkdev); + + if (platform_irq_count(pdev) != 1)
Drop, what's the benefit? DT schema ensures you have only one entry.
Quoted 15 lines
drivers/accel/amdpk/Kconfig new file +15
-0+ return -ENODEV; + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return -ENODEV; + + ret = drm_dev_register(&pkdev->ddev, 0); + if (ret) { + dev_err(&pdev->dev, "DRM register failed, ret %d", ret); + return ret; + } + + return amdpk_create_device(pkdev, dev, irq); +} +
drivers/accel/amdpk/Kconfig
Quoted 10 lines
drivers/accel/amdpk/Kconfig new file +10
-0+static void amdpk_remove(struct platform_device *pdev) +{ + struct amdpk_dev *pkdev = platform_get_drvdata(pdev); + + amdpk_remove_device(pkdev); +} + +static void amdpk_shutdown(struct platform_device *pdev) +{ + amdpk_remove(pdev);
I am not sure why this is necessary. Please provide comment WHY you need it. IOW, why do you need to disable IRQ manually here if the entire system is shutting down?
Quoted 28 lines
drivers/accel/amdpk/Kconfig new file +28
-0+} + +static const struct of_device_id amdpk_match_table[] = { + { .compatible = "amd,versal-net-pki" }, + { }, +}; +MODULE_DEVICE_TABLE(of, amdpk_match_table); + +static struct platform_driver amdpk_pdrv = { + .probe = amdpk_probe, + .remove = amdpk_remove, + .shutdown = amdpk_shutdown, + .driver = { + .name = DRIVER_NAME, + .of_match_table = amdpk_match_table, + }, +}; + +static int __init amdpk_init(void) +{ + int ret; + + ret = platform_driver_register(&amdpk_pdrv); + if (ret) { + pr_err("can't register platform driver\n"); + return ret; + } +
drivers/accel/amdpk/Kconfig
Quoted 10 lines
drivers/accel/amdpk/Kconfig new file +10
-0+ return 0; +} + +static void __exit amdpk_exit(void) +{ + platform_driver_unregister(&amdpk_pdrv); +} + +module_init(amdpk_init); +module_exit(amdpk_exit);
Why do you need to open code module_platform_driver?
Best regards,
Krzysztof
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Nipun Gupta
The AMD PKI accelerator driver provides a accel interface to interact with the device for offloading and accelerating asymmetric crypto operations.
For me this is clearly a crypto driver and you are supposed to:
1. Cc crypto maintaners,
2. Put it actually into crypto and use crypto API.
added crypto maintainers for comments.
IMO, as accel framework is designed to support any type of compute
accelerators, the PKI crypto accelerator in accel framework is not completely out of place here, as also suggested at:
https://lore.kernel.org/all/2025031352-gyration-deceit-5563@gregkh/
Having the crypto accelerator as part of accel also enables to extract the most performance from the HW PKI engines, given that the queue assignment is handled per drm device open call.
Regards,
Nipun
Herbert Xu
maintainerRe: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 10 lines · Nipun
added crypto maintainers for comments.
IMO, as accel framework is designed to support any type of compute accelerators, the PKI crypto accelerator in accel framework is not completely out of place here, as also suggested at:
https://lore.kernel.org/all/2025031352-gyration-deceit-5563@gregkh/Having the crypto accelerator as part of accel also enables to extract the most performance from the HW PKI engines, given that the queue assignment is handled per drm device open call.
There is actually a user-space interface for asymmetric crypto through the keyring subsystem. Adding the maintainers of those in case they wish to comment on your driver.
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
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 8 lines · Herbert Xu
Quoted 7 lines · Nipun
added crypto maintainers for comments.
IMO, as accel framework is designed to support any type of compute accelerators, the PKI crypto accelerator in accel framework is not completely out of place here, as also suggested at:
https://lore.kernel.org/all/2025031352-gyration-deceit-5563@gregkh/
Quoted 7 lines
Quoted 3 lines
Having the crypto accelerator as part of accel also enables to extract the most performance from the HW PKI engines, given that the queue assignment is handled per drm device open call.
There is actually a user-space interface for asymmetric crypto through the keyring subsystem. Adding the maintainers of those in case they wish to comment on your driver.
AFAIU after looking into it, the keyring subsystem is not to perform the data operations, but for managing keys for these operations. Kindly correct me if I am wrong here.
Thanks,
Nipun
Herbert Xu
maintainerRe: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 4 lines · Nipun
AFAIU after looking into it, the keyring subsystem is not to perform the data operations, but for managing keys for these operations. Kindly correct me if I am wrong here.
Have a look at
security/keys/keyctl_pkey.c
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
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 9 lines · Herbert Xu
Quoted 4 lines · Nipun
AFAIU after looking into it, the keyring subsystem is not to perform the data operations, but for managing keys for these operations. Kindly correct me if I am wrong here.
Have a look at
security/keys/keyctl_pkey.c
Thanks for pointing out to the C file, but as these these system calls can support only synchronous operations, precludes their use for asynchronous operations. In the TLS handshakes, where multiple connections occur simultaneously, asynchronous operations are beneficial. OpenSSL ASYNC support can very well utilizes the asynchronous operations while establishing multiple TLS connections.
Thanks,
Nipun
Herbert Xu
maintainerRe: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 7 lines · Nipun
Thanks for pointing out to the C file, but as these these system calls can support only synchronous operations, precludes their use for asynchronous operations. In the TLS handshakes, where multiple connections occur simultaneously, asynchronous operations are beneficial. OpenSSL ASYNC support can very well utilizes the asynchronous operations while establishing multiple TLS connections.
In that case we should extend af_alg to support akcipher algorithms.
Having every crypto driver make up its own user-space PKI interface is not scalable.
I held back on adding akcipher to af_alg because it would lead to the freezing of our akcipher API. But it's time to do this.
Being the first user of such an interface, could you please post your OpenSSL patches as well so that we can look at what's actually needed?
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
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
In reply to Gupta, NipunQuoted 11 lines · Nipun
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Nipun Gupta
The AMD PKI accelerator driver provides a accel interface to interact with the device for offloading and accelerating asymmetric crypto operations.
For me this is clearly a crypto driver and you are supposed to:
1. Cc crypto maintaners,
2. Put it actually into crypto and use crypto API.
Quoted 5 lines
added crypto maintainers for comments.
IMO, as accel framework is designed to support any type of compute accelerators, the PKI crypto accelerator in accel framework is not completely out of place here, as also suggested at:
https://lore.kernel.org/all/2025031352-gyration-deceit-5563@gregkh/
To be fair, Greg did suggest drivers/crypto/ as an alternative... :)
"Great, then why isn't this in drivers/accel/ or drivers/crypto/ ?"
https://lore.kernel.org/r/2025031236-siamese-graffiti-5b98@gregkh/
There are already six drivers for crypto accelerators in drivers/crypto/, so that would seem to be a natural fit for your driver:
aspeed/aspeed-acry.c
caam/caampkc.c
ccp/ccp-crypto-rsa.c <-- from AMD no less!
hisilicon/hpre/hpre_crypto.c
intel/qat/qat_common/qat_asym_algs.c
starfive/jh7110-rsa.c
You can find these in the tree with:
git grep 'cra_name = "rsa"'
So far there are only drivers to accelerate RSA encryption/decryption. The kernel supports a single padding scheme, PKCS1, which is implemented by crypto/rsa-pkcs1pad.c. There is no support yet for OAEP.
So the padding of the hash (which is cheap) happens in software and then crypto/rsa-pkcs1pad.c performs an RSA encrypt/decrypt operation which is either performed in software by crypto/rsa.c, or in hardware if a crypto accelerator is present. Drivers for crypto accelerators register the "rsa" algorithm with a higher cra_priority than the software implementation, hence are generally preferred.
One benefit that you get from implementing a proper akcipher_alg in your driver is that virtual machines may take advantage of the hardware accelerator through the virtio support implemented by:drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
Note that the crypto subsystem currently does not support hardware acceleration of signature generation/verification (crypto_sig), but only encryption/decryption (crypto_akcipher). One reason is that signature generation/verification is generally a synchronous operation and doesn't benefit as much from hardware acceleration due to the overhead of interacting with the hardware.
So there's no support e.g. for generating or verifying ECDSA signatures in hardware. I think that would only really make sense if private keys are kept in hardware and cannot be retrieved. So the use case wouldn't be acceleration, but security of private keys.
That said, for RSA specifically, signature generation/verification does involve an encrypt/decrypt operation internally. The padding is once again done in software (by crypto/rsassa-pkcs1.c -- no PSS support yet). But the actual encrypt/decrypt operation will be performed in hardware if a crypto accelerator is present.
The user space interface Herbert referred to is a set of system calls which are usable e.g. via the keyutils library and command line utility:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/
HTH,
Lukas
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Quoted 53 lines · Lukas Wunner
Quoted 11 lines · Nipun
Quoted 9 lines · Krzysztof Kozlowski
Quoted 4 lines · Nipun Gupta
The AMD PKI accelerator driver provides a accel interface to interact with the device for offloading and accelerating asymmetric crypto operations.
For me this is clearly a crypto driver and you are supposed to:
1. Cc crypto maintaners,
2. Put it actually into crypto and use crypto API.Quoted 5 lines
added crypto maintainers for comments.
IMO, as accel framework is designed to support any type of compute accelerators, the PKI crypto accelerator in accel framework is not completely out of place here, as also suggested at:
https://lore.kernel.org/all/2025031352-gyration-deceit-5563@gregkh/To be fair, Greg did suggest
drivers/crypto/as an alternative... :)"Great, then why isn't this in
drivers/accel/ordrivers/crypto/?"
https://lore.kernel.org/r/2025031236-siamese-graffiti-5b98@gregkh/There are already six drivers for crypto accelerators in
drivers/crypto/, so that would seem to be a natural fit for your driver:
aspeed/aspeed-acry.c
caam/caampkc.c
ccp/ccp-crypto-rsa.c<-- from AMD no less!
hisilicon/hpre/hpre_crypto.c
intel/qat/qat_common/qat_asym_algs.c
starfive/jh7110-rsa.cYou can find these in the tree with:
git grep '
cra_name= "rsa"'So far there are only drivers to accelerate RSA encryption/decryption. The kernel supports a single padding scheme, PKCS1, which is implemented by
crypto/rsa-pkcs1pad.c. There is no support yet for OAEP.So the padding of the hash (which is cheap) happens in software and then
crypto/rsa-pkcs1pad.cperforms an RSA encrypt/decrypt operation which is either performed in software bycrypto/rsa.c, or in hardware if a crypto accelerator is present. Drivers for crypto accelerators register the "rsa" algorithm with a highercra_prioritythan the software implementation, hence are generally preferred.One benefit that you get from implementing a proper
akcipher_algin your driver is that virtual machines may take advantage of the hardware accelerator through the virtio support implemented by:drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
Quoted 6 lines
Note that the crypto subsystem currently does not support hardware acceleration of signature generation/verification (
crypto_sig), but only encryption/decryption (crypto_akcipher). One reason is that signature generation/verification is generally a synchronous operation and doesn't benefit as much from hardware acceleration due to the overhead of interacting with the hardware.
Thank you for the feedback.
When establishing TLS connections, OpenSSL requires signature generation/verification. In scenarios where multiple connections occur simultaneously, asynchronous operations are beneficial as they lead to much improved CPU utilization. OpenSSL ASYNC support can very well utilizes the asynchronous operations while establishing multiple TLS connections.
Quoted 5 lines
So there's no support e.g. for generating or verifying ECDSA signatures in hardware. I think that would only really make sense if private keys are kept in hardware and cannot be retrieved. So the use case wouldn't be acceleration, but security of private keys.
While ECDSA signature generation and verification enhance the security of private keys when stored in hardware, they also play important role in the establishment of TLS connections. Offloading these operations to hardware frees up CPU, enhancing performance during TLS handshakes.
Quoted 10 lines
That said, for RSA specifically, signature generation/verification does involve an encrypt/decrypt operation internally. The padding is once again done in software (by
crypto/rsassa-pkcs1.c-- no PSS support yet). But the actual encrypt/decrypt operation will be performed in hardware if a crypto accelerator is present.The user space interface Herbert referred to is a set of system calls which are usable e.g. via the keyutils library and command line utility:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/
These system calls can support only synchronous operations, which precludes their use for asynchronous operations. This limitation prevents the use of keyutils here.
Thanks,
Nipun
Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
In reply to Nipun GuptaQuoted 1 line · Nipun Gupta
The AMD PKI accelerator driver provides a accel interface to interact
"an accel"
Quoted 47 lines
with the device for offloading and accelerating asymmetric crypto operations.
Signed-off-by Nipun Gupta <[email protected]>---
Changes
RFC->v2:
- moved from misc to accel
- added architecture and compile test dependency inKconfig
- removed sysfs (and added debugfs in new patch 3/3)
- fixed platform compat
- removed redundant resource index 1 configuration (which was there in RFC patch)MAINTAINERS | 2 + drivers/accel/Kconfig | 1 + drivers/accel/Makefile | 1 + drivers/accel/amdpk/Kconfig | 18 + drivers/accel/amdpk/Makefile | 8 + drivers/accel/amdpk/amdpk_drv.c | 736 ++++++++++++++++++++++++++++++++ drivers/accel/amdpk/amdpk_drv.h | 271 ++++++++++++ include/uapi/drm/amdpk.h | 49 +++ 8 files changed, 1086 insertions(+)create mode 100644
drivers/accel/amdpk/Kconfigcreate mode 100644drivers/accel/amdpk/Makefilecreate mode 100644drivers/accel/amdpk/amdpk_drv.ccreate mode 100644drivers/accel/amdpk/amdpk_drv.hcreate mode 100644include/uapi/drm/amdpk.hMAINTAINERS +2
-0@@ -1161,6 +1161,8 @@ L: [email protected] S: Maintained T: git https://gitlab.freedesktop.org/drm/misc/kernel.git F: Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml +F: drivers/accel/amdpk/ +F: include/uapi/drm/amdpk.h AMD PMC DRIVER M: Shyam Sundar S K <[email protected]>drivers/accel/Kconfig +0
-0
drivers/accel/Kconfig source "drivers/accel/amdxdna/Kconfig" · line 31
Quoted 4 lines
drivers/accel/Kconfig +1
-0@@ -28,5 +28,6 @@ source "drivers/accel/amdxdna/Kconfig" source "drivers/accel/habanalabs/Kconfig" source "drivers/accel/ivpu/Kconfig" source "drivers/accel/qaic/Kconfig" +source "drivers/accel/amdpk/Kconfig"
Alphabetical order
drivers/accel/Makefile obj-$(CONFIG_DRM_ACCEL_AMDXDNA) += amdxdna/ · line 7
Quoted 11 lines
drivers/accel/Kconfig +0
-0endifdrivers/accel/Makefile +1
-0@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_ACCEL_AMDXDNA) += amdxdna/ obj-$(CONFIG_DRM_ACCEL_HABANALABS) += habanalabs/ obj-$(CONFIG_DRM_ACCEL_IVPU) += ivpu/ obj-$(CONFIG_DRM_ACCEL_QAIC) += qaic/ +obj-$(CONFIG_DRM_ACCEL_AMDPK) += amdpk/
Alphabetical order
drivers/accel/amdpk/amdpk_drv.c line 1
Quoted 7 lines
drivers/accel/amdpk/amdpk_drv.c new file +1
-0@@ -0,0 +1,736 @@ +// SPDX-License-Identifier: GPL-2.0
Deprecated SPDX tag. Checkpatch will catch this.
Quoted 58 lines
drivers/accel/amdpk/amdpk_drv.c new file +58
-0+/* +* Copyright (c) 2018-2021 Silex Insight sa +* Copyright (c) 2018-2021 Beerten Engineering scs +* Copyright (c) 2025 Advanced Micro Devices, Inc. +*/ + +/* +* Device Overview +* =============== +* AMD PKI accelerator is a device on AMD versal-net to execute public +* key asymmetric crypto operations like ECDSA, ECDH, RSA etc. with high +* performance. The driver provides accel interface to applications for +* configuring the device and performing the required operations. AMD PKI +* device comprises of multiple Barco Silex ba414 PKI engines bundled together, +* and providing a queue based interface to interact with these devices on AMD +* versal-net. +* +* Following figure provides the brief overview of the device interface with +* the software: +* +* +------------------+ +* | Software | +* +------------------+ +* | | +* | v +* | +-----------------------------------------------------------+ +* | | RAM | +* | | +----------------------------+ +---------------------+ | +* | | | RQ pages | | CQ pages | | +* | | | +------------------------+ | | +-----------------+ | | +* | | | | START (cmd) | | | | req_id | status | | | +* | | | | TFRI (addr, sz)---+ | | | | req_id | status | | | +* | | | | +-TFRO (addr, sz) | | | | | ... | | | +* | | | | | NTFY (req_id) | | | | +-----------------+ | | +* | | | +-|-------------------|--+ | | | | +* | | | | v | +---------------------+ | +* | | | | +-----------+ | | +* | | | | | input | | | +* | | | | | data | | | +* | | | v +-----------+ | | +* | | | +----------------+ | | +* | | | | output data | | | +* | | | +----------------+ | | +* | | +----------------------------+ | +* | | | +* | +-----------------------------------------------------------+ +* | +* | +* +---|----------------------------------------------------+ +* | v AMD PKI device | +* | +-------------------+ +------------------------+ | +* | | New request FIFO | --> | PK engines | | +* | +-------------------+ +------------------------+ | +* +--------------------------------------------------------+ +* +* To perform a crypto operation, the software writes a sequence of descriptors, +* into the RQ memory. This includes input data and designated location for the +* output data. After preparing the request, request offset (from the RQ memory
drivers/accel/amdpk/amdpk_drv.c line 69
Quoted 10 lines
drivers/accel/amdpk/amdpk_drv.c new file +10
-0+* region) is written into the NEW_REQUEST register. Request is then stored in a +* common hardware FIFO shared among all RQs. +* +* When a PK engine becomes available, device pops the request from the FIFO and +* fetches the descriptors. It DMAs the input data from RQ memory and executes +* the necessary computations. After computation is complete, the device writes +* output data back to RAM via DMA. Device then writes a new entry in CQ ring +* buffer in RAM, indicating completion of the request. Device also generates +* an interrupt for notifying completion to the software. +*/
Feels like this would be better served in Documentation
drivers/accel/amdpk/amdpk_drv.c line 79
Quoted 10 lines
drivers/accel/amdpk/amdpk_drv.c new file +10
-0+ +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/of.h> +#include <linux/dma-mapping.h> +#include <linux/interrupt.h> +#include <linux/delay.h> +#include <linux/eventfd.h> +#include <drm/drm_accel.h> +#include <drm/drm_ioctl.h>
Alphabetical order
Quoted 20 lines
drivers/accel/amdpk/amdpk_drv.c new file +20
-0+ +#include "amdpk_drv.h" + +#define DRIVER_NAME "amdpk" + +static void amdpk_init_cq (struct amdpk_dev *pkdev,struct amdpk_cq *cq, +int szcode,char *base) +{ + cq->pkdev = pkdev; + cq->generation =1 ; + cq->szcode = szcode; + cq->base = (u32 *)base; + cq->tail =0 ; +} + +static int amdpk_pop_cq (struct amdpk_cq *cq,int *rid) +{ +u32 status =CQ_STATUS_VALID ; +unsigned int sz; +u32 completion;
drivers/accel/amdpk/amdpk_drv.c line 109
Quoted 10 lines
drivers/accel/amdpk/amdpk_drv.c new file +10
-0+ + completion = cq->base[cq->tail +1 ]; +if ((completion &CQ_GENERATION_BIT ) != cq->generation) +return CQ_STATUS_INVALID ; + + *rid = (completion >>16 ) &0xffff ; +/* read memory barrier: to avoid a race condition, the status field should +* not be read before the completion generation bit. Otherwise we could +* get stale outdated status data. +*/
Incorrect comment format.
drivers/accel/amdpk/amdpk_drv.c line 110
Quoted 1 line
drivers/accel/amdpk/amdpk_drv.c new file +1
-0+rmb ();
Shouldn't you be using readl()?
Quoted 15 lines
drivers/accel/amdpk/amdpk_drv.c new file +15
-0+ status |= cq->base[cq->tail]; +/* advance completion queue tail */ + cq->tail +=2 ; + sz =1 << (cq->szcode -2 ); +if (cq->tail >= sz) { + cq->tail =0 ; + cq->generation ^=1 ;/* invert generation bit */ + } + +/* evaluate status from the completion queue */ +if (completion &CQ_COMPLETION_BIT ) + status |=CQ_COMPLETION_ERROR ; + +return status; +}
drivers/accel/amdpk/amdpk_drv.c
Quoted 10 lines
drivers/accel/amdpk/amdpk_drv.c new file +10
-0+ +static const struct file_operations amdpk_accel_fops = { + .owner =THIS_MODULE , + .open = accel_open, + .release = drm_release, + .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, + .llseek = noop_llseek, + .mmap = amdpk_accel_mmap, +};
DEFINE_DRM_ACCEL_FOPS ?
Quoted 12 lines
include/uapi/drm/amdpk.h new file +6
-0@@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef __AMDPK_H__
include/uapi/drm/amdpk.h line 16
Quoted 10 lines
include/uapi/drm/amdpk.h new file +10
-0+#define __AMDPK_H__ + +#if defined(__cplusplus) +extern "C" { +#endif + +#define MAX_PK_REQS 256 + +struct amdpk_info { + /** maximum available queue depth */
This doesn't look like valid kerneldoc
include/uapi/drm/amdpk.h line 18
Quoted 2 lines
include/uapi/drm/amdpk.h new file +2
-0+unsigned int avail_qdepth; +};
Doesn't look like this handles compat correctly. Did you read the documentation on creating ioctls?
kernel test robot
build botRe: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
In reply to Nipun Guptakernel test robot noticed the following build errors:
Hi Nipun,
kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on staging/staging-testing staging/staging-next staging/staging-linus linus/master drm-misc/drm-misc-next drm-tip/drm-tip v6.15-rc2 next-20250416] [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/Nipun-Gupta/accel-amdpk-add-driver-for-AMD-PKI-accelerator/20250410-013224 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20250409173033.2261755-2-nipun.gupta%40amd.com patch subject: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator config: x86_64-randconfig-003-20250416 (https://download.01.org/0day-ci/archive/20250416/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250416/[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 errors (new ones prefixed by >>):
>> error: include/uapi/drm/amdpk.h: missing "WITH Linux-syscall-note" for SPDX-License-Identifier
make[3]: *** [scripts/Makefile.headersinst:63: usr/include/drm/amdpk.h] Error 1 shuffle=3983912090 make[3]: Target '__headers' not remade because of errors.
make[2]: *** [Makefile:1375: headers] Error 2 shuffle=3983912090 scripts/kernel-doc: 1: kernel-doc.py: not found
make[3]: *** [scripts/Makefile.build:203: scripts/mod/empty.o] Error 127 shuffle=3983912090 make[3]: *** Deleting file 'scripts/mod/empty.o'
make[3]: Target 'scripts/mod/' not remade because of errors.
make[2]: *** [Makefile:1276: prepare0] Error 2 shuffle=3983912090
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=3983912090
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2 shuffle=3983912090
make: Target 'prepare' not remade because of errors.
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 3/3 accel/amdpk: add debugfs support
In reply to Nipun GuptaAdd debugfs support for AMD PKI accelerator. The debugfs support prints the following:
- Hardware info
- Hardware configuration
- Busy and idle cycles count in the PK engines
- pending requests for each queue
---
Changes RFC->v2:
- this is a new patch which adds debugfs (removed some sysfs which was defined in RFC patch) and added more debugfs information
drivers/accel/amdpk/Makefile | 3 +- drivers/accel/amdpk/amdpk_debugfs.c | 107 ++++++++++++++++++++++++++++ drivers/accel/amdpk/amdpk_drv.c | 1 + drivers/accel/amdpk/amdpk_drv.h | 2 + 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 drivers/accel/amdpk/amdpk_debugfs.c
drivers/accel/amdpk/Makefile +2 -1
@@ -5,4 +5,5 @@ obj-$(CONFIG_DRM_ACCEL_AMDPK) := amdpk.o -amdpk-y := amdpk_drv.o +amdpk-y := amdpk_drv.o \ + amdpk_debugfs.o
drivers/accel/amdpk/amdpk_debugfs.c new file +107 -0
107 lines not on this page · raw message
drivers/accel/amdpk/amdpk_drv.c +1 -0
@@ -678,6 +678,7 @@ static int amdpk_probe(struct platform_device *pdev)dev_err (&pdev->dev,"DRM register failed, ret %d" , ret);return ret; } +amdpk_debugfs_init (pkdev);return amdpk_create_device (pkdev, dev, irq); }
drivers/accel/amdpk/amdpk_drv.h +2 -0
@@ -258,6 +258,8 @@ struct amdpk_user {#define to_amdpk_dev (dev) container_of(dev, struct amdpk_dev, ddev)#define to_amdpk_work (work) container_of(work, struct amdpk_work, cq_work) +void amdpk_debugfs_init (struct amdpk_dev *pkdev); +static void __maybe_unused pk_wrreg (char __iomem *regs,int addr,u64 val) {iowrite64 (val, regs + addr);
--
2.34.1
Quoted 3 lines · Nipun Gupta
Add binding documentation for AMD PKI accelerator supported for AMD versal-net SoC.
A nit, subject: drop second/last, redundant "device tree for". The "dt-bindings" prefix is already stating that these are bindings. See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/Documentation/devicetree/bindings/submitting-patches.rst#L18
You already got this comment...
Quoted 6 lines
AMD PKI accelerator is a device on AMD versa-net SoC to execute public key asymmetric crypto operations like ECDSA, ECDH, RSA etc. with high performance. The driver provides accel interface to applications for configuring the device and performing the required operations. AMD PKI device comprises of multiple Barco Silex ba414 PKI engines bundled together, and providing a queue based interface to interact with the device.
...
Quoted 5 lines
.../bindings/accel/amd,versal-net-pki.yaml | 58 +++++++++++++++++++ MAINTAINERS | 8 +++ 2 files changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml
That's a crypto device, so goes to 'crypto' directory.
Quoted 25 lines
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +18
-0@@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/accel/amd,versal-net-pki.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMD PKI accelerator device + +maintainers: + - Nipun Gupta <[email protected]> + - Praveen Jain <[email protected]> + +description: | + AMD PKI accelerator handles the public key asymmetric crypto operations. + The driver provides accel interface to the application for configuring the + device and performing the required operations. AMD PKI device comprises of + multiple Barco Silex ba414 PKI engines bundled together, and providing a + queue based interface to interact with these devices on AMD versal-net SoC.
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +10
-0+ + Link to ba414 datasheet: + https://datasheet.datasheetarchive.com/originals/crawler/barco-silex.com/34b540b9dc5db40c5bc01999401cf1e4.pdf + +properties: + compatible: + const: amd,versal-net-pki + + reg: + description: AMD PKI register space
Drop description, obvious.
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml line 33
Quoted 5 lines
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +5
-0+ maxItems: 1 + + interrupts: + maxItems: 1 +
And the resets? I understand from previous email that there is a reset controller.
Quoted 9 lines
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +9
-0+ iommus: true + +required: + - compatible + - reg + - interrupts + - iommus + +additionalProperties: false
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml line 52
Quoted 10 lines
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +10
-0+ +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + bus { + #address-cells = <2>; + #size-cells = <2>; + + amdpk@20400000000 {
crypto@
Quoted 11 lines
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +6
-0+ compatible = "amd,versal-net-pki"; + interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>; + reg = <0x204 0x00000000 0x0 0x10000>; + iommus = <&smmu 0x25b>; + }; + };MAINTAINERS +0
-0
MAINTAINERS F: Documentation/networking/device_drivers/ethernet/amd/pds_core.rst · line 1162
Quoted 9 lines
MAINTAINERS +6
-0@@ -1154,6 +1154,14 @@ F: Documentation/networking/device_drivers/ethernet/amd/pds_core.rst F: drivers/net/ethernet/amd/pds_core/ F: include/linux/pds/ +AMD PKI DRIVER +M: Nipun Gupta <[email protected]> +M: Praveen Jain <[email protected]> +L: [email protected] +S: Maintained +T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
Are you going to apply patches to this tree?
Best regards,
Krzysztof
Quoted 6 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml line 33
Quoted 3 lines · Nipun Gupta
Documentation/devicetree/bindings/accel/amd,versal-net-pki.yaml new file +3
-0+ interrupts: + maxItems: 1 +And the resets? I understand from previous email that there is a reset controller.
It was not reset controller, those were register from clock controller which is handled by PDI (Programmable Device Image) at boot. It was mistakenly added there and was not used in the driver (in v1 as well). There is a software reset in the device which is used to reset it.
Regards,
Nipun
On 4/9/2025 11:30 AM, Nipun Gupta wrote:
No cover letter?
Quoted 61 lines
Add binding documentation for AMD PKI accelerator supported for AMD versal-net SoC.
AMD PKI accelerator is a device on AMD versa-net SoC to execute public key asymmetric crypto operations like ECDSA, ECDH, RSA etc. with high performance. The driver provides accel interface to applications for configuring the device and performing the required operations. AMD PKI device comprises of multiple Barco Silex ba414 PKI engines bundled together, and providing a queue based interface to interact with the device.
+------------------+ | Software | +------------------+ | | | v | +-----------------------------------------------------------+ | | RAM | | | +----------------------------+ +---------------------+ | | | | RQ pages | | CQ pages | | | | | +------------------------+ | | +-----------------+ | | | | | | START (cmd) | | | | req_id | status | | | | | | | TFRI (addr, sz)---+ | | | | req_id | status | | | | | | | +-TFRO (addr, sz) | | | | | ... | | | | | | | | NTFY (req_id) | | | | +-----------------+ | | | | | +-|-------------------|--+ | | | | | | | | v | +---------------------+ | | | | | +-----------+ | | | | | | | input | | | | | | | | data | | | | | | v +-----------+ | | | | | +----------------+ | | | | | | output data | | | | | | +----------------+ | | | | +----------------------------+ | | | | | +-----------------------------------------------------------+ | | +---|----------------------------------------------------+ | v AMD PKI device | | +-------------------+ +------------------------+ | | | New request FIFO | --> | PK engines | | | +-------------------+ +------------------------+ | +--------------------------------------------------------+To perform a crypto operation, the software writes a sequence of descriptors, into the RQ memory. This includes input data and designated location for the output data. After preparing the request, request offset (from the RQ memory region) is written into the
NEW_REQUESTregister. Request is then stored in a common hardware FIFO shared among all RQs.When a PK engine becomes available, device pops the request from the FIFO and fetches the descriptors. It DMAs the input data from RQ memory and executes the necessary computations. After computation is complete, the device writes output data back to RAM via DMA. Device then writes a new entry in CQ ring buffer in RAM, indicating completion of the request. Device also generates an interrupt for notifying completion to the software.
Signed-off-by Nipun Gupta <[email protected]>---
Quoted 7 lines
The patch series was originally submitted as misc driver:
https://lore.kernel.org/all/[email protected]/As suggested by Greg, the driver does not fit in misc and should be part of accel or crypto. Accel is well suited for AMD PKI Crypto Accelerator, and thus the driver is updated as an accel driver and yaml moved to newly created accel folder.
Why does this not fit in crypto?