[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e40d056b-731d-4e33-9347-20c0a7665ede@gmail.com>
Date: Tue, 19 Aug 2025 12:56:50 +0300
From: Ovidiu Panait <ovidiu.panait.oss@...il.com>
To: T Pratham <t-pratham@...com>, Herbert Xu <herbert@...dor.apana.org.au>,
"David S . Miller" <davem@...emloft.net>
Cc: linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
Kamlesh Gurudasani <kamlesh@...com>, Manorit Chawdhry <m-chawdhry@...com>,
Vignesh Raghavendra <vigneshr@...com>, Praneeth Bajjuri <praneeth@...com>,
Vishal Mahaveer <vishalm@...com>, Kavitha Malarvizhi <k-malarvizhi@...com>
Subject: Re: [PATCH v6 2/2] crypto: ti: Add driver for DTHE V2 AES Engine
(ECB, CBC)
Hi,
On 8/19/25 9:12 AM, T Pratham wrote:
> Add support for ECB and CBC modes in the AES Engine of the DTHE V2
> hardware cryptography engine.
>
> Signed-off-by: T Pratham <t-pratham@...com>
> ---
> MAINTAINERS | 1 +
> drivers/crypto/Kconfig | 1 +
> drivers/crypto/Makefile | 1 +
> drivers/crypto/ti/Kconfig | 14 +
> drivers/crypto/ti/Makefile | 3 +
> drivers/crypto/ti/dthev2-aes.c | 411 ++++++++++++++++++++++++++++++
> drivers/crypto/ti/dthev2-common.c | 220 ++++++++++++++++
> drivers/crypto/ti/dthev2-common.h | 101 ++++++++
> 8 files changed, 752 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
>
[...]
> +static int dthe_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct dthe_data *dev_data;
> + int ret;
> +
> + dev_data = devm_kzalloc(dev, sizeof(*dev_data), GFP_KERNEL);
> + if (!dev_data)
> + return -ENOMEM;
> +
> + dev_data->dev = dev;
> + dev_data->regs = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(dev_data->regs))
> + return PTR_ERR(dev_data->regs);
> +
> + platform_set_drvdata(pdev, dev_data);
> +
> + spin_lock(&dthe_dev_list.lock);
> + list_add(&dev_data->list, &dthe_dev_list.dev_list);
> + spin_unlock(&dthe_dev_list.lock);
> +
> + ret = dthe_dma_init(dev_data);
> + if (ret)
> + goto probe_dma_err;
> +
> + dev_data->engine = crypto_engine_alloc_init(dev, 1);
> + if (!dev_data->engine) {
> + ret = -ENOMEM;
> + goto probe_engine_err;
> + }
> +
> + ret = crypto_engine_start(dev_data->engine);
> + if (ret) {
> + dev_err(dev, "Failed to start crypto engine\n");
> + goto probe_engine_start_err;
> + }
> +
> + ret = dthe_register_algs();
> + if (ret) {
> + dev_err(dev, "Failed to register algs\n");
> + goto probe_reg_err;
> + }
> +
> + return 0;
> +
> +probe_reg_err:
> + crypto_engine_stop(dev_data->engine);
> +probe_engine_start_err:
> + crypto_engine_exit(dev_data->engine);
crypto_engine_exit() calls crypto_engine_stop() internally, so there is
no need to call both functions here. Just use crypto_engine_exit().
/**
* crypto_engine_exit - free the resources of hardware engine when exit
* @engine: the hardware engine need to be freed
*/
void crypto_engine_exit(struct crypto_engine *engine)
{
int ret;
ret = crypto_engine_stop(engine);
if (ret)
return;
kthread_destroy_worker(engine->kworker);
}
> +probe_engine_err:
> + dma_release_channel(dev_data->dma_aes_rx);
> + dma_release_channel(dev_data->dma_aes_tx);
> + dma_release_channel(dev_data->dma_sha_tx);
> +probe_dma_err:
> + spin_lock(&dthe_dev_list.lock);
> + list_del(&dev_data->list);
> + spin_unlock(&dthe_dev_list.lock);
> +
> + return ret;
> +}
> +
> +static void dthe_remove(struct platform_device *pdev)
> +{
> + struct dthe_data *dev_data = platform_get_drvdata(pdev);
> +
> + spin_lock(&dthe_dev_list.lock);
> + list_del(&dev_data->list);
> + spin_unlock(&dthe_dev_list.lock);
> +
> + dthe_unregister_algs();
> +
> + crypto_engine_stop(dev_data->engine);
> + crypto_engine_exit(dev_data->engine);
> +
Same here.
> + dma_release_channel(dev_data->dma_aes_rx);
> + dma_release_channel(dev_data->dma_aes_tx);
> + dma_release_channel(dev_data->dma_sha_tx);
> +}
Ovidiu
Powered by blists - more mailing lists