Message ID | 1436522845-13929-1-git-send-email-geert+renesas@glider.be (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Fri, Jul 10, 2015 at 12:07:25PM +0200, Geert Uytterhoeven wrote: > If CONFIG_SH_DMAE_BASE (which is required for DMA engine support for > legacy SH, SH/R-Mobile, and R-Car Gen1, but not for R-Car Gen2) is not > enabled, but CONFIG_RCAR_DMAC (for R-Car Gen2 DMA engine support) is, > and the DTS doesn't provide a "dmas" property for a device, > dma_request_slave_channel_compat() incorrectly succeeds, and returns a > DMA channel. > > However, when trying to use that DMA channel later, it fails with: > > rcar-dmac e6700000.dma-controller: rcar_dmac_prep_slave_sg: bad parameter: len=1, id=-22 > > (Fortunately most drivers can handle this failure, and fall back to > PIO) > > The reason for this is that a NULL legacy filter function is used, which > actually means "all channels are OK", not "do not match". > If CONFIG_SH_DMAE_BASE is enabled (like in shmobile_defconfig, which > supports other SoCs besides R-Car Gen2), shdma_chan_filter() correctly > returns false, as no available channel on R-Car Gen2 matches a > shdma-base channel. > If the DTS does provide a "dmas" property, dma_request_slave_channel() > succeeds, and legacy filter-based matching is not used. > > To fix this, change shdma_chan_filter from being NULL to a dummy > function that always returns false, like is done on other platforms. Applied, thanks
diff --git a/include/linux/shdma-base.h b/include/linux/shdma-base.h index dd0ba502ccb3a0ea..d927647e6350324f 100644 --- a/include/linux/shdma-base.h +++ b/include/linux/shdma-base.h @@ -128,7 +128,10 @@ void shdma_cleanup(struct shdma_dev *sdev); #if IS_ENABLED(CONFIG_SH_DMAE_BASE) bool shdma_chan_filter(struct dma_chan *chan, void *arg); #else -#define shdma_chan_filter NULL +static inline bool shdma_chan_filter(struct dma_chan *chan, void *arg) +{ + return false; +} #endif #endif
If CONFIG_SH_DMAE_BASE (which is required for DMA engine support for legacy SH, SH/R-Mobile, and R-Car Gen1, but not for R-Car Gen2) is not enabled, but CONFIG_RCAR_DMAC (for R-Car Gen2 DMA engine support) is, and the DTS doesn't provide a "dmas" property for a device, dma_request_slave_channel_compat() incorrectly succeeds, and returns a DMA channel. However, when trying to use that DMA channel later, it fails with: rcar-dmac e6700000.dma-controller: rcar_dmac_prep_slave_sg: bad parameter: len=1, id=-22 (Fortunately most drivers can handle this failure, and fall back to PIO) The reason for this is that a NULL legacy filter function is used, which actually means "all channels are OK", not "do not match". If CONFIG_SH_DMAE_BASE is enabled (like in shmobile_defconfig, which supports other SoCs besides R-Car Gen2), shdma_chan_filter() correctly returns false, as no available channel on R-Car Gen2 matches a shdma-base channel. If the DTS does provide a "dmas" property, dma_request_slave_channel() succeeds, and legacy filter-based matching is not used. To fix this, change shdma_chan_filter from being NULL to a dummy function that always returns false, like is done on other platforms. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- include/linux/shdma-base.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)