Skip to contentSkip to conversation

dmaengine: Add function to request slave channel from a dma_device

RFC New Vinod Koul 1 participant 1 message Oct 9, 2018 dmaengine

lore
Share & tools
lore

Vinod Koul

author maintainer
#0 lore raw

RFC 2/5 dmaengine: Add function to request slave channel from a dma_device

Quoted 4 lines · Peter Ujfalusi

dma_get_any_slave_channel() would skip using the filter function, which in some cases needed to be executed before the alloc_chan_resources callback to make sure that all parameters are provided for the slave channel.

Another request API, i though you had solved that last time around :(

Quoted 56 lines
---
 drivers/dma/dmaengine.c   | 20 ++++++++++++++++++++
 include/linux/dmaengine.h |  2 ++
 2 files changed, 22 insertions(+)
drivers/dma/dmaengine.c +20 -0
index 27b6d7c2d8a0..b80f1bdd8813 100644
@@ -634,6 +634,26 @@ struct dma_chan *dma_get_any_slave_channel(struct dma_device *device)
 }
 EXPORT_SYMBOL_GPL(dma_get_any_slave_channel);
 
+struct dma_chan *dmadev_get_slave_channel(struct dma_device *device,
+					  dma_filter_fn fn, void *fn_param)
+{
+	dma_cap_mask_t mask;
+	struct dma_chan *chan;
+
+	dma_cap_zero(mask);
+	dma_cap_set(DMA_SLAVE, mask);
+
+	/* lock against __dma_request_channel */
+	mutex_lock(&dma_list_mutex);
+
+	chan = find_candidate(device, &mask, fn, fn_param);
+
+	mutex_unlock(&dma_list_mutex);
+
+	return IS_ERR(chan) ? NULL : chan;
+}
+EXPORT_SYMBOL_GPL(dmadev_get_slave_channel);
+
 /**
  * __dma_request_channel - try to allocate an exclusive channel
  * @mask: capabilities that the channel must satisfy
include/linux/dmaengine.h +2 -0
index 16c9d021988a..32010c6ae13a 100644
@@ -1542,6 +1542,8 @@ void dma_async_device_unregister(struct dma_device *device);
 void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
 struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);
 struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
+struct dma_chan *dmadev_get_slave_channel(struct dma_device *device,
+					  dma_filter_fn fn, void *fn_param);
 #define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
 #define dma_request_slave_channel_compat(mask, x, y, dev, name) \
 	__dma_request_slave_channel_compat(&(mask), x, y, dev, name)
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki