All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Allen <john.allen@amd.com>
To: "Dāvis Mosāns" <davispuh@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Tom Lendacky <thomas.lendacky@amd.com>,
	linux-crypto@vger.kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH] ccp: ccp_dmaengine_unregister release dma channels
Date: Tue, 1 Mar 2022 15:07:56 -0600	[thread overview]
Message-ID: <Yh6LLFAf+f48BBFa@dell9853host> (raw)
In-Reply-To: <20220228031545.11639-1-davispuh@gmail.com>

On Mon, Feb 28, 2022 at 05:15:45AM +0200, Dāvis Mosāns wrote:
> ccp_dmaengine_register adds dma_chan->device_node to dma_dev->channels list
> but ccp_dmaengine_unregister didn't remove them.
> That can cause crashes in various dmaengine methods that tries to use dma_dev->channels
> 
> Signed-off-by: Dāvis Mosāns <davispuh@gmail.com>

Acked-by: John Allen <john.allen@amd.com>

> ---
>  drivers/crypto/ccp/ccp-dmaengine.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
> index d718db224be42..7d4b4ad1db1f3 100644
> --- a/drivers/crypto/ccp/ccp-dmaengine.c
> +++ b/drivers/crypto/ccp/ccp-dmaengine.c
> @@ -632,6 +632,20 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)
>  	return 0;
>  }
>  
> +static void ccp_dma_release(struct ccp_device *ccp)
> +{
> +	struct ccp_dma_chan *chan;
> +	struct dma_chan *dma_chan;
> +	unsigned int i;
> +
> +	for (i = 0; i < ccp->cmd_q_count; i++) {
> +		chan = ccp->ccp_dma_chan + i;
> +		dma_chan = &chan->dma_chan;
> +		tasklet_kill(&chan->cleanup_tasklet);
> +		list_del_rcu(&dma_chan->device_node);
> +	}
> +}
> +
>  int ccp_dmaengine_register(struct ccp_device *ccp)
>  {
>  	struct ccp_dma_chan *chan;
> @@ -736,6 +750,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
>  	return 0;
>  
>  err_reg:
> +	ccp_dma_release(ccp);
>  	kmem_cache_destroy(ccp->dma_desc_cache);
>  
>  err_cache:
> @@ -752,6 +767,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
>  		return;
>  
>  	dma_async_device_unregister(dma_dev);
> +	ccp_dma_release(ccp);
>  
>  	kmem_cache_destroy(ccp->dma_desc_cache);
>  	kmem_cache_destroy(ccp->dma_cmd_cache);
> -- 
> 2.35.1
> 

  reply	other threads:[~2022-03-01 21:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28  3:15 [PATCH] ccp: ccp_dmaengine_unregister release dma channels Dāvis Mosāns
2022-03-01 21:07 ` John Allen [this message]
2022-03-09  3:21 ` Herbert Xu

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=Yh6LLFAf+f48BBFa@dell9853host \
    --to=john.allen@amd.com \
    --cc=davispuh@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.lendacky@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.