All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister
@ 2022-09-01  2:16 Koba Ko
  2022-09-01 13:42 ` Tom Lendacky
  0 siblings, 1 reply; 5+ messages in thread
From: Koba Ko @ 2022-09-01  2:16 UTC (permalink / raw)
  To: Tom Lendacky, John Allen, Herbert Xu, David S. Miller,
	linux-crypto, linux-kernel

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+0xb7/0xc0

Call dma_release_channel for occupied channles before dma_async_device_unregister.

Fixes: 4cbe9bc34ed0 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Koba Ko <koba.ko@canonical.com>
---
V2: Fix the unused warning
---
 drivers/crypto/ccp/ccp-dmaengine.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
index 7d4b4ad1db1f3..9f753cb4f5f18 100644
--- a/drivers/crypto/ccp/ccp-dmaengine.c
+++ b/drivers/crypto/ccp/ccp-dmaengine.c
@@ -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);
 	}
@@ -766,8 +770,8 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
 	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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister
  2022-09-01  2:16 [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister Koba Ko
@ 2022-09-01 13:42 ` Tom Lendacky
  2022-09-01 13:57   ` Koba Ko
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Lendacky @ 2022-09-01 13:42 UTC (permalink / raw)
  To: Koba Ko, John Allen, Herbert Xu, David S. Miller, linux-crypto,
	linux-kernel

On 8/31/22 21:16, Koba Ko wrote:
> 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+0xb7/0xc0
> 
> Call dma_release_channel for occupied channles before dma_async_device_unregister.
> 
> Fixes: 4cbe9bc34ed0 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")

I can't find this Fixes: tag. I did find:

54cce8ecb925 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")

Not sure if Herbert can take care of that or if you'll need a v3.

With the change to the Fixes: tag

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Koba Ko <koba.ko@canonical.com>
> ---
> V2: Fix the unused warning
> ---
>   drivers/crypto/ccp/ccp-dmaengine.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
> index 7d4b4ad1db1f3..9f753cb4f5f18 100644
> --- a/drivers/crypto/ccp/ccp-dmaengine.c
> +++ b/drivers/crypto/ccp/ccp-dmaengine.c
> @@ -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);
>   	}
> @@ -766,8 +770,8 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
>   	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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister
  2022-09-01 13:42 ` Tom Lendacky
@ 2022-09-01 13:57   ` Koba Ko
  2022-09-01 14:23     ` Koba Ko
  0 siblings, 1 reply; 5+ messages in thread
From: Koba Ko @ 2022-09-01 13:57 UTC (permalink / raw)
  To: Tom Lendacky
  Cc: John Allen, Herbert Xu, David S. Miller, linux-crypto, linux-kernel

On Thu, Sep 1, 2022 at 9:42 PM Tom Lendacky <thomas.lendacky@amd.com> wrote:
>
> On 8/31/22 21:16, Koba Ko wrote:
> > 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+0xb7/0xc0
> >
> > Call dma_release_channel for occupied channles before dma_async_device_unregister.
> >
> > Fixes: 4cbe9bc34ed0 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
>
> I can't find this Fixes: tag. I did find:
>
> 54cce8ecb925 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
>
> Not sure if Herbert can take care of that or if you'll need a v3.

Sorry, it should be 54cce8ecb925("crypto: ccp -
ccp_dmaengine_unregister release dma channels")

>
> With the change to the Fixes: tag
>
> Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
>
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Koba Ko <koba.ko@canonical.com>
> > ---
> > V2: Fix the unused warning
> > ---
> >   drivers/crypto/ccp/ccp-dmaengine.c | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
> > index 7d4b4ad1db1f3..9f753cb4f5f18 100644
> > --- a/drivers/crypto/ccp/ccp-dmaengine.c
> > +++ b/drivers/crypto/ccp/ccp-dmaengine.c
> > @@ -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);
> >       }
> > @@ -766,8 +770,8 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
> >       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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister
  2022-09-01 13:57   ` Koba Ko
@ 2022-09-01 14:23     ` Koba Ko
  2022-09-01 14:27       ` Tom Lendacky
  0 siblings, 1 reply; 5+ messages in thread
From: Koba Ko @ 2022-09-01 14:23 UTC (permalink / raw)
  To: Tom Lendacky
  Cc: John Allen, Herbert Xu, David S. Miller, linux-crypto, linux-kernel

On Thu, Sep 1, 2022 at 9:57 PM Koba Ko <koba.ko@canonical.com> wrote:
>
> On Thu, Sep 1, 2022 at 9:42 PM Tom Lendacky <thomas.lendacky@amd.com> wrote:
> >
> > On 8/31/22 21:16, Koba Ko wrote:
> > > 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+0xb7/0xc0
> > >
> > > Call dma_release_channel for occupied channles before dma_async_device_unregister.
> > >
> > > Fixes: 4cbe9bc34ed0 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
> >
> > I can't find this Fixes: tag. I did find:
> >
> > 54cce8ecb925 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
> >
> > Not sure if Herbert can take care of that or if you'll need a v3.
>
> Sorry, it should be 54cce8ecb925("crypto: ccp -
> ccp_dmaengine_unregister release dma channels")
>
> >
> > With the change to the Fixes: tag
> >
> > Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

Should I add acked-by in V3 by myself? thanks

> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Signed-off-by: Koba Ko <koba.ko@canonical.com>
> > > ---
> > > V2: Fix the unused warning
> > > ---
> > >   drivers/crypto/ccp/ccp-dmaengine.c | 6 +++++-
> > >   1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
> > > index 7d4b4ad1db1f3..9f753cb4f5f18 100644
> > > --- a/drivers/crypto/ccp/ccp-dmaengine.c
> > > +++ b/drivers/crypto/ccp/ccp-dmaengine.c
> > > @@ -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);
> > >       }
> > > @@ -766,8 +770,8 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
> > >       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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister
  2022-09-01 14:23     ` Koba Ko
@ 2022-09-01 14:27       ` Tom Lendacky
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2022-09-01 14:27 UTC (permalink / raw)
  To: Koba Ko
  Cc: John Allen, Herbert Xu, David S. Miller, linux-crypto, linux-kernel

On 9/1/22 09:23, Koba Ko wrote:
> On Thu, Sep 1, 2022 at 9:57 PM Koba Ko <koba.ko@canonical.com> wrote:
>>
>> On Thu, Sep 1, 2022 at 9:42 PM Tom Lendacky <thomas.lendacky@amd.com> wrote:
>>>
>>> On 8/31/22 21:16, Koba Ko wrote:
>>>> 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+0xb7/0xc0
>>>>
>>>> Call dma_release_channel for occupied channles before dma_async_device_unregister.
>>>>
>>>> Fixes: 4cbe9bc34ed0 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
>>>
>>> I can't find this Fixes: tag. I did find:
>>>
>>> 54cce8ecb925 ("crypto: ccp - ccp_dmaengine_unregister release dma channels")
>>>
>>> Not sure if Herbert can take care of that or if you'll need a v3.
>>
>> Sorry, it should be 54cce8ecb925("crypto: ccp -
>> ccp_dmaengine_unregister release dma channels")
>>
>>>
>>> With the change to the Fixes: tag
>>>
>>> Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
> 
> Should I add acked-by in V3 by myself? thanks

Yep.

Thanks,
Tom

> 
>>>> Reported-by: kernel test robot <lkp@intel.com>
>>>> Signed-off-by: Koba Ko <koba.ko@canonical.com>
>>>> ---
>>>> V2: Fix the unused warning
>>>> ---
>>>>    drivers/crypto/ccp/ccp-dmaengine.c | 6 +++++-
>>>>    1 file changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
>>>> index 7d4b4ad1db1f3..9f753cb4f5f18 100644
>>>> --- a/drivers/crypto/ccp/ccp-dmaengine.c
>>>> +++ b/drivers/crypto/ccp/ccp-dmaengine.c
>>>> @@ -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);
>>>>        }
>>>> @@ -766,8 +770,8 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
>>>>        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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-01 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01  2:16 [PATCH V2] crypto: ccp - Release dma channels before dmaengine unrgister Koba Ko
2022-09-01 13:42 ` Tom Lendacky
2022-09-01 13:57   ` Koba Ko
2022-09-01 14:23     ` Koba Ko
2022-09-01 14:27       ` Tom Lendacky

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.