* [PATCH] dmaengine: fix balance of privatecnt
@ 2015-09-24 9:03 Peter Ujfalusi
2015-09-30 8:00 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2015-09-24 9:03 UTC (permalink / raw)
To: dan.j.williams, vinod.koul; +Cc: dmaengine, linux-kernel
dma_release_channel() decrements privatecnt counter and almost all dma_get*
function increments it with the exception of dma_get_slave_channel().
In most cases this does not cause issue since normally the channel is not
requested and released, but if a driver requests DMA channel via
dma_get_slave_channel() and releases the channel the privatecnt will be
unbalanced and this will prevent for example getting channel for memcpy.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/dma/dmaengine.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 3ff284c8e3d5..09479d4be4db 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -554,10 +554,18 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)
mutex_lock(&dma_list_mutex);
if (chan->client_count == 0) {
+ struct dma_device *device = chan->device;
+
+ dma_cap_set(DMA_PRIVATE, device->cap_mask);
+ device->privatecnt++;
err = dma_chan_get(chan);
- if (err)
+ if (err) {
pr_debug("%s: failed to get %s: (%d)\n",
__func__, dma_chan_name(chan), err);
+ chan = NULL;
+ if (--device->privatecnt == 0)
+ dma_cap_clear(DMA_PRIVATE, device->cap_mask);
+ }
} else
chan = NULL;
--
2.5.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: fix balance of privatecnt
2015-09-24 9:03 [PATCH] dmaengine: fix balance of privatecnt Peter Ujfalusi
@ 2015-09-30 8:00 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2015-09-30 8:00 UTC (permalink / raw)
To: Peter Ujfalusi; +Cc: dan.j.williams, dmaengine, linux-kernel
On Thu, Sep 24, 2015 at 12:03:35PM +0300, Peter Ujfalusi wrote:
> dma_release_channel() decrements privatecnt counter and almost all dma_get*
> function increments it with the exception of dma_get_slave_channel().
> In most cases this does not cause issue since normally the channel is not
> requested and released, but if a driver requests DMA channel via
> dma_get_slave_channel() and releases the channel the privatecnt will be
> unbalanced and this will prevent for example getting channel for memcpy.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-30 8:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-24 9:03 [PATCH] dmaengine: fix balance of privatecnt Peter Ujfalusi
2015-09-30 8:00 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®