RE: [PATCH 6/6] intel_mid_dma: change the slave interface

From: Koul, Vinod
Date: Mon Oct 11 2010 - 01:11:50 EST



On Fri, Oct 8, 2010 at 10:58 PM, dan.j.williams@xxxxxxxxx wrote:
> On Mon, Oct 4, 2010 at 3:38 AM, Vinod Koul <vinod.koul@xxxxxxxxx> wrote:
> > In 2.6.36 kernel, dma slave control command was introduced,
> > this patch changes the intel-mid-dma driver to this
> > new kernel slave interface
> >
> > Signed-off-by: Vinod Koul <vinod.koul@xxxxxxxxx>
> > ---
> [..]
> > +static int dma_slave_control(struct dma_chan *chan, unsigned long arg)
> > +{
> > +       struct intel_mid_dma_chan       *midc = to_intel_mid_dma_chan(chan);
> > +       struct dma_slave_config  *slave = (struct dma_slave_config *)arg;
> > +       struct intel_mid_dma_slave *mid_slave;
> > +
> > +       BUG_ON(!midc);
> > +       BUG_ON(!slave);
> > +       pr_debug("MDMA: slave control called\n");
> > +
> > +       mid_slave = to_intel_mid_dma_slave(slave);
>
> I know this was the initial recommendation to support custom
> extensions to dma_slave_config, but this isn't safe. How does this
> routine know that that 'slave' is embedded in an intel_mid_dma_slave
> structure. I applied it as is, but I think we need a better approach.
>
> Maybe a per device alloc_dma_slave_config() such that ->dma_control()
> can assume the driver allocated the dma_slave_config. As it stands
> nothing in the calling convention guarantees type safety.


Dan,
Thanks for applying the patches.

I had thought thru this earlier, yes I agree that it is not fully safe to
*assume* that intel_mid_dma_slave embeds the dma_slave_config structure.

But we can also argue that since this is DMA_SLAVE device and device needs to
always pass controller specific arguments and hence knows about this controller,
so will have such a thing in place.
Yes but this can be easily abused.

Another alternative is to maintain the channel->private pointer for these sort
of details as we were doing previously...

Thoughts...?

~Vinod



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/