public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch] dma_sync_to_device
@ 2004-02-10 17:31 Martin Diehl
  2004-02-10 18:42 ` David S. Miller
  2004-02-11  6:17 ` Deepak Saxena
  0 siblings, 2 replies; 23+ messages in thread
From: Martin Diehl @ 2004-02-10 17:31 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel


Hi Dave,

last fall we agreed there is a dma call missing to sync streaming out dma 
mappings before giving the buffer back to the device. I've sent you a 
patch which you liked IIRC. However, I wasn't repeatedly polling you for 
actually inclusion due to the 2.6 stabilization period.

Anyway, I see now other related stuff (like dma_pool patches) getting in
so I'm wondering whether it might be the right moment now - right after 
2.6.3-final I'd suggest. So let me resend and ask for application. I've 
just retested with 2.6.3-rc2 and verified the old patch still applies 
cleanly and works as expected.

The patch does:
* provide generic dma_sync_to_device_{single|sg} api
* add i386 pci implementation
* related Documentation/DMA-mapping update

Thanks,
Martin

-----------------------

--- linux-2.6.0-test8/include/asm-i386/dma-mapping.h	Wed Oct  8 21:24:53 2003
+++ v2.6.0-test8-md/include/asm-i386/dma-mapping.h	Tue Oct 21 10:56:45 2003
@@ -92,6 +92,20 @@
 	flush_write_buffers();
 }
 
+static inline void
+dma_sync_to_device_single(struct device *dev, dma_addr_t dma_handle, size_t size,
+		enum dma_data_direction direction)
+{
+	flush_write_buffers();
+}
+
+static inline void
+dma_sync_to_device_sg(struct device *dev, struct scatterlist *sg, int nelems,
+		 enum dma_data_direction direction)
+{
+	flush_write_buffers();
+}
+
 static inline int
 dma_supported(struct device *dev, u64 mask)
 {
--- linux-2.6.0-test8/include/asm-generic/pci-dma-compat.h	Wed Oct  8 21:24:02 2003
+++ v2.6.0-test8-md/include/asm-generic/pci-dma-compat.h	Tue Oct 21 10:55:09 2003
@@ -84,4 +84,18 @@
 	dma_sync_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
 }
 
+static inline void
+pci_dma_sync_to_device_single(struct pci_dev *hwdev, dma_addr_t dma_handle,
+		    size_t size, int direction)
+{
+	dma_sync_to_device_single(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_to_device_sg(struct pci_dev *hwdev, struct scatterlist *sg,
+		int nelems, int direction)
+{
+	dma_sync_to_device_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+}
+
 #endif
--- linux-2.6.0-test8/Documentation/DMA-mapping.txt	Wed Oct  8 21:24:06 2003
+++ v2.6.0-test8-md/Documentation/DMA-mapping.txt	Tue Oct 21 11:27:17 2003
@@ -543,8 +543,11 @@
 all bus addresses.
 
 If you need to use the same streaming DMA region multiple times and touch
-the data in between the DMA transfers, just map it with
-pci_map_{single,sg}, and after each DMA transfer call either:
+the data in between the DMA transfers, the buffer needs to be synced
+depending on the transfer direction.
+
+When reading from the device, just map it with pci_map_{single,sg},
+and after each DMA transfer call either:
 
 	pci_dma_sync_single(dev, dma_handle, size, direction);
 
@@ -553,6 +556,20 @@
 	pci_dma_sync_sg(dev, sglist, nents, direction);
 
 as appropriate.
+
+When writing to the mapped the buffer, prepare the data and
+then before giving the buffer to the hardware call either:
+
+	pci_dma_sync_to_device_single(dev, dma_handle, size, direction);
+
+or:
+
+	pci_dma_sync_to_device_sg(dev, sglist, nents, direction);
+
+as appropriate.
+
+For bidirectional mappings the corresponding calls are required before and
+after passing ownership between cpu and hardware.
 
 After the last DMA transfer call one of the DMA unmap routines
 pci_unmap_{single,sg}. If you don't touch the data from the first pci_map_*


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [Patch] dma_sync_to_device
@ 2004-02-13 14:27 James Bottomley
  2004-02-14  8:51 ` Martin Diehl
  0 siblings, 1 reply; 23+ messages in thread
From: James Bottomley @ 2004-02-13 14:27 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Martin Diehl

Just to be sure we eliminate all confusion (and it amazes me how
frequently this comes up), could you add some words DMA-mapping.txt to
make clear that this new API does not address PCI posting (which is a
problem with onward write cache flushing in the PCI bridge)---otherwise
I can see device driver writers thinking that
pci_dma_sync_to_device_single(... DMA_TO_DEVICE) will flush posted
writes.

Thanks,

James



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2004-02-14 23:18 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-10 17:31 [Patch] dma_sync_to_device Martin Diehl
2004-02-10 18:42 ` David S. Miller
2004-02-10 18:59   ` Martin Diehl
2004-02-11  6:17 ` Deepak Saxena
2004-02-11  6:51   ` Martin Diehl
2004-02-11 16:39     ` Deepak Saxena
2004-02-11 17:51       ` David S. Miller
2004-02-11 18:18     ` Matt Porter
2004-02-11 18:30       ` David S. Miller
2004-02-11 18:57         ` Deepak Saxena
2004-02-11 19:08           ` David S. Miller
2004-02-12  3:46             ` Deepak Saxena
2004-02-12  3:58               ` David S. Miller
2004-02-13  1:49             ` Jamie Lokier
2004-02-14  7:24               ` David S. Miller
2004-02-11 19:23         ` Matt Porter
2004-02-11 19:30           ` David S. Miller
2004-02-11 18:43       ` linux-2.6.2 Kernel Problem Elikster
2004-02-14 11:51         ` Adrian Bunk
  -- strict thread matches above, loose matches on Subject: below --
2004-02-13 14:27 [Patch] dma_sync_to_device James Bottomley
2004-02-14  8:51 ` Martin Diehl
2004-02-14 22:34   ` James Bottomley
2004-02-14 23:18   ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox