Skip to contentSkip to conversation

dmaengine: increase privatecnt in dma_get_any_slave_channel

PATCH New Xiang Wang 1 participant 1 message Aug 21, 2014 dmaengine

lore
Share & tools
lore

Xiang Wang

author
#0 lore raw

PATCH 1/1 dmaengine: increase privatecnt in dma_get_any_slave_channel

From: Xiang Wang <[email protected]>

There might be such calling sequence for dma channel:
1. register dma device dma_async_device_register
-> if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
device->privatecnt++;

2. request channel
dma_request_slave_channel
-> of_dma_request_slave_channel

    -> of_dma_xlate
      -> dma_get_any_slave_channel in dma drivers

note that device->privatecnt is not changed during this.

3. release channel
dma_release_channel
-> if (--chan->device->privatecnt == 0)

		dma_cap_clear(DMA_PRIVATE,
		chan->device->cap_mask);

So if we request a channel then release it, DMA_PRIVATE will be cleared unexpectedly. In this patch, we increase privatecnt in step 2 just like what __dma_request_channel does.

---
 drivers/dma/dmaengine.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/dma/dmaengine.c +3 -0
index ed610b4..01bb372 100644
@@ -557,6 +557,9 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device)
 		}
 	}
 
+	if (chan && dma_has_cap(DMA_PRIVATE, device->cap_mask))
+		device->privatecnt++;
+
 	mutex_unlock(&dma_list_mutex);
 
 	return chan;
Signature · 1 line
1.7.5.4