lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL1qeaGvaHmfCHAhVejEqtV-dMVTEGprZJZPOevOmXaSyf8Uyw@mail.gmail.com>
Date:	Thu, 13 Nov 2014 15:07:06 -0800
From:	Andrew Bresticker <abrestic@...omium.org>
To:	Arnd Bergmann <arnd@...db.de>
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" <devicetree@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] dmaengine: Add driver for IMG MDC

On Thu, Nov 13, 2014 at 2:13 PM, Arnd Bergmann <arnd@...db.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.

>> +
>> +#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.

Ah, right.  I'll drop the locking.
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ