RE: [patch 2.6.14-rc2 0/5] swiotlb maintenance and x86_64 dma_sync_single_range_for_{cpu,device}

Luck, Tony
2005-09-26T22:08:23Z

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

>Well, now, this is a quandry isn't it... Actually, I'm inclined to
>agree with you.
>
>Tony, et al., care to restate your reasoning for moving it under
>drivers/pci?

Historically swiotlb.c was written with just PCI in mind (hence
all the comments ("... implement the PCI DMA API", "The PCI address
to use is returned", "teardown the PCI dma mapping") and a few
error messages ("PCI-DMA: Out of SW-IOMMU space ...", "PCI-DMA: Memory
would be corrupted", "PCI-DMA: Random memory would be DMAed").
Perhaps back then the only options were PCI and ISA????

Matthew is probably technically right in that this is a more
generic interface ... but is it actually being used for anything
other than PCI? Will it ever be so used?

Ignoring the comments and error messages, the attached patch
removed the <linux/pci.h> and <asm/pci.h> includes (and adds a
couple of others that are then needed, and converts a few
PCI_DMA_* defines to DMA_* ones that sound like they mean the
same thing). Compiles, but not tested.

-Tony

[-- Attachment #2: sw.patch --]
[-- Type: application/octet-stream, Size: 1031 bytes --]

--- a/arch/ia64/lib/swiotlb.c 2005-09-26 13:03:04.000000000 -0700
+++ b/arch/ia64/lib/swiotlb.c 2005-09-26 14:54:38.000000000 -0700
@@ -15,17 +15,17 @@
*/

#include <linux/cache.h>
+#include <linux/dma-mapping.h>
#include <linux/mm.h>
#include <linux/module.h>
-#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/ctype.h>

#include <asm/io.h>
-#include <asm/pci.h>
#include <asm/dma.h>
+#include <asm/scatterlist.h>

#include <linux/init.h>
#include <linux/bootmem.h>
@@ -391,9 +391,9 @@
"device %s\n", size, dev ? dev->bus_id : "?");

if (size > io_tlb_overflow && do_panic) {
- if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
+ if (dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)
panic("PCI-DMA: Memory would be corrupted\n");
- if (dir == PCI_DMA_TODEVICE || dir == PCI_DMA_BIDIRECTIONAL)
+ if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
panic("PCI-DMA: Random memory would be DMAed\n");
}
}