[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <11336807.gWpZoH7Aih@wuerfel>
Date: Thu, 13 Nov 2014 23:13:10 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Andrew Bresticker <abrestic@...omium.org>
Cc: Vinod Koul <vinod.koul@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Rob Herring <robh+dt@...nel.org>,
Pawel Moll <pawel.moll@....com>,
Mark Rutland <mark.rutland@....com>,
Ian Campbell <ijc+devicetree@...lion.org.uk>,
Kumar Gala <galak@...eaurora.org>,
Grant Likely <grant.likely@...aro.org>,
James Hartley <james.hartley@...tec.com>,
James Hogan <james.hogan@...tec.com>,
Ezequiel Garcia <ezequiel.garcia@...tec.com>,
Damien Horsley <Damien.Horsley@...tec.com>,
dmaengine@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] dmaengine: Add driver for IMG MDC
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists