From: Arnd Bergmann <arnd@arndb.de>
To: Andrew Bresticker <abrestic@chromium.org>
Cc: Vinod Koul <vinod.koul@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Grant Likely <grant.likely@linaro.org>,
James Hartley <james.hartley@imgtec.com>,
James Hogan <james.hogan@imgtec.com>,
Ezequiel Garcia <ezequiel.garcia@imgtec.com>,
Damien Horsley <Damien.Horsley@imgtec.com>,
dmaengine@vger.kernel.org,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] dmaengine: Add driver for IMG MDC
Date: Fri, 14 Nov 2014 00:14:05 +0100 [thread overview]
Message-ID: <23608147.9L5xhJDu6b@wuerfel> (raw)
In-Reply-To: <CAL1qeaGvaHmfCHAhVejEqtV-dMVTEGprZJZPOevOmXaSyf8Uyw@mail.gmail.com>
On Thursday 13 November 2014 15:07:06 Andrew Bresticker wrote:
> On Thu, Nov 13, 2014 at 2:13 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Thursday 13 November 2014 12:58:08 Andrew Bresticker wrote:
> >> +
> >> +static bool mdc_filter_fn(struct dma_chan *chan, void *fn_param)
> >> +{
> >> + struct mdc_filter_data *data = fn_param;
> >> + struct mdc_chan *mchan;
> >> +
> >> + if (chan->device->dev->driver == &mdc_dma_driver.driver) {
> >> + mchan = to_mdc_chan(chan);
> >> + if (!(data->mask & BIT(mchan->chan_nr)))
> >> + return false;
> >> + mchan->periph = data->periph;
> >> + mchan->thread = data->thread;
> >> + return true;
> >> + }
> >> + return false;
> >> +}
> >> +
> >> +static struct dma_chan *mdc_of_xlate(struct of_phandle_args *dma_spec,
> >> + struct of_dma *ofdma)
> >> +{
> >> + struct mdc_dma *mdma = ofdma->of_dma_data;
> >> + struct mdc_filter_data data;
> >> +
> >> + if (dma_spec->args_count != 3)
> >> + return NULL;
> >> +
> >> + data.periph = dma_spec->args[0];
> >> + data.mask = dma_spec->args[1];
> >> + data.thread = dma_spec->args[2];
> >> +
> >> + return dma_request_channel(mdma->dma_dev.cap_mask, mdc_filter_fn,
> >> + &data);
> >> +}
> >
> > The filter function is broken if you ever have multiple instances
> > of the device. Better avoid calling dma_request_channel and scan
> > the channels that the device knows about.
>
> It seems unlikely that there would be multiple instances of this IP in
> a system, but it doesn't hurt to be safe. Perhaps instead of
> iterating through the list here I could extend struct mdc_filter_data
> to include a pointer to the struct dma_device corresponding to this
> instance of the MDC and compare based on that.
You still need to iterate through all channels of all dma engines
in the system. Since you have the pointer to the engine here,
just go through the channels that you already know are there.
Unfortunately, the mask prevents you from just using
dma_get_any_slave_channel(), that would be the easiest approach
that we prefer in most drivers these days.
Arnd
next prev parent reply other threads:[~2014-11-13 23:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 20:58 [PATCH 0/2] dmaengine: Support for IMG MDC Andrew Bresticker
2014-11-13 20:58 ` [PATCH 1/2] dmaengine: Add binding document " Andrew Bresticker
2014-11-13 20:58 ` [PATCH 2/2] dmaengine: Add driver " Andrew Bresticker
2014-11-13 22:13 ` Arnd Bergmann
2014-11-13 23:07 ` Andrew Bresticker
2014-11-13 23:14 ` Arnd Bergmann [this message]
2014-11-13 23:40 ` Andrew Bresticker
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=23608147.9L5xhJDu6b@wuerfel \
--to=arnd@arndb.de \
--cc=Damien.Horsley@imgtec.com \
--cc=abrestic@chromium.org \
--cc=dan.j.williams@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=ezequiel.garcia@imgtec.com \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=james.hartley@imgtec.com \
--cc=james.hogan@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.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