lkml.org 
[lkml]   [2004]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch] dma_sync_to_device
On Wed, 11 Feb 2004 11:57:25 -0700
Deepak Saxena <dsaxena@plexity.net> wrote:

> > 1) pci_map_single(), device DMA's from the buffer.
> >
> > 2) pci_dma_sync_single(). Cpu writes some new command or
> > status flag into the buffer.
> >
> > 3) pci_dma_sync_to_device_single(), now device is asked to DMA from the buffer
> > again.
> >
> > Cache flushes are needed on MIPS for both step #2 and #3, and different kinds of
> > flushes in fact.
> >
> > Do you understand the need for this now?
>
> Not really. Steps 2 and 3 can be done by simply calling pci_dma_sync_single()
> with the appropriate direction flag.

No, direction says what device did or is going to do with the buffer.

> I don't understand why a
> pci_dma_sync_single() is needed after the device does a DMA from the
> buffer and before the CPU writes a command.

To flush PCI controller caches.

> After the CPU writes data to the
> buffer, it can do a pci_dma_sync_single(..., DMA_TO_DEVICE), which causes
> a cache flush. Isn't this what we're already doing today?

It is different. pci_dma_sync_single(..., DMA_TO_DEVICE), on MIPS for example,
would do absolutely nothing. At mapping time, the local cpu cache was flushed,
and assuming the MIPS pci controllers don't have caches of their own there is
nothing to flush there either.

Whereas pci_dma_sync_device_single() would flush the dirty lines from the cpu
caches. In fact, it will perform the same CPU cache flushes as pci_map_single()
did, using MIPS as the example again.

New sequence:

1) pci_map_single(..., DMA_TO_DEVICE). Flush dirty data from cpu caches to memory,
so device may see it.

2) device reads buffer

3) pci_dma_sync_single(... DMA_TO_DEVICE). If PCI controller has caches, flush them.

4) CPU writes new buffer data.

5) pci_dma_sync_device_single(... DMA_TO_DEVICE). Like #1, flush dirty data from cpu
caches to memory.

6) Device reads buffer.

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

\
 
 \ /
  Last update: 2005-03-22 14:00    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site