From: Lars-Peter Clausen <lars@metafoo.de>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
Vinod Koul <vinod.koul@intel.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
Stephen Warren <swarren@nvidia.com>
Subject: Re: [PATCH V2] dma: add common of_dma_slave_xlate()
Date: Tue, 26 Nov 2013 08:40:28 +0100 [thread overview]
Message-ID: <5294506C.60701@metafoo.de> (raw)
In-Reply-To: <1385429104-7001-1-git-send-email-swarren@wwwdotorg.org>
On 11/26/2013 02:25 AM, Stephen Warren wrote:
[...]
> +struct dma_chan *of_dma_slave_xlate(struct of_phandle_args *dma_spec,
> + struct of_dma *ofdma)
> +{
> + struct of_dma_slave_xlate_info *info = ofdma->of_dma_data;
> + struct dma_chan *candidate, *chan;
> + int ret;
> +
> +retry:
> + candidate = NULL;
> +
> + /*
> + * walk the list of channels registered with the current instance and
> + * find one that is currently unused
> + */
> + list_for_each_entry(chan, &info->device->channels, device_node)
> + if (chan->client_count == 0) {
> + candidate = chan;
> + break;
> + }
> +
> + if (!candidate)
> + return NULL;
> +
> + /*
> + * dma_get_slave_channel will return NULL if we lost a race between
> + * the lookup and the reservation
> + */
> + chan = dma_get_slave_channel(candidate);
> + if (!chan)
> + goto retry;
I think it will be better to implement this functionality in the core. This
means we can hold the dma_list_mutex and don't have to do this retry loop
and do not have to peek at the client_count field in non-core code.
Something like dma_get_free_slave_channel(), which would call
private_candidate() followed by dma_chan_get().
> +
> + if (info->post_alloc) {
> + ret = info->post_alloc(chan, dma_spec);
If you need to do something at the end of the function I think it is nicer
to just wrap this function with your own function instead of adding a callback.
- Lars
next prev parent reply other threads:[~2013-11-26 7:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-26 1:25 Stephen Warren
2013-11-26 7:40 ` Lars-Peter Clausen [this message]
2013-11-26 16:57 ` Dan Williams
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=5294506C.60701@metafoo.de \
--to=lars@metafoo.de \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=swarren@nvidia.com \
--cc=swarren@wwwdotorg.org \
--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
Powered by JetHome