Skip to content

Commit

Permalink
crypto: ccp - Release dma channels before dmaengine unrgister
Browse files Browse the repository at this point in the history
A warning is shown during shutdown,

__dma_async_device_channel_unregister called while 2 clients hold a reference
WARNING: CPU: 15 PID: 1 at drivers/dma/dmaengine.c:1110
__dma_async_device_channel_unregister

Call dma_release_channel for occupied channles
before dma_async_device_unregister.

Fixes: 4cbe9bc ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
Signed-off-by: Koba Ko <koba.ko@canonical.com>
  • Loading branch information
Kobatw authored and intel-lab-lkp committed Aug 30, 2022
1 parent a9a98d4 commit 5aa373b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/crypto/ccp/ccp-dmaengine.c
Expand Up @@ -641,6 +641,10 @@ static void ccp_dma_release(struct ccp_device *ccp)
for (i = 0; i < ccp->cmd_q_count; i++) {
chan = ccp->ccp_dma_chan + i;
dma_chan = &chan->dma_chan;

if (dma_chan->client_count)
dma_release_channel(dma_chan);

tasklet_kill(&chan->cleanup_tasklet);
list_del_rcu(&dma_chan->device_node);
}
Expand Down Expand Up @@ -762,12 +766,14 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
void ccp_dmaengine_unregister(struct ccp_device *ccp)
{
struct dma_device *dma_dev = &ccp->dma_dev;
struct dma_chan *dma_chan;
unsigned int i;

if (!dmaengine)
return;

dma_async_device_unregister(dma_dev);
ccp_dma_release(ccp);
dma_async_device_unregister(dma_dev);

kmem_cache_destroy(ccp->dma_desc_cache);
kmem_cache_destroy(ccp->dma_cmd_cache);
Expand Down

0 comments on commit 5aa373b

Please sign in to comment.