From: Jon Hunter <jon-hunter@ti.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: device-tree <devicetree-discuss@lists.ozlabs.org>,
linux-omap <linux-omap@vger.kernel.org>,
linux-arm <linux-arm-kernel@lists.infradead.org>,
Nicolas Ferre <nicolas.ferre@atmel.com>,
Benoit Cousson <b-cousson@ti.com>,
Stephen Warren <swarren@nvidia.com>,
Grant Likely <grant.likely@secretlab.ca>,
Russell King <linux@arm.linux.org.uk>,
Rob Herring <rob.herring@calxeda.com>,
Vinod Koul <vinod.koul@intel.com>, Dan Williams <djbw@fb.com>
Subject: Re: [PATCH V4 1/2] of: Add generic device tree DMA helpers
Date: Fri, 14 Sep 2012 09:03:18 -0500 [thread overview]
Message-ID: <50533926.1070201@ti.com> (raw)
In-Reply-To: <201209141332.42420.arnd@arndb.de>
On 09/14/2012 08:32 AM, Arnd Bergmann wrote:
> On Friday 14 September 2012, Jon Hunter wrote:
>> On 09/14/2012 04:43 AM, Arnd Bergmann wrote:
>>>> +
>>>> +Client drivers should specify the DMA property using a phandle to the controller
>>>> +followed by DMA controller specific data.
>>>> +
>>>> +Required property:
>>>> +- dmas: List of one or more DMA specifiers, each consisting of
>>>> + - A phandle pointing to DMA controller node
>>>> + - A single integer cell containing DMA controller
>>>> + specific information. This typically contains a dma
>>>> + request line number or a channel number, but can
>>>> + contain any data that is used required for configuring
>>>> + a channel.
>>>> +- dma-names: Contains one identifier string for each dma specifier in
>>>> + the dmas property. The specific strings that can be used
>>>> + are defined in the binding of the DMA client device.
>>>
>>> I think here we need to clarify that listing the same name multiple times implies
>>> having multiple alternatives for the same channel.
>>
>> Ok, however, the way it works right now is that we will use the first
>> specifier that matches the name. So if there are multiple with the same
>> name that would imply that someone will need call the
>> xxx_request_slave_channel() multiple times to extract these. Is that ok?
>
> I would expect a driver to only call the function once, and get something
> back from the dmaengine layer that works. If there are two controllers
> to choose from and one is busy, then it should definitely give a channel
> from the non-busy one.
>
> It's not much of an issue if the code doesn't handle all corner cases at
> first, but I would expect that the binding correctly describes how to write
> a device tree that will work once the code implements it correctly.
Gotcha, may be something like the following should work then ...
diff --git a/drivers/of/dma.c b/drivers/of/dma.c
index 4025f2f..de59611 100644
--- a/drivers/of/dma.c
+++ b/drivers/of/dma.c
@@ -127,13 +127,15 @@ static int of_dma_find_channel(struct device_node *np, char *name,
return count;
for (i = 0; i < count; i++) {
- of_property_read_string_index(np, "dma-names", i, &s);
+ if (of_property_read_string_index(np, "dma-names", i, &s))
+ continue;
if (strcmp(name, s))
continue;
- return of_parse_phandle_with_args(np, "dmas", "#dma-cells",
- i, dma_spec);
+ if (!of_parse_phandle_with_args(np, "dmas", "#dma-cells", i,
+ dma_spec))
+ return 0;
}
return -ENODEV;
@@ -159,33 +161,34 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
return NULL;
}
- r = of_dma_find_channel(np, name, &dma_spec);
-
- if (r) {
- pr_err("%s: can't find DMA channel\n", np->full_name);
- return NULL;
- }
+ do {
+ r = of_dma_find_channel(np, name, &dma_spec);
+ if (r) {
+ pr_err("%s: can't find DMA channel\n", np->full_name);
+ return NULL;
+ }
+
+ ofdma = of_dma_find_controller(dma_spec.np);
+ if (!ofdma) {
+ pr_debug("%s: can't find DMA controller %s\n",
+ np->full_name, dma_spec.np->full_name);
+ continue;
+ }
- ofdma = of_dma_find_controller(dma_spec.np);
- if (!ofdma) {
- pr_err("%s: can't find DMA controller %s\n", np->full_name,
- dma_spec.np->full_name);
- return NULL;
- }
+ if (dma_spec.args_count != ofdma->of_dma_nbcells) {
+ pr_debug("%s: wrong #dma-cells for %s\n", np->full_name,
+ dma_spec.np->full_name);
+ continue;
+ }
- if (dma_spec.args_count != ofdma->of_dma_nbcells) {
- pr_err("%s: wrong #dma-cells for %s\n", np->full_name,
- dma_spec.np->full_name);
- return NULL;
- }
+ chan = ofdma->of_dma_xlate(&dma_spec, ofdma);
- chan = ofdma->of_dma_xlate(&dma_spec, ofdma);
+ of_node_put(dma_spec.np);
- of_node_put(dma_spec.np);
+ } while (!chan);
return chan;
}
-EXPORT_SYMBOL_GPL(of_dma_request_slave_channel);
Cheers
Jon
next prev parent reply other threads:[~2012-09-14 14:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-13 22:00 [PATCH V4 0/2] of: Add generic device tree DMA helpers Jon Hunter
2012-09-13 22:00 ` [PATCH V4 1/2] " Jon Hunter
2012-09-14 9:43 ` Arnd Bergmann
2012-09-14 13:27 ` Jon Hunter
2012-09-14 13:32 ` Arnd Bergmann
2012-09-14 14:03 ` Jon Hunter [this message]
2012-09-14 16:28 ` Stephen Warren
2012-09-14 17:19 ` Jon Hunter
2012-09-13 22:00 ` [PATCH V4 2/2] dmaengine: add helper function to request a slave DMA channel Jon Hunter
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=50533926.1070201@ti.com \
--to=jon-hunter@ti.com \
--cc=arnd@arndb.de \
--cc=b-cousson@ti.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=djbw@fb.com \
--cc=grant.likely@secretlab.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=nicolas.ferre@atmel.com \
--cc=rob.herring@calxeda.com \
--cc=swarren@nvidia.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).