Re: [PATCH v2 13/29] nios2: DMA mapping API

From: rkuo
Date: Mon Jul 28 2014 - 11:48:26 EST


On Thu, Jul 24, 2014 at 02:05:16PM +0200, Arnd Bergmann wrote:
> > >> +void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
> > >> + size_t size, enum dma_data_direction direction)
> > >> +{
> > >> + BUG_ON(!valid_dma_direction(direction));
> > >> +
> > >> + __dma_sync(phys_to_virt(dma_handle), size, direction);
> > >> +}
> > >> +EXPORT_SYMBOL(dma_sync_single_for_cpu);
> > >> +
> > >> +void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
> > >> + size_t size, enum dma_data_direction direction)
> > >> +{
> > >> + BUG_ON(!valid_dma_direction(direction));
> > >> +
> > >> + __dma_sync(phys_to_virt(dma_handle), size, direction);
> > >> +}
> > >> +EXPORT_SYMBOL(dma_sync_single_for_device);
> > >
> > > More importantly: you do the same operation for both _for_cpu and _for_device.
> > > I assume your CPU can never do speculative cache prefetches, so it's not
> > > incorrect, but you do twice the number of invalidations and flushes that
> > > you need.
> > >
> > > Why would you do anything for _for_cpu here?
> > I am a bit confused for _for_cpu and _for_device here. I found some
> > architectures like c6x and hexagon have same operation for both
> > _for_cpu and _for_device as well.
>
> (adding their maintainers to cc)
>
> Yes, you are right, they seem to have the same bug and could see a noticeable
> DMA performance improvement if they change it as well.
>

Yep that's a bug. Thanks for pointing this out.


-Richard Kuo


--

Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
--
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/