linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ovidiu Panait <ovidiu.panait.oss@gmail.com>
To: T Pratham <t-pratham@ti.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	Kamlesh Gurudasani <kamlesh@ti.com>,
	Manorit Chawdhry <m-chawdhry@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Praneeth Bajjuri <praneeth@ti.com>,
	Vishal Mahaveer <vishalm@ti.com>,
	Kavitha Malarvizhi <k-malarvizhi@ti.com>
Subject: Re: [PATCH v6 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
Date: Tue, 19 Aug 2025 12:56:50 +0300	[thread overview]
Message-ID: <e40d056b-731d-4e33-9347-20c0a7665ede@gmail.com> (raw)
In-Reply-To: <20250819065844.3337101-3-t-pratham@ti.com>

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@ti.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

  reply	other threads:[~2025-08-19  9:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19  6:12 [PATCH v6 0/2] Add support for Texas Instruments DTHEv2 Crypto Engine T Pratham
2025-08-19  6:12 ` [PATCH v6 1/2] dt-bindings: crypto: Add binding for TI DTHE V2 T Pratham
2025-08-20  7:43   ` Krzysztof Kozlowski
2025-08-20  8:52     ` T Pratham
2025-08-19  6:12 ` [PATCH v6 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) T Pratham
2025-08-19  9:56   ` Ovidiu Panait [this message]
2025-08-20  8:58     ` T Pratham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e40d056b-731d-4e33-9347-20c0a7665ede@gmail.com \
    --to=ovidiu.panait.oss@gmail.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=k-malarvizhi@ti.com \
    --cc=kamlesh@ti.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-chawdhry@ti.com \
    --cc=praneeth@ti.com \
    --cc=t-pratham@ti.com \
    --cc=vigneshr@ti.com \
    --cc=vishalm@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).