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,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] dmaengine: Add driver for IMG MDC
Date: Thu, 13 Nov 2014 23:13:10 +0100 [thread overview]
Message-ID: <11336807.gWpZoH7Aih@wuerfel> (raw)
In-Reply-To: <1415912288-26926-3-git-send-email-abrestic@chromium.org>
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.
> +
> +#define PISTACHIO_CR_PERIPH_DMA_ROUTE(ch) (0x120 + 0x4 * ((ch) / 4))
> +#define PISTACHIO_CR_PERIPH_DMA_ROUTE_SHIFT(ch) (8 * ((ch) % 4))
> +#define PISTACHIO_CR_PERIPH_DMA_ROUTE_MASK 0x3f
> +
> +static void pistachio_mdc_enable_chan(struct mdc_chan *mchan)
> +{
> + struct mdc_dma *mdma = mchan->mdma;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&mdma->lock, flags);
> + regmap_update_bits(mdma->periph_regs,
> + PISTACHIO_CR_PERIPH_DMA_ROUTE(mchan->chan_nr),
> + PISTACHIO_CR_PERIPH_DMA_ROUTE_MASK <<
> + PISTACHIO_CR_PERIPH_DMA_ROUTE_SHIFT(mchan->chan_nr),
> + mchan->periph <<
> + PISTACHIO_CR_PERIPH_DMA_ROUTE_SHIFT(mchan->chan_nr));
> + spin_unlock_irqrestore(&mdma->lock, flags);
> +}
> +
> +static void pistachio_mdc_disable_chan(struct mdc_chan *mchan)
> +{
> + struct mdc_dma *mdma = mchan->mdma;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&mdma->lock, flags);
> + regmap_update_bits(mdma->periph_regs,
> + PISTACHIO_CR_PERIPH_DMA_ROUTE(mchan->chan_nr),
> + PISTACHIO_CR_PERIPH_DMA_ROUTE_MASK <<
> + PISTACHIO_CR_PERIPH_DMA_ROUTE_SHIFT(mchan->chan_nr),
> + 0);
> + spin_unlock_irqrestore(&mdma->lock, flags);
> +}
Regmap has its own locking, no need to add another level.
Arnd
next prev parent reply other threads:[~2014-11-13 22:13 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 [this message]
2014-11-13 23:07 ` Andrew Bresticker
2014-11-13 23:14 ` Arnd Bergmann
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=11336807.gWpZoH7Aih@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