All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: shdma: Make dummy shdma_chan_filter() always return false
@ 2015-07-10 10:07 Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2015-07-10 10:07 UTC (permalink / raw)
  To: linux-sh

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(-)

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
-- 
1.9.1


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

* Re: [PATCH] dmaengine: shdma: Make dummy shdma_chan_filter() always return false
@ 2015-08-05  3:30 Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2015-08-05  3:30 UTC (permalink / raw)
  To: linux-sh

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

-- 
~Vinod

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

end of thread, other threads:[~2015-08-05  3:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-10 10:07 [PATCH] dmaengine: shdma: Make dummy shdma_chan_filter() always return false Geert Uytterhoeven
2015-08-05  3:30 Vinod Koul

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.