dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] dmaengine: uniphier-xdmac: Add UniPhier external DMA controller driver
@ 2021-07-27  8:33 Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-07-27  8:33 UTC (permalink / raw)
  To: hayashi.kunihiko; +Cc: dmaengine

Hello Kunihiko Hayashi,

The patch 667b9251440b: "dmaengine: uniphier-xdmac: Add UniPhier
external DMA controller driver" from Feb 21, 2020, leads to the
following static checker warning:

	drivers/dma/uniphier-xdmac.c:212 uniphier_xdmac_chan_stop()
	warn: sleeping in atomic context

drivers/dma/uniphier-xdmac.c
    197 static int uniphier_xdmac_chan_stop(struct uniphier_xdmac_chan *xc)
    198 {
    199 	u32 val;
    200 
    201 	/* disable interrupt */
    202 	val = readl(xc->reg_ch_base + XDMAC_IEN);
    203 	val &= ~(XDMAC_IEN_ENDIEN | XDMAC_IEN_ERRIEN);
    204 	writel(val, xc->reg_ch_base + XDMAC_IEN);
    205 
    206 	/* stop XDMAC */
    207 	val = readl(xc->reg_ch_base + XDMAC_TSS);
    208 	val &= ~XDMAC_TSS_REQ;
    209 	writel(0, xc->reg_ch_base + XDMAC_TSS);
    210 
    211 	/* wait until transfer is stopped */
--> 212 	return readl_poll_timeout(xc->reg_ch_base + XDMAC_STAT, val,
    213 				  !(val & XDMAC_STAT_TENF), 100, 1000);
                                                                    ^^^
This 100 means it can sleep.  The function is always called with a
spin_lock held.

    214 }

regards,
dan carpenter

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

* Re: [bug report] dmaengine: uniphier-xdmac: Add UniPhier external DMA controller driver
  2021-07-27  4:05 ` Kunihiko Hayashi
@ 2021-07-27  4:47   ` Kunihiko Hayashi
  0 siblings, 0 replies; 4+ messages in thread
From: Kunihiko Hayashi @ 2021-07-27  4:47 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: dmaengine

Hi,

On 2021/07/27 13:05, Kunihiko Hayashi wrote:
> Hi Dan,
> Thank you for reporting.
> 
> On 2021/07/26 16:34, Dan Carpenter wrote:
>> Hello Kunihiko Hayashi,
>>
>> The patch 667b9251440b: "dmaengine: uniphier-xdmac: Add UniPhier
>> external DMA controller driver" from Feb 21, 2020, leads to the
>> following static checker warning:
>>
>>     drivers/dma/uniphier-xdmac.c:212 uniphier_xdmac_chan_stop()
>>     warn: sleeping in atomic context
>>
>> drivers/dma/uniphier-xdmac.c
>>      197 static int uniphier_xdmac_chan_stop(struct uniphier_xdmac_chan *xc)
>>      198 {
>>      199     u32 val;
>>      200
>>      201     /* disable interrupt */
>>      202     val = readl(xc->reg_ch_base + XDMAC_IEN);
>>      203     val &= ~(XDMAC_IEN_ENDIEN | XDMAC_IEN_ERRIEN);
>>      204     writel(val, xc->reg_ch_base + XDMAC_IEN);
>>      205
>>      206     /* stop XDMAC */
>>      207     val = readl(xc->reg_ch_base + XDMAC_TSS);
>>      208     val &= ~XDMAC_TSS_REQ;
>>      209     writel(0, xc->reg_ch_base + XDMAC_TSS);
>>      210
>>      211     /* wait until transfer is stopped */
>> --> 212     return readl_poll_timeout(xc->reg_ch_base + XDMAC_STAT, val,
>>      213                   !(val & XDMAC_STAT_TENF), 100, 1000);
>>                                                                      ^^^
>> This is doing a 100 us sleep but both callers hold a spin lock.
> 
> Yes, this waiting code is in spin lock context.
> I think that the function needs to be rewritten in tasklet.

I found this can be simply replaced with readl_poll_timeout_atomic().
I'll fix it.

Thank you,
---
Best Regards
Kunihiko Hayashi

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

* Re: [bug report] dmaengine: uniphier-xdmac: Add UniPhier external DMA controller driver
  2021-07-26  7:34 Dan Carpenter
@ 2021-07-27  4:05 ` Kunihiko Hayashi
  2021-07-27  4:47   ` Kunihiko Hayashi
  0 siblings, 1 reply; 4+ messages in thread
From: Kunihiko Hayashi @ 2021-07-27  4:05 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: dmaengine

Hi Dan,
Thank you for reporting.

On 2021/07/26 16:34, Dan Carpenter wrote:
> Hello Kunihiko Hayashi,
> 
> The patch 667b9251440b: "dmaengine: uniphier-xdmac: Add UniPhier
> external DMA controller driver" from Feb 21, 2020, leads to the
> following static checker warning:
> 
> 	drivers/dma/uniphier-xdmac.c:212 uniphier_xdmac_chan_stop()
> 	warn: sleeping in atomic context
> 
> drivers/dma/uniphier-xdmac.c
>      197 static int uniphier_xdmac_chan_stop(struct uniphier_xdmac_chan *xc)
>      198 {
>      199 	u32 val;
>      200
>      201 	/* disable interrupt */
>      202 	val = readl(xc->reg_ch_base + XDMAC_IEN);
>      203 	val &= ~(XDMAC_IEN_ENDIEN | XDMAC_IEN_ERRIEN);
>      204 	writel(val, xc->reg_ch_base + XDMAC_IEN);
>      205
>      206 	/* stop XDMAC */
>      207 	val = readl(xc->reg_ch_base + XDMAC_TSS);
>      208 	val &= ~XDMAC_TSS_REQ;
>      209 	writel(0, xc->reg_ch_base + XDMAC_TSS);
>      210
>      211 	/* wait until transfer is stopped */
> --> 212 	return readl_poll_timeout(xc->reg_ch_base + XDMAC_STAT, val,
>      213 				  !(val & XDMAC_STAT_TENF), 100, 1000);
>                                                                      ^^^
> This is doing a 100 us sleep but both callers hold a spin lock.

Yes, this waiting code is in spin lock context.
I think that the function needs to be rewritten in tasklet.

Thank you,

---
Best Regards
Kunihiko Hayashi

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

* [bug report] dmaengine: uniphier-xdmac: Add UniPhier external DMA controller driver
@ 2021-07-26  7:34 Dan Carpenter
  2021-07-27  4:05 ` Kunihiko Hayashi
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2021-07-26  7:34 UTC (permalink / raw)
  To: hayashi.kunihiko; +Cc: dmaengine

Hello Kunihiko Hayashi,

The patch 667b9251440b: "dmaengine: uniphier-xdmac: Add UniPhier
external DMA controller driver" from Feb 21, 2020, leads to the
following static checker warning:

	drivers/dma/uniphier-xdmac.c:212 uniphier_xdmac_chan_stop()
	warn: sleeping in atomic context

drivers/dma/uniphier-xdmac.c
    197 static int uniphier_xdmac_chan_stop(struct uniphier_xdmac_chan *xc)
    198 {
    199 	u32 val;
    200 
    201 	/* disable interrupt */
    202 	val = readl(xc->reg_ch_base + XDMAC_IEN);
    203 	val &= ~(XDMAC_IEN_ENDIEN | XDMAC_IEN_ERRIEN);
    204 	writel(val, xc->reg_ch_base + XDMAC_IEN);
    205 
    206 	/* stop XDMAC */
    207 	val = readl(xc->reg_ch_base + XDMAC_TSS);
    208 	val &= ~XDMAC_TSS_REQ;
    209 	writel(0, xc->reg_ch_base + XDMAC_TSS);
    210 
    211 	/* wait until transfer is stopped */
--> 212 	return readl_poll_timeout(xc->reg_ch_base + XDMAC_STAT, val,
    213 				  !(val & XDMAC_STAT_TENF), 100, 1000);
                                                                    ^^^
This is doing a 100 us sleep but both callers hold a spin lock.

    214 }

regards,
dan carpenter

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

end of thread, other threads:[~2021-07-27  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27  8:33 [bug report] dmaengine: uniphier-xdmac: Add UniPhier external DMA controller driver Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2021-07-26  7:34 Dan Carpenter
2021-07-27  4:05 ` Kunihiko Hayashi
2021-07-27  4:47   ` Kunihiko Hayashi

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox