* [RFC,2/5] dmaengine: Add function to request slave channel from a dma_device
@ 2018-10-12 12:07 Peter Ujfalusi
0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2018-10-12 12:07 UTC (permalink / raw)
To: Vinod; +Cc: dan.j.williams, dmaengine, grygorii.strashko
On 2018-10-09 14:22, Peter Ujfalusi wrote:
>
>
> On 2018-10-09 13:49, Vinod wrote:
>> On 24-09-18, 16:00, Peter Ujfalusi wrote:
>>> 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 :(
>
> Yes, I thought so, but this time it is different.
> I want to drop this patch myself also, but I need to figure out a way to
> do what the dmadev_get_slave_channel() allows me to do.
>
> In path 4, udma_of_xlate() and the udma_dma_filter_fn()
>
> It might be possible that I look up a free udma_chan, do the setup via
> the filter_fn() and finally call the dma_get_slave_channel().
> Might work fine, but I wanted to avoid to implement my own find free
> channel code when we have it already in DMAengine core.
It is going to be racy against parallel channel requests, but
>>> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
>>> index 16c9d021988a..32010c6ae13a 100644
>>> --- a/include/linux/dmaengine.h
>>> +++ b/include/linux/dmaengine.h
>>> @@ -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);
-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_get_any_slave_channel(device)\
dmadev_get_slave_channel(device, NULL, NULL)
Should cut down on duplicated code at least.
>>> #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)
>>> --
>>> Peter
>>>
>>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>
>
> - Péter
>
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC,2/5] dmaengine: Add function to request slave channel from a dma_device
@ 2018-10-09 11:22 Peter Ujfalusi
0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2018-10-09 11:22 UTC (permalink / raw)
To: Vinod; +Cc: dan.j.williams, dmaengine, grygorii.strashko
On 2018-10-09 13:49, Vinod wrote:
> On 24-09-18, 16:00, Peter Ujfalusi wrote:
>> 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 :(
Yes, I thought so, but this time it is different.
I want to drop this patch myself also, but I need to figure out a way to
do what the dmadev_get_slave_channel() allows me to do.
In path 4, udma_of_xlate() and the udma_dma_filter_fn()
It might be possible that I look up a free udma_chan, do the setup via
the filter_fn() and finally call the dma_get_slave_channel().
Might work fine, but I wanted to avoid to implement my own find free
channel code when we have it already in DMAengine core.
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>> ---
>> drivers/dma/dmaengine.c | 20 ++++++++++++++++++++
>> include/linux/dmaengine.h | 2 ++
>> 2 files changed, 22 insertions(+)
>>
>> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
>> index 27b6d7c2d8a0..b80f1bdd8813 100644
>> --- a/drivers/dma/dmaengine.c
>> +++ b/drivers/dma/dmaengine.c
>> @@ -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
>> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
>> index 16c9d021988a..32010c6ae13a 100644
>> --- a/include/linux/dmaengine.h
>> +++ b/include/linux/dmaengine.h
>> @@ -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)
>> --
>> Peter
>>
>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC,2/5] dmaengine: Add function to request slave channel from a dma_device
@ 2018-10-09 10:49 Vinod Koul
0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2018-10-09 10:49 UTC (permalink / raw)
To: Peter Ujfalusi; +Cc: dan.j.williams, dmaengine, grygorii.strashko
On 24-09-18, 16:00, Peter Ujfalusi wrote:
> 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 :(
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/dma/dmaengine.c | 20 ++++++++++++++++++++
> include/linux/dmaengine.h | 2 ++
> 2 files changed, 22 insertions(+)
>
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 27b6d7c2d8a0..b80f1bdd8813 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -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
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 16c9d021988a..32010c6ae13a 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -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)
> --
> Peter
>
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC,2/5] dmaengine: Add function to request slave channel from a dma_device
@ 2018-09-24 13:00 Peter Ujfalusi
0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2018-09-24 13:00 UTC (permalink / raw)
To: vkoul, dan.j.williams; +Cc: dmaengine, grygorii.strashko
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.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/dma/dmaengine.c | 20 ++++++++++++++++++++
include/linux/dmaengine.h | 2 ++
2 files changed, 22 insertions(+)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 27b6d7c2d8a0..b80f1bdd8813 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -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
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 16c9d021988a..32010c6ae13a 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-12 12:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-12 12:07 [RFC,2/5] dmaengine: Add function to request slave channel from a dma_device Peter Ujfalusi
-- strict thread matches above, loose matches on Subject: below --
2018-10-09 11:22 Peter Ujfalusi
2018-10-09 10:49 Vinod Koul
2018-09-24 13:00 Peter Ujfalusi
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.