pci_dma_error

Anton Blanchard anton at samba.org
Mon Mar 22 01:33:50 EST 2004


Hi,

pci_dma_error() just went into 2.6. In order to catch the drivers that
have used NO_TCE directly, Im proposing the following patch.

Anton

===== iommu.c 1.2 vs edited =====
--- 1.2/arch/ppc64/kernel/iommu.c	Thu Mar  4 00:26:23 2004
+++ edited/iommu.c	Mon Mar 22 01:30:18 2004
@@ -73,7 +73,7 @@
 	if (unlikely(npages) == 0) {
 		if (printk_ratelimit())
 			WARN_ON(1);
-		return NO_TCE;
+		return PCI_DMA_ERROR_CODE;
 	}

 	if (handle && *handle)
@@ -109,7 +109,7 @@
 			goto again;
 		} else {
 			/* Third failure, give up */
-			return NO_TCE;
+			return PCI_DMA_ERROR_CODE;
 		}
 	}

@@ -143,15 +143,15 @@
 		       unsigned int npages, int direction)
 {
 	unsigned long entry, flags;
-	dma_addr_t ret = NO_TCE;
+	dma_addr_t ret = PCI_DMA_ERROR_CODE;

 	spin_lock_irqsave(&(tbl->it_lock), flags);

 	entry = iommu_range_alloc(tbl, npages, NULL);

-	if (unlikely(entry == NO_TCE)) {
+	if (unlikely(entry == PCI_DMA_ERROR_CODE)) {
 		spin_unlock_irqrestore(&(tbl->it_lock), flags);
-		return NO_TCE;
+		return PCI_DMA_ERROR_CODE;
 	}

 	entry += tbl->it_offset;	/* Offset into real TCE table */
@@ -262,7 +262,7 @@
 		DBG("  - vaddr: %lx, size: %lx\n", vaddr, slen);

 		/* Handle failure */
-		if (unlikely(entry == NO_TCE)) {
+		if (unlikely(entry == PCI_DMA_ERROR_CODE)) {
 			if (printk_ratelimit())
 				printk(KERN_INFO "iommu_alloc failed, tbl %p vaddr %lx"
 				       " npages %lx\n", tbl, vaddr, npages);
@@ -326,7 +326,7 @@
 	 */
 	if (outcount < nelems) {
 		outs++;
-		outs->dma_address = NO_TCE;
+		outs->dma_address = PCI_DMA_ERROR_CODE;
 		outs->dma_length = 0;
 	}
 	return outcount;
===== pci_iommu.c 1.2 vs edited =====
--- 1.2/arch/ppc64/kernel/pci_iommu.c	Thu Mar  4 00:26:23 2004
+++ edited/pci_iommu.c	Mon Mar 22 01:30:23 2004
@@ -82,7 +82,7 @@
 	if (order >= IOMAP_MAX_ORDER) {
 		printk("PCI_DMA: pci_alloc_consistent size too large: 0x%lx\n",
 			size);
-		return (void *)NO_TCE;
+		return (void *)PCI_DMA_ERROR_CODE;
 	}

 	tbl = devnode_table(hwdev);
@@ -101,7 +101,7 @@
 	/* Set up tces to cover the allocated range */
 	mapping = iommu_alloc(tbl, ret, npages, PCI_DMA_BIDIRECTIONAL);

-	if (mapping == NO_TCE) {
+	if (mapping == PCI_DMA_ERROR_CODE) {
 		free_pages((unsigned long)ret, order);
 		ret = NULL;
 	} else
@@ -139,7 +139,7 @@
 				size_t size, int direction)
 {
 	struct iommu_table * tbl;
-	dma_addr_t dma_handle = NO_TCE;
+	dma_addr_t dma_handle = PCI_DMA_ERROR_CODE;
 	unsigned long uaddr;
 	unsigned int npages;

@@ -153,7 +153,7 @@

 	if (tbl) {
 		dma_handle = iommu_alloc(tbl, vaddr, npages, direction);
-		if (dma_handle == NO_TCE) {
+		if (dma_handle == PCI_DMA_ERROR_CODE) {
 			if (printk_ratelimit())  {
 				printk(KERN_INFO "iommu_alloc failed, tbl %p vaddr %p npages %d\n",
 				       tbl, vaddr, npages);
===== vio.c 1.11 vs edited =====
--- 1.11/arch/ppc64/kernel/vio.c	Tue Mar 16 22:30:36 2004
+++ edited/vio.c	Mon Mar 22 01:30:27 2004
@@ -419,7 +419,7 @@
 			  size_t size, int direction )
 {
 	struct iommu_table *tbl;
-	dma_addr_t dma_handle = NO_TCE;
+	dma_addr_t dma_handle = PCI_DMA_ERROR_CODE;
 	unsigned long uaddr;
 	unsigned int npages;

@@ -504,7 +504,7 @@
 	/* It is easier to debug here for the drivers than in the tce tables.*/
  	if(order >= IOMAP_MAX_ORDER) {
  		printk("VIO_DMA: vio_alloc_consistent size to large: 0x%lx \n", size);
- 		return (void *)NO_TCE;
+ 		return (void *)PCI_DMA_ERROR_CODE;
  	}

 	tbl = dev->iommu_table;
@@ -517,7 +517,7 @@
 			memset(ret, 0, npages << PAGE_SHIFT);
 			/* Set up tces to cover the allocated range */
 			tce = iommu_alloc(tbl, ret, npages, PCI_DMA_BIDIRECTIONAL);
-			if (tce == NO_TCE) {
+			if (tce == PCI_DMA_ERROR_CODE) {
 				PPCDBG(PPCDBG_TCE, "vio_alloc_consistent: iommu_alloc failed\n" );
 				free_pages((unsigned long)ret, order);
 				ret = NULL;
===== iommu.h 1.2 vs edited =====
--- 1.2/include/asm-ppc64/iommu.h	Thu Mar  4 00:26:24 2004
+++ edited/iommu.h	Mon Mar 22 01:29:27 2004
@@ -33,8 +33,6 @@
  */
 #define IOMAP_MAX_ORDER 10

-#define NO_TCE ((dma_addr_t)-1)
-
 /*
  * Tces come in two formats, one for the virtual bus and a different
  * format for PCI
===== pci.h 1.20 vs edited =====
--- 1.20/include/asm-ppc64/pci.h	Sun Mar 14 17:54:58 2004
+++ edited/pci.h	Mon Mar 22 01:29:12 2004
@@ -169,6 +169,12 @@
 	return 0;
 }

+#define PCI_DMA_ERROR_CODE      (~(dma_addr_t)0x0)
+static inline int pci_dma_error(dma_addr_t dma_addr)
+{
+	return (dma_addr == PCI_DMA_ERROR_CODE);
+}
+
 extern int pci_domain_nr(struct pci_bus *bus);

 /* Set the name of the bus as it appears in /proc/bus/pci */

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list