linux-mips
[Top] [All Lists]

Re: 2.4 pci_dma_sync_sg fix

To: ralf@linux-mips.org
Subject: Re: 2.4 pci_dma_sync_sg fix
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Sat, 03 Jul 2004 21:44:11 +0900 (JST)
Cc: linux-mips@linux-mips.org
In-reply-to: <20040701135919.GA6906@linux-mips.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20040701132240.GA6219@linux-mips.org> <20040701.224535.71082878.anemo@mba.ocn.ne.jp> <20040701135919.GA6906@linux-mips.org>
Sender: linux-mips-bounce@linux-mips.org
>>>>> 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
 }
 

<Prev in Thread] Current Thread [Next in Thread>