patch-2.4.21 linux-2.4.21/arch/x86_64/kernel/pci-dma.c

Next file: linux-2.4.21/arch/x86_64/kernel/pci-gart.c
Previous file: linux-2.4.21/arch/x86_64/kernel/nmi.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/arch/x86_64/kernel/pci-dma.c linux-2.4.21/arch/x86_64/kernel/pci-dma.c
@@ -37,16 +37,16 @@
  	 */
  	for (i = 0; i < nents; i++ ) {
 		struct scatterlist *s = &sg[i];
- 		if (s->address) {
+		int flush = (i == nents-1);
+		void *addr = s->address; 
+		if (addr) 
 			BUG_ON(s->page || s->offset); 
- 			s->dma_address = pci_map_single(hwdev, s->address, s->length, 
-							direction); 
- 		} else if (s->page) { 
-			s->dma_address = pci_map_page(hwdev, s->page, s->offset,
-						      s->length, direction); 
-		} else
+		else if (s->page)
+			addr = page_address(s->page) + s->offset; 
+		else
 			BUG(); 
-
+		s->dma_address = __pci_map_single(hwdev, addr, s->length,
+						  direction, flush); 
 		if (unlikely(s->dma_address == bad_dma_address))
 			goto error; 
  	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)