[PATCH] usb: musb: host: Issue a memory barrier before staring the DMA

Russell King - ARM Linux linux at arm.linux.org.uk
Thu Aug 5 09:12:12 EDT 2010


On Thu, Aug 05, 2010 at 06:24:31PM +0530, Maulik wrote:
> > > Index: omap4_integration/drivers/usb/musb/musb_host.c
> > > ===================================================================
> > > --- omap4_integration.orig/drivers/usb/musb/musb_host.c
> > > +++ omap4_integration/drivers/usb/musb/musb_host.c
> > > @@ -628,6 +628,11 @@ static bool musb_tx_dma_program(struct d
> > >  	u8			mode;
> > >
> > >  #ifdef	CONFIG_USB_INVENTRA_DMA
> > > +	/*
> > > +	 * Ensure the data reaches to main memory before starting
> > > +	 * DMA transfer
> > > +	 */
> > > +	wmb();
> > 
> >     Are you sure this is only needed for Inventra DMA?
> 
> Yes. This is seen only on SMP system such as OMAP4 which uses Inventra DMA.
> We did not see the issue when SMP is disabled. 

It'll be far safer to actually consider what's going on here, and realise
that it's NOT a SMP issue but a write ordering issue.

What that means is that as OMAP systems progress, and the ordering becomes
weaker, you will see the problem appearing on non-SMP.  So why not fix it
properly now and avoid having to revisit this with yet more patches.

Think about what happens if writes to memory (DMA or otherwise) in the
program become mis-ordered with writes to the device registers - and fix
anything where that ordering matters by adding the necessary barriers.
This will save you having to constantly revisit the driver time and time
again to move the barriers around.



More information about the linux-arm-kernel mailing list