Re: iommu_alloc failure and panic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 27, 2006 at 02:39:50PM -0800, Mark Haverkamp wrote:

> I would have thought that the npages would be 1 now.

No, npages is the size of the allocation coming from the driver, that
won't chance. The table blocksize just says how wide the cacheline size
is, i.e. how far it should advance between allocations.

This is a patch that should probably have been added a while ago, to
give a bit more info. Can you apply it and give it a go?


Thanks,

Olof




Index: 2.6/arch/powerpc/kernel/iommu.c
===================================================================
--- 2.6.orig/arch/powerpc/kernel/iommu.c	2006-01-28 12:18:56.000000000 +1300
+++ 2.6/arch/powerpc/kernel/iommu.c	2006-01-28 12:31:20.000000000 +1300
@@ -146,6 +146,8 @@ static unsigned long iommu_range_alloc(s
 	if (handle)
 		*handle = end;
 
+	tbl->it_used += npages;
+
 	return n;
 }
 
@@ -214,6 +216,8 @@ static void __iommu_free(struct iommu_ta
 	
 	for (i = 0; i < npages; i++)
 		__clear_bit(free_entry+i, tbl->it_map);
+
+	tbl->it_used -= npages;
 }
 
 static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
@@ -281,9 +285,11 @@ int iommu_map_sg(struct device *dev, str
 
 		/* Handle failure */
 		if (unlikely(entry == DMA_ERROR_CODE)) {
-			if (printk_ratelimit())
-				printk(KERN_INFO "iommu_alloc failed, tbl %p vaddr %lx"
+			if (printk_ratelimit()) {
+				printk(KERN_INFO "iommu_alloc_sg failed, tbl %p vaddr %lx"
 				       " npages %lx\n", tbl, vaddr, npages);
+				printk(KERN_INFO "table size %lx used %lx\n", tbl->it_size, tbl->it_used);
+			}
 			goto failure;
 		}
 
@@ -422,6 +428,7 @@ struct iommu_table *iommu_init_table(str
 
 	tbl->it_hint = 0;
 	tbl->it_largehint = tbl->it_halfpoint;
+	tbl->it_used = 0;
 	spin_lock_init(&tbl->it_lock);
 
 	/* Clear the hardware table in case firmware left allocations in it */
@@ -496,6 +503,7 @@ dma_addr_t iommu_map_single(struct iommu
 				printk(KERN_INFO "iommu_alloc failed, "
 						"tbl %p vaddr %p npages %d\n",
 						tbl, vaddr, npages);
+				printk(KERN_INFO "table size %lx used %lx\n", tbl->it_size, tbl->it_used);
 			}
 		} else
 			dma_handle |= (uaddr & ~PAGE_MASK);
Index: 2.6/include/asm-powerpc/iommu.h
===================================================================
--- 2.6.orig/include/asm-powerpc/iommu.h	2006-01-21 03:14:30.000000000 +1300
+++ 2.6/include/asm-powerpc/iommu.h	2006-01-28 12:26:39.000000000 +1300
@@ -47,6 +47,7 @@ struct iommu_table {
 	unsigned long  it_largehint; /* Hint for large allocs */
 	unsigned long  it_halfpoint; /* Breaking point for small/large allocs */
 	spinlock_t     it_lock;      /* Protects it_map */
+	unsigned long  it_used;
 	unsigned long *it_map;       /* A simple allocation bitmap for now */
 };
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux