Re: [BUG] x86_64 pci_map_sg modifies sg list - fails multiple map/unmaps

From: Berkley Shands
Date: Wed Jan 07 2004 - 11:35:36 EST


Here is a somewhat more robust (and trivial) fix for the sg iommu
problem on the x86_64. Still does not correct the sg list modification logic though :-)

--- /raid0/kernels/linux/arch/x86_64/kernel/pci-gart.c 2004-01-05 10:16:11.000000000 -0600
+++ pci-gart.c 2004-01-07 10:14:47.000000000 -0600
@@ -446,6 +446,16 @@
return 0;
out = 0;
start = 0;
+
+ /* see if we are recovering from an error */
+
+ if (sg[0].oldlength) {
+ printk(KERN_WARNING "Recovering sg list for %s\n", dev->slot_name);
+ for (i = 0; i < nents; i++) {
+ sg[i].length = sg[i].oldlength;
+ }
+ }
+
for (i = 0; i < nents; i++) {
struct scatterlist *s = &sg[i];
dma_addr_t addr = page_to_phys(s->page) + s->offset;
@@ -453,6 +463,7 @@
BUG_ON(s->length == 0);

size += s->length;
+ s->oldlength = s->length;

/* Handle the previous not yet processed entries */
if (i > start) {

--- /raid0/kernels/linux/include/asm-x86_64/scatterlist.h 2003-12-17 20:59:39.000000000 -0600
+++ scatterlist.h 2004-01-07 10:01:06.000000000 -0600
@@ -5,6 +5,7 @@
struct page *page;
unsigned int offset;
unsigned int length;
+ unsigned int oldlength;
dma_addr_t dma_address;
};


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