* [PATCH] dmaengine: Stricter legacy checking in dma_request_slave_channel_compat()
@ 2015-08-17 13:08 Geert Uytterhoeven
2015-08-20 6:43 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2015-08-17 13:08 UTC (permalink / raw)
To: Vinod Koul, Dan Williams
Cc: Arnd Bergmann, Tony Lindgren, Matt Porter, dmaengine, linux-sh,
linux-kernel, Geert Uytterhoeven
dma_request_slave_channel_compat() is meant for drivers that support
both DT and legacy platform device based probing: if DT channel DMA
setup fails, it will fall back to platform data based DMA channel setup,
using hardcoded DMA channel IDs and a filter function.
However, if the DTS doesn't provide a "dmas" property for the device,
the fallback is also used. If the legacy filter function is not
hardcoded in the DMA slave driver, but comes from platform data, it will
be NULL. Then dma_request_slave_channel_compat() will succeed
incorrectly, and return a DMA channel, as a NULL legacy filter function
actually means "all channels are OK", not "do not match".
Later, when trying to use that DMA channel, it will fail with:
rcar-dmac e6700000.dma-controller: rcar_dmac_prep_slave_sg: bad parameter: len=1, id=-22
To fix this, ensure that both the filter function and the DMA channel ID
are not NULL before using the legacy fallback.
Note that some DMA slave drivers can handle this failure, and will fall
back to PIO.
See also commit 056f6c87028544de ("dmaengine: shdma: Make dummy
shdma_chan_filter() always return false"), which fixed the same issue
for the case where shdma_chan_filter() is hardcoded in a DMA slave
driver.
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
include/linux/dmaengine.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index bdae84ab305bca59..6a22cf1b63c24ffb 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1197,6 +1197,9 @@ static inline struct dma_chan
if (chan)
return chan;
+ if (!fn || !fn_param)
+ return NULL;
+
return __dma_request_channel(mask, fn, fn_param);
}
#endif /* DMAENGINE_H */
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: Stricter legacy checking in dma_request_slave_channel_compat()
2015-08-17 13:08 [PATCH] dmaengine: Stricter legacy checking in dma_request_slave_channel_compat() Geert Uytterhoeven
@ 2015-08-20 6:43 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2015-08-20 6:43 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Dan Williams, Arnd Bergmann, Tony Lindgren, Matt Porter,
dmaengine, linux-sh, linux-kernel
On Mon, Aug 17, 2015 at 03:08:55PM +0200, Geert Uytterhoeven wrote:
> dma_request_slave_channel_compat() is meant for drivers that support
> both DT and legacy platform device based probing: if DT channel DMA
> setup fails, it will fall back to platform data based DMA channel setup,
> using hardcoded DMA channel IDs and a filter function.
>
> However, if the DTS doesn't provide a "dmas" property for the device,
> the fallback is also used. If the legacy filter function is not
> hardcoded in the DMA slave driver, but comes from platform data, it will
> be NULL. Then dma_request_slave_channel_compat() will succeed
> incorrectly, and return a DMA channel, as a NULL legacy filter function
> actually means "all channels are OK", not "do not match".
>
> Later, when trying to use that DMA channel, it will fail with:
>
> rcar-dmac e6700000.dma-controller: rcar_dmac_prep_slave_sg: bad parameter: len=1, id=-22
>
> To fix this, ensure that both the filter function and the DMA channel ID
> are not NULL before using the legacy fallback.
>
> Note that some DMA slave drivers can handle this failure, and will fall
> back to PIO.
>
> See also commit 056f6c87028544de ("dmaengine: shdma: Make dummy
> shdma_chan_filter() always return false"), which fixed the same issue
> for the case where shdma_chan_filter() is hardcoded in a DMA slave
> driver.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-20 6:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-17 13:08 [PATCH] dmaengine: Stricter legacy checking in dma_request_slave_channel_compat() Geert Uytterhoeven
2015-08-20 6:43 ` Vinod Koul
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).