From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
ALSA Development Mailing List <alsa-devel@alsa-project.org>,
Vinod Koul <vinod.koul@intel.com>,
Linux MMC List <linux-mmc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-spi <linux-spi@vger.kernel.org>,
Tony Lindgren <tony@atomide.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-crypto@vger.kernel.org,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
dmaengine@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH 02/13] dmaengine: Introduce dma_request_slave_channel_compat_reason()
Date: Fri, 20 Nov 2015 12:25:06 +0200 [thread overview]
Message-ID: <564EF502.6040708@ti.com> (raw)
In-Reply-To: <4533695.7ZVFN1S94o@wuerfel>
On 11/19/2015 01:25 PM, Arnd Bergmann wrote:
>> If we have two main APIs, one to request slave channels and one to get any
>> channel with given capability
>> dma_request_slave_channel(NULL, NULL, &mask, fn, fn_param); /* Legacy slave */
>> dma_request_slave_channel(dev, name, NULL, NULL, NULL); /* DT/ACPI, current
>> slave */
>> dma_request_slave_channel(dev, name, &mask, fn, fn_param); /* current compat*/
>>
>> This way we can omit the mask also in cases when the client only want to get
>> DMA_SLAVE, we can just build up the mask within the function. If the mask is
>> provided we would copy the bits from the provided mask, so for example if you
>> want to have DMA_SLAVE+DMA_CYCLIC, the driver only needs to pass DMA_CYCLIC,
>> the DMA_SLAVE is going to be set anyways.
>
> I think it's more logical here to have mask=NULL mean that we want DMA_SLAVE,
> but otherwise pass the full mask as DMA_SLAVE|DMA_CYCLIC etc.
Yep, could be, while I would write the core part to set the DMA_SLAVE
unconditionally anyways. If the API say it is dma_request_slavechan() it is
expected to get channel which is capable of DMA_SLAVE.
>> dma_request_channel(mask); /* memcpy. etc, non slave mostly */
>>
>> Not sure how to name this as reusing existing (good, descriptive) function
>> names would mean changes all over the kernel to start off this.
>>
>> Not used and
>> request_dma_channel(); /* as _irq/_mem_region/_resource, etc */
>> request_dma();
>> dma_channel_request();
>
> dma_request_slavechan();
> dma_request_slave();
> dma_request_mask();
Let me think aloud here a bit...
1. To request slave channel which will return you the channel your device is
bind via DT/ACPI or the platform map table you propose later:
dma_request_chan(struct device *dev, const char *name);
2. To request a channel (any channel) matching with the capabilities the
driver needs, like memcpy, memset, etc:
#define dma_request_chan_by_mask(mask) __dma_request_chan_by_mask(&(mask))
__dma_request_chan_by_mask(const dma_cap_mask_t *mask);
I think the dma_request_chan() does not need mask to be passed, since via this
we request a specific channel which has been defined/set by DT/ACPI or the
lookup map. We could add a mask parameter which could be used to sanity check
the channel we got against the capabilities the driver needs from the channel.
We currently do this in the drivers where the author wanted to make sure that
the channel is capable of what it should be capable.
So two API to request channel:
struct dma_chan *dma_request_chan(struct device *dev, const char *name);
struct dma_chan *dma_request_chan_by_mask(const dma_cap_mask_t *mask);
Both will return with the valid channel pointer or in case of failure with
ERR_PTR().
We need to go through the code in regards to return codes also to have sane
mapping.
>
>> All in all, not sure which way would be better...
>
> I think I would prefer the simplest API to have only the dev+name
> arguments, as we tend to move that way for all platforms anyway, and it
> seems silly to have all drivers pass three NULL arguments all the time.
> At the moment, there are 139 references to dma_request_slave_channel_*
> in the kernel, and only 46 of them are dma_request_slave_channel_compat.
> Out of those 46, a couple can already be converted back to use
> dma_request_slave_channel() because the platform now only supports
> devicetree based boots and will not go back to platform data.
>
> How about something like
>
> extern struct dma_chan *
> __dma_request_chan(struct device *dev, const char *name,
> const dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param);
>
> static inline struct dma_chan *
> dma_request_slavechan(struct device *dev, const char *name)
> {
> return __dma_request_chan(dev, name, NULL, NULL, NULL);
> }
>
> static inline struct dma_chan *
> dma_request_chan(const dma_cap_mask_t *mask)
> {
> return __dma_request_chan(NULL, NULL, mask, NULL, NULL);
> }
>
> That way the vast majority of drivers can use one of the two nice interfaces
> and the rest can be converted to use __dma_request_chan().
>
> On a related topic, we had in the past considered providing a way for
> platform code to register a lookup table of some sort, to associate
> a device/name pair with a configuration. That would let us use the
> simplified dma_request_slavechan(dev, name) pair everywhere. We could
> use the same method that we have for clk_register_clkdevs() or
> pinctrl_register_map().
>
> Something like either
>
> static struct dma_chan_map myplatform_dma_map[] = {
> { .devname = "omap-aes0", .slave = "tx", .filter = omap_dma_filter_fn, .arg = (void *)65, },
> { .devname = "omap-aes0", .slave = "rx", .filter = omap_dma_filter_fn, .arg = (void *)66, },
> };
>
> or
>
> static struct dma_chan_map myplatform_dma_map[] = {
> { .devname = "omap-aes0", .slave = "tx", .master = "omap-dma-engine0", .req = 65, },
> { .devname = "omap-aes0", .slave = "rx", .master = "omap-dma-engine0", .req = 66, },
sa11x0-dma expects the fn_param as string :o
> };
Basically we are deprecating the use of IORESOURCE_DMA?
For legacy the filter function is pretty much needed to handle the differences
between the platforms as not all of them does the filtering in a same way. So
the first type of map would be feasible IMHO.
> we could even allow a combination of the two, so the simple case just specifies
> master and req number, which requires changes to the dmaengine driver, but we could
> also do a mass-conversion to the .filter/.arg variant.
This will get rid of the need for the fn and fn_param parameters when
requesting dma channel, but it will not get rid of the exported function from
the dma engine drivers since in arch code we need to have visibility to the
filter_fn.
--
Péter
next prev parent reply other threads:[~2015-11-20 10:25 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-26 13:25 [PATCH 00/13] dmaengine + omap drivers: support fro deferred probing Peter Ujfalusi
2015-05-26 13:25 ` [PATCH 01/13] dmaengine: of_dma: Correct return code for of_dma_request_slave_channel in case !CONFIG_OF Peter Ujfalusi
2015-05-26 13:25 ` [PATCH 02/13] dmaengine: Introduce dma_request_slave_channel_compat_reason() Peter Ujfalusi
2015-05-29 9:33 ` Vinod Koul
2015-05-29 9:42 ` Geert Uytterhoeven
2015-05-29 10:18 ` Vinod Koul
2015-05-29 14:32 ` Peter Ujfalusi
2015-06-02 12:55 ` Vinod Koul
2015-06-04 15:58 ` Peter Ujfalusi
2015-06-12 12:58 ` Vinod Koul
2015-06-22 11:31 ` Peter Ujfalusi
2015-06-24 16:24 ` Vinod Koul
2015-06-25 11:15 ` Arnd Bergmann
2015-11-18 14:21 ` Peter Ujfalusi
2015-11-18 14:29 ` Arnd Bergmann
2015-11-18 14:41 ` Peter Ujfalusi
2015-11-18 15:07 ` Arnd Bergmann
2015-11-18 15:43 ` Andy Shevchenko
[not found] ` <CAHp75VeZFXp9i_zz7CBkVQVPGQxuzYk9AbWbbbn33r8YX3LCdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-18 15:51 ` Arnd Bergmann
2015-11-18 16:00 ` Andy Shevchenko
2015-11-18 16:06 ` Vinod Koul
2015-11-19 10:34 ` Peter Ujfalusi
2015-11-19 11:25 ` Arnd Bergmann
2015-11-20 10:25 ` Peter Ujfalusi [this message]
2015-11-20 10:58 ` Arnd Bergmann
2015-11-20 12:24 ` Andy Shevchenko
[not found] ` <CAHp75VdoHqPMNGFfz4mPhX+Lw+vxgiyqFS8j5+kQ9Z9CHt=OTA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-20 12:30 ` Peter Ujfalusi
[not found] ` <564F1253.4000800-l0cyMroinI0@public.gmane.org>
2015-11-20 14:08 ` Andy Shevchenko
2015-11-20 12:52 ` Peter Ujfalusi
[not found] ` <564F1773.9030006-l0cyMroinI0@public.gmane.org>
2015-11-20 13:48 ` Arnd Bergmann
2015-11-18 15:46 ` Andy Shevchenko
2015-11-19 10:36 ` Peter Ujfalusi
[not found] ` <1432646768-12532-1-git-send-email-peter.ujfalusi-l0cyMroinI0@public.gmane.org>
2015-05-26 13:25 ` [PATCH 03/13] serial: 8250_dma: Support for deferred probing when requesting DMA channels Peter Ujfalusi
[not found] ` <1432646768-12532-4-git-send-email-peter.ujfalusi-l0cyMroinI0@public.gmane.org>
2015-05-26 14:44 ` Greg Kroah-Hartman
2015-05-27 10:41 ` Peter Ujfalusi
2015-05-27 10:41 ` Peter Ujfalusi
2015-05-26 15:08 ` Tony Lindgren
2015-05-27 10:58 ` Peter Ujfalusi
2015-05-26 13:26 ` [PATCH 09/13] crypto: omap-des - " Peter Ujfalusi
2015-05-26 13:26 ` [PATCH 13/13] ASoC: omap-pcm: Switch to use dma_request_slave_channel_compat_reason() Peter Ujfalusi
2015-05-27 17:48 ` Mark Brown
2015-05-26 13:25 ` [PATCH 04/13] mmc: omap_hsmmc: No need to check DMA channel validity at module remove Peter Ujfalusi
2015-05-28 7:20 ` Ulf Hansson
2015-05-26 13:26 ` [PATCH 05/13] mmc: omap_hsmmc: Support for deferred probing when requesting DMA channels Peter Ujfalusi
[not found] ` <1432646768-12532-6-git-send-email-peter.ujfalusi-l0cyMroinI0@public.gmane.org>
2015-05-28 7:23 ` Ulf Hansson
2015-05-26 13:26 ` [PATCH 06/13] mmc: omap: " Peter Ujfalusi
2015-05-26 13:26 ` [PATCH 07/13] mmc: davinci_mmc: " Peter Ujfalusi
2015-05-28 7:31 ` Ulf Hansson
2015-05-26 13:26 ` [PATCH 08/13] crypto: omap-aes - " Peter Ujfalusi
2015-05-26 13:26 ` [PATCH 10/13] crypto: omap-sham - Support for deferred probing when requesting DMA channel Peter Ujfalusi
2015-05-26 13:26 ` [PATCH 11/13] spi: omap2-mcspi: Support for deferred probing when requesting DMA channels Peter Ujfalusi
2015-05-26 15:27 ` Mark Brown
2015-05-27 11:15 ` Peter Ujfalusi
[not found] ` <5565A740.2020707-l0cyMroinI0@public.gmane.org>
2015-05-27 17:48 ` Mark Brown
2015-05-27 17:48 ` Mark Brown
2015-05-26 13:26 ` [PATCH 12/13] [media] omap3isp: Support for deferred probing when requesting DMA channel Peter Ujfalusi
2015-11-09 19:50 ` Laurent Pinchart
2015-11-10 7:56 ` Peter Ujfalusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=564EF502.6040708@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=tony@atomide.com \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).