All of lore.kernel.org
 help / color / mirror / Atom feed
* 2.4 pci_dma_sync_sg fix
@ 2004-07-01 13:21 Atsushi Nemoto
  2004-07-01 13:22 ` Ralf Baechle
  0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2004-07-01 13:21 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

pci_dma_sync_sg in 2.4 tree seems broken.  pci_map_sg were fixed a
while ago.  Please fix pci_dma_sync_sg also.

Here is a patch.

Index: pci.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/pci.h,v
retrieving revision 1.24.2.16
diff -u -r1.24.2.16 pci.h
--- pci.h	17 Nov 2003 01:07:45 -0000	1.24.2.16
+++ pci.h	1 Jul 2004 13:10:48 -0000
@@ -270,20 +270,28 @@
  */
 static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
 				   struct scatterlist *sg,
-				   int nelems, int direction)
+				   int nents, int direction)
 {
-#ifdef CONFIG_NONCOHERENT_IO
 	int i;
-#endif
 
 	if (direction == PCI_DMA_NONE)
 		out_of_line_bug();
 
-	/* Make sure that gcc doesn't leave the empty loop body.  */
-#ifdef CONFIG_NONCOHERENT_IO
-	for (i = 0; i < nelems; i++, sg++)
-		dma_cache_wback_inv((unsigned long)sg->address, sg->length);
-#endif
+	for (i = 0; i < nents; i++, sg++) {
+		if (sg->address && sg->page)
+			out_of_line_bug();
+		else if (!sg->address && !sg->page)
+			out_of_line_bug();
+
+		if (sg->address) {
+			dma_cache_wback_inv((unsigned long)sg->address,
+			                    sg->length);
+		} else {
+			dma_cache_wback_inv((unsigned long)
+				(page_address(sg->page) + sg->offset),
+				sg->length);
+		}
+	}
 }
 
 /*
---
Atsushi Nemoto

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

* Re: 2.4 pci_dma_sync_sg fix
  2004-07-01 13:21 2.4 pci_dma_sync_sg fix Atsushi Nemoto
@ 2004-07-01 13:22 ` Ralf Baechle
  2004-07-01 13:45   ` Atsushi Nemoto
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2004-07-01 13:22 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On Thu, Jul 01, 2004 at 10:21:20PM +0900, Atsushi Nemoto wrote:

> pci_dma_sync_sg in 2.4 tree seems broken.  pci_map_sg were fixed a
> while ago.  Please fix pci_dma_sync_sg also.

Leave the #ifdef stuff there - or otherwise gcc might optimize this into
empty loops ...

  Ralf

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

* Re: 2.4 pci_dma_sync_sg fix
  2004-07-01 13:22 ` Ralf Baechle
@ 2004-07-01 13:45   ` Atsushi Nemoto
  2004-07-01 13:59     ` Ralf Baechle
  0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2004-07-01 13:45 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

>>>>> On Thu, 1 Jul 2004 15:22:40 +0200, Ralf Baechle <ralf@linux-mips.org> said:

ralf> Leave the #ifdef stuff there - or otherwise gcc might optimize
ralf> this into empty loops ...

The loop contains paranoid out_of_line_bug, so it never be optimized
to empty.

---
Atsushi Nemoto

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

* Re: 2.4 pci_dma_sync_sg fix
  2004-07-01 13:45   ` Atsushi Nemoto
@ 2004-07-01 13:59     ` Ralf Baechle
  2004-07-03 12:44       ` Atsushi Nemoto
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2004-07-01 13:59 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On Thu, Jul 01, 2004 at 10:45:35PM +0900, Atsushi Nemoto wrote:

> >>>>> On Thu, 1 Jul 2004 15:22:40 +0200, Ralf Baechle <ralf@linux-mips.org> said:
> 
> ralf> Leave the #ifdef stuff there - or otherwise gcc might optimize
> ralf> this into empty loops ...
> 
> The loop contains paranoid out_of_line_bug, so it never be optimized
> to empty.

Indeed and I think that's a bit of overkill.  I've never seen these
assertions catch any bugs - and 2.4 isn't exactly new anymore.  Anyway,
even if the loop was empty gcc would not eleminate it.

  Ralf

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

* Re: 2.4 pci_dma_sync_sg fix
  2004-07-01 13:59     ` Ralf Baechle
@ 2004-07-03 12:44       ` Atsushi Nemoto
  0 siblings, 0 replies; 5+ messages in thread
From: Atsushi Nemoto @ 2004-07-03 12:44 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

>>>>> On Thu, 1 Jul 2004 15:59:19 +0200, Ralf Baechle <ralf@linux-mips.org> said:

>> The loop contains paranoid out_of_line_bug, so it never be
>> optimized to empty.

ralf> Indeed and I think that's a bit of overkill.  I've never seen
ralf> these assertions catch any bugs - and 2.4 isn't exactly new
ralf> anymore.  Anyway, even if the loop was empty gcc would not
ralf> eleminate it.

Then how about this?

Index: pci.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/pci.h,v
retrieving revision 1.24.2.16
diff -u -r1.24.2.16 pci.h
--- pci.h	17 Nov 2003 01:07:45 -0000	1.24.2.16
+++ pci.h	3 Jul 2004 12:30:36 -0000
@@ -281,8 +281,16 @@
 
 	/* Make sure that gcc doesn't leave the empty loop body.  */
 #ifdef CONFIG_NONCOHERENT_IO
-	for (i = 0; i < nelems; i++, sg++)
-		dma_cache_wback_inv((unsigned long)sg->address, sg->length);
+	for (i = 0; i < nelems; i++, sg++) {
+		if (sg->address) {
+			dma_cache_wback_inv((unsigned long)sg->address,
+			                    sg->length);
+		} else {
+			dma_cache_wback_inv((unsigned long)
+				(page_address(sg->page) + sg->offset),
+				sg->length);
+		}
+	}
 #endif
 }
 

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

end of thread, other threads:[~2004-07-03 12:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-01 13:21 2.4 pci_dma_sync_sg fix Atsushi Nemoto
2004-07-01 13:22 ` Ralf Baechle
2004-07-01 13:45   ` Atsushi Nemoto
2004-07-01 13:59     ` Ralf Baechle
2004-07-03 12:44       ` Atsushi Nemoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.