linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask
@ 2006-04-13  2:05 Olof Johansson
  2006-04-13  2:28 ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB Olof Johansson
  2006-04-14 18:55 ` [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask Olof Johansson
  0 siblings, 2 replies; 19+ messages in thread
From: Olof Johansson @ 2006-04-13  2:05 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, linux-kernel

Hi,

Paulus -- Ben mentioned being interested in this going into 2.6.17,
since the bcm43xx driver will need it to be usable on G5s with more than
1GB memory.

Built with iseries_defconfig and ppc64_defconfig, boot tested on pSeries
and G5, but I'm away from home so I haven't been able to install an
Airport card in the G5.

Since time is somewhat of essense (if 2.6.17 is still an option), I went
for the choice of sending now and follow up with a small bugfix later
in case something shows up, especially since quick regression tests seem
ok.


Thanks,

Olof


---




Some devices don't support full 32-bit DMA address space, which we currently
assume. Add the required mask-passing to the IOMMU allocators.

Signed-off-by: Olof Johansson <olof@lixom.net>


Index: 2.6/arch/powerpc/kernel/iommu.c
===================================================================
--- 2.6.orig/arch/powerpc/kernel/iommu.c
+++ 2.6/arch/powerpc/kernel/iommu.c
@@ -61,6 +61,7 @@ __setup("iommu=", setup_iommu);
 static unsigned long iommu_range_alloc(struct iommu_table *tbl,
                                        unsigned long npages,
                                        unsigned long *handle,
+                                       unsigned long mask,
                                        unsigned int align_order)
 { 
 	unsigned long n, end, i, start;
@@ -97,9 +98,21 @@ static unsigned long iommu_range_alloc(s
 	 */
 	if (start >= limit)
 		start = largealloc ? tbl->it_largehint : tbl->it_hint;
-	
+
  again:
 
+	if (limit + tbl->it_offset > mask) {
+		limit = mask - tbl->it_offset + 1;
+		/* If we're constrained on address range, first try
+		 * at the masked hint to avoid O(n) search complexity,
+		 * but on second pass, start at 0.
+		 */
+		if ((start & mask) >= limit || pass > 0)
+			start = 0;
+		else
+			start &= mask;
+	}
+
 	n = find_next_zero_bit(tbl->it_map, limit, start);
 
 	/* Align allocation */
@@ -150,14 +163,14 @@ static unsigned long iommu_range_alloc(s
 
 static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *page,
 		       unsigned int npages, enum dma_data_direction direction,
-		       unsigned int align_order)
+		       unsigned long mask, unsigned int align_order)
 {
 	unsigned long entry, flags;
 	dma_addr_t ret = DMA_ERROR_CODE;
-	
+
 	spin_lock_irqsave(&(tbl->it_lock), flags);
 
-	entry = iommu_range_alloc(tbl, npages, NULL, align_order);
+	entry = iommu_range_alloc(tbl, npages, NULL, mask, align_order);
 
 	if (unlikely(entry == DMA_ERROR_CODE)) {
 		spin_unlock_irqrestore(&(tbl->it_lock), flags);
@@ -236,7 +249,7 @@ static void iommu_free(struct iommu_tabl
 
 int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 		struct scatterlist *sglist, int nelems,
-		enum dma_data_direction direction)
+		unsigned long mask, enum dma_data_direction direction)
 {
 	dma_addr_t dma_next = 0, dma_addr;
 	unsigned long flags;
@@ -274,7 +287,7 @@ int iommu_map_sg(struct device *dev, str
 		vaddr = (unsigned long)page_address(s->page) + s->offset;
 		npages = PAGE_ALIGN(vaddr + slen) - (vaddr & PAGE_MASK);
 		npages >>= PAGE_SHIFT;
-		entry = iommu_range_alloc(tbl, npages, &handle, 0);
+		entry = iommu_range_alloc(tbl, npages, &handle, mask >> PAGE_SHIFT, 0);
 
 		DBG("  - vaddr: %lx, size: %lx\n", vaddr, slen);
 
@@ -479,7 +492,8 @@ void iommu_free_table(struct device_node
  * byte within the page as vaddr.
  */
 dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
-		size_t size, enum dma_data_direction direction)
+		size_t size, unsigned long mask,
+		enum dma_data_direction direction)
 {
 	dma_addr_t dma_handle = DMA_ERROR_CODE;
 	unsigned long uaddr;
@@ -492,7 +506,8 @@ dma_addr_t iommu_map_single(struct iommu
 	npages >>= PAGE_SHIFT;
 
 	if (tbl) {
-		dma_handle = iommu_alloc(tbl, vaddr, npages, direction, 0);
+		dma_handle = iommu_alloc(tbl, vaddr, npages, direction,
+					 mask >> PAGE_SHIFT, 0);
 		if (dma_handle == DMA_ERROR_CODE) {
 			if (printk_ratelimit())  {
 				printk(KERN_INFO "iommu_alloc failed, "
@@ -521,7 +536,7 @@ void iommu_unmap_single(struct iommu_tab
  * to the dma address (mapping) of the first page.
  */
 void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
-		dma_addr_t *dma_handle, gfp_t flag)
+		dma_addr_t *dma_handle, unsigned long mask, gfp_t flag)
 {
 	void *ret = NULL;
 	dma_addr_t mapping;
@@ -551,7 +566,8 @@ void *iommu_alloc_coherent(struct iommu_
 	memset(ret, 0, size);
 
 	/* Set up tces to cover the allocated range */
-	mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL, order);
+	mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL,
+			      mask >> PAGE_SHIFT, order);
 	if (mapping == DMA_ERROR_CODE) {
 		free_pages((unsigned long)ret, order);
 		ret = NULL;
Index: 2.6/arch/powerpc/kernel/vio.c
===================================================================
--- 2.6.orig/arch/powerpc/kernel/vio.c
+++ 2.6/arch/powerpc/kernel/vio.c
@@ -202,7 +202,7 @@ static dma_addr_t vio_map_single(struct 
 			  size_t size, enum dma_data_direction direction)
 {
 	return iommu_map_single(to_vio_dev(dev)->iommu_table, vaddr, size,
-			direction);
+			~0ul, direction);
 }
 
 static void vio_unmap_single(struct device *dev, dma_addr_t dma_handle,
@@ -216,7 +216,7 @@ static int vio_map_sg(struct device *dev
 		int nelems, enum dma_data_direction direction)
 {
 	return iommu_map_sg(dev, to_vio_dev(dev)->iommu_table, sglist,
-			nelems, direction);
+			nelems, ~0ul, direction);
 }
 
 static void vio_unmap_sg(struct device *dev, struct scatterlist *sglist,
@@ -229,7 +229,7 @@ static void *vio_alloc_coherent(struct d
 			   dma_addr_t *dma_handle, gfp_t flag)
 {
 	return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size,
-			dma_handle, flag);
+			dma_handle, ~0ul, flag);
 }
 
 static void vio_free_coherent(struct device *dev, size_t size,
Index: 2.6/include/asm-powerpc/iommu.h
===================================================================
--- 2.6.orig/include/asm-powerpc/iommu.h
+++ 2.6/include/asm-powerpc/iommu.h
@@ -70,17 +70,18 @@ extern void iommu_free_table(struct devi
 extern struct iommu_table *iommu_init_table(struct iommu_table * tbl);
 
 extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
-		struct scatterlist *sglist, int nelems,
+		struct scatterlist *sglist, int nelems, unsigned long mask,
 		enum dma_data_direction direction);
 extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
 		int nelems, enum dma_data_direction direction);
 
 extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
-		dma_addr_t *dma_handle, gfp_t flag);
+		dma_addr_t *dma_handle, unsigned long mask, gfp_t flag);
 extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
 		void *vaddr, dma_addr_t dma_handle);
 extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
-		size_t size, enum dma_data_direction direction);
+		size_t size, unsigned long mask,
+		enum dma_data_direction direction);
 extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
 		size_t size, enum dma_data_direction direction);
 
Index: 2.6/arch/powerpc/kernel/pci_iommu.c
===================================================================
--- 2.6.orig/arch/powerpc/kernel/pci_iommu.c
+++ 2.6/arch/powerpc/kernel/pci_iommu.c
@@ -59,6 +59,25 @@ static inline struct iommu_table *devnod
 }
 
 
+static inline unsigned long device_to_mask(struct device *hwdev)
+{
+	struct pci_dev *pdev;
+
+	if (!hwdev) {
+		pdev = ppc64_isabridge_dev;
+		if (!pdev) /* This is the best guess we can do */
+			return 0xfffffffful;
+	} else
+		pdev = to_pci_dev(hwdev);
+
+	if (pdev->dma_mask)
+		return pdev->dma_mask;
+
+	/* Assume devices without mask can take 32 bit addresses */
+	return 0xfffffffful;
+}
+
+
 /* Allocates a contiguous real buffer and creates mappings over it.
  * Returns the virtual address of the buffer and sets dma_handle
  * to the dma address (mapping) of the first page.
@@ -67,7 +86,7 @@ static void *pci_iommu_alloc_coherent(st
 			   dma_addr_t *dma_handle, gfp_t flag)
 {
 	return iommu_alloc_coherent(devnode_table(hwdev), size, dma_handle,
-			flag);
+			device_to_mask(hwdev), flag);
 }
 
 static void pci_iommu_free_coherent(struct device *hwdev, size_t size,
@@ -86,7 +105,7 @@ static dma_addr_t pci_iommu_map_single(s
 		size_t size, enum dma_data_direction direction)
 {
 	return iommu_map_single(devnode_table(hwdev), vaddr, size, 
-			        direction);
+			        device_to_mask(hwdev), direction);
 }
 
 
@@ -101,7 +120,7 @@ static int pci_iommu_map_sg(struct devic
 		int nelems, enum dma_data_direction direction)
 {
 	return iommu_map_sg(pdev, devnode_table(pdev), sglist,
-			nelems, direction);
+			nelems, device_to_mask(pdev), direction);
 }
 
 static void pci_iommu_unmap_sg(struct device *pdev, struct scatterlist *sglist,
@@ -113,7 +132,19 @@ static void pci_iommu_unmap_sg(struct de
 /* We support DMA to/from any memory page via the iommu */
 static int pci_iommu_dma_supported(struct device *dev, u64 mask)
 {
-	return 1;
+	struct iommu_table *tbl = devnode_table(dev);
+	
+	if (!tbl || tbl->it_offset > mask) {
+		printk(KERN_INFO "Warning: IOMMU table offset too big for device mask\n");
+		if (tbl)
+			printk(KERN_INFO "mask: 0x%08lx, table offset: 0x%08lx\n",
+				mask, tbl->it_offset);
+		else
+			printk(KERN_INFO "mask: 0x%08lx, table unavailable\n",
+				mask);
+		return 0;
+	} else
+		return 1;
 }
 
 void pci_iommu_init(void)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB
  2006-04-13  2:05 [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask Olof Johansson
@ 2006-04-13  2:28 ` Olof Johansson
  2006-04-13  2:52   ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2 Olof Johansson
  2006-04-14 18:55 ` [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask Olof Johansson
  1 sibling, 1 reply; 19+ messages in thread
From: Olof Johansson @ 2006-04-13  2:28 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, linux-kernel

Hi,

This goes with the previous dma_mask patch -- enable DART at 1GB due to
Airport Extreme cards needing it. Please consider for 2.6.17.


Thanks,

Olof


---

Turn on the DART already at 1GB. This is needed because of crippled
devices in some systems, i.e. Airport Extreme cards, only supporting
30-bit DMA addresses.

Otherwise, users with between 1 and 2GB of memory will need to manually
enable it with iommu=force, and that's no good.

Some simple performance tests show that there's a slight impact of
enabling DART, but it's in the 1-3% range (kernel build with disk I/O
as well as over NFS).

iommu=off can still be used for those who don't want to deal with the
overhead (and don't need it for any devices).


Signed-off-by: Olof Johansson <olof@lixom.net>

Index: 2.6/arch/powerpc/sysdev/dart_iommu.c
===================================================================
--- 2.6.orig/arch/powerpc/sysdev/dart_iommu.c
+++ 2.6/arch/powerpc/sysdev/dart_iommu.c
@@ -329,10 +329,14 @@ void iommu_init_early_dart(void)
 
 void __init alloc_dart_table(void)
 {
-	/* Only reserve DART space if machine has more than 2GB of RAM
+	/* Only reserve DART space if machine has more than 1GB of RAM
 	 * or if requested with iommu=on on cmdline.
+	 *
+	 * 1GB of RAM is picked as limit because some default devices
+	 * (i.e. Airport Extreme) have 30 bit address range limits.
 	 */
-	if (lmb_end_of_DRAM() <= 0x80000000ull && !iommu_force_on)
+
+	if (lmb_end_of_DRAM() <= 0x40000000ull && !iommu_force_on)
 		return;
 
 	/* 512 pages (2MB) is max DART tablesize. */

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13  2:28 ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB Olof Johansson
@ 2006-04-13  2:52   ` Olof Johansson
  2006-04-13  6:40     ` Muli Ben-Yehuda
  0 siblings, 1 reply; 19+ messages in thread
From: Olof Johansson @ 2006-04-13  2:52 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, linux-kernel

On Wed, Apr 12, 2006 at 09:28:09PM -0500, Olof Johansson wrote:
> Hi,
> 
> This goes with the previous dma_mask patch -- enable DART at 1GB due to
> Airport Extreme cards needing it. Please consider for 2.6.17.

Crap, I missed a quilt refresh. Here's the version that handles iommu=off
between 1GB and 2GB right.


---


Turn on the DART already at 1GB. This is needed because of crippled
devices in some systems, i.e. Airport Extreme cards, only supporting
30-bit DMA addresses.

Otherwise, users with between 1 and 2GB of memory will need to manually
enable it with iommu=force, and that's no good.

Some simple performance tests show that there's a slight impact of
enabling DART, but it's in the 1-3% range (kernel build with disk I/O
as well as over NFS).

iommu=off can still be used for those who don't want to deal with the
overhead (and don't need it for any devices).


Signed-off-by: Olof Johansson <olof@lixom.net>

Index: 2.6/arch/powerpc/sysdev/dart_iommu.c
===================================================================
--- 2.6.orig/arch/powerpc/sysdev/dart_iommu.c
+++ 2.6/arch/powerpc/sysdev/dart_iommu.c
@@ -49,6 +49,7 @@
 
 #include "dart.h"
 
+extern int iommu_is_off;
 extern int iommu_force_on;
 
 /* Physical base address and size of the DART table */
@@ -329,10 +330,17 @@ void iommu_init_early_dart(void)
 
 void __init alloc_dart_table(void)
 {
-	/* Only reserve DART space if machine has more than 2GB of RAM
+	/* Only reserve DART space if machine has more than 1GB of RAM
 	 * or if requested with iommu=on on cmdline.
+	 *
+	 * 1GB of RAM is picked as limit because some default devices
+	 * (i.e. Airport Extreme) have 30 bit address range limits.
 	 */
-	if (lmb_end_of_DRAM() <= 0x80000000ull && !iommu_force_on)
+
+	if (iommu_is_off)
+		return;
+
+	if (!iommu_force_on && lmb_end_of_DRAM() <= 0x40000000ull)
 		return;
 
 	/* 512 pages (2MB) is max DART tablesize. */
Index: 2.6/arch/powerpc/kernel/prom.c
===================================================================
--- 2.6.orig/arch/powerpc/kernel/prom.c
+++ 2.6/arch/powerpc/kernel/prom.c
@@ -62,7 +62,7 @@ static int __initdata dt_root_addr_cells
 static int __initdata dt_root_size_cells;
 
 #ifdef CONFIG_PPC64
-static int __initdata iommu_is_off;
+int __initdata iommu_is_off;
 int __initdata iommu_force_on;
 unsigned long tce_alloc_start, tce_alloc_end;
 #endif

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13  2:52   ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2 Olof Johansson
@ 2006-04-13  6:40     ` Muli Ben-Yehuda
  2006-04-13 10:45       ` Benjamin Herrenschmidt
  2006-04-13 15:57       ` Olof Johansson
  0 siblings, 2 replies; 19+ messages in thread
From: Muli Ben-Yehuda @ 2006-04-13  6:40 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, paulus, linux-kernel

On Wed, Apr 12, 2006 at 09:52:33PM -0500, Olof Johansson wrote:

> iommu=off can still be used for those who don't want to deal with the
> overhead (and don't need it for any devices).

I've been pondering walking the PCI bus before deciding to enable an
IOMMU and checking each device's DMA mask. Is this something that you
considered and rejected, or just something no one got around to doing?

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13  6:40     ` Muli Ben-Yehuda
@ 2006-04-13 10:45       ` Benjamin Herrenschmidt
  2006-04-13 16:07         ` Olof Johansson
  2006-04-13 15:57       ` Olof Johansson
  1 sibling, 1 reply; 19+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-13 10:45 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Thu, 2006-04-13 at 09:40 +0300, Muli Ben-Yehuda wrote:
> On Wed, Apr 12, 2006 at 09:52:33PM -0500, Olof Johansson wrote:
> 
> > iommu=off can still be used for those who don't want to deal with the
> > overhead (and don't need it for any devices).
> 
> I've been pondering walking the PCI bus before deciding to enable an
> IOMMU and checking each device's DMA mask. Is this something that you
> considered and rejected, or just something no one got around to doing?

It would do the trick for airport cards in G5s.. a little bit of OF
walking to find the card.

It won't help with cardbus broadcom's but then, there is currently no G5
with a cardbus adaptor that I know of :) It's possible I suppose to get
a pci<->cardbus adapter but I suppose in that case, we can ignore it ...

Ben.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13  6:40     ` Muli Ben-Yehuda
  2006-04-13 10:45       ` Benjamin Herrenschmidt
@ 2006-04-13 15:57       ` Olof Johansson
  1 sibling, 0 replies; 19+ messages in thread
From: Olof Johansson @ 2006-04-13 15:57 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Thu, Apr 13, 2006 at 09:40:27AM +0300, Muli Ben-Yehuda wrote:
> On Wed, Apr 12, 2006 at 09:52:33PM -0500, Olof Johansson wrote:
> 
> > iommu=off can still be used for those who don't want to deal with the
> > overhead (and don't need it for any devices).
> 
> I've been pondering walking the PCI bus before deciding to enable an
> IOMMU and checking each device's DMA mask. Is this something that you
> considered and rejected, or just something no one got around to doing?

It's something I thought about, but right now we enable the IOMMU quite
early during boot. It'd take a bit of surgery to shuffle things, and I
decided that it's not worth the work (and risk of regressions) for 2.6.17.



-Olof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 10:45       ` Benjamin Herrenschmidt
@ 2006-04-13 16:07         ` Olof Johansson
  2006-04-13 17:31           ` Muli Ben-Yehuda
  2006-04-13 20:51           ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 19+ messages in thread
From: Olof Johansson @ 2006-04-13 16:07 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Thu, Apr 13, 2006 at 08:45:49PM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2006-04-13 at 09:40 +0300, Muli Ben-Yehuda wrote:
> > On Wed, Apr 12, 2006 at 09:52:33PM -0500, Olof Johansson wrote:
> > 
> > > iommu=off can still be used for those who don't want to deal with the
> > > overhead (and don't need it for any devices).
> > 
> > I've been pondering walking the PCI bus before deciding to enable an
> > IOMMU and checking each device's DMA mask. Is this something that you
> > considered and rejected, or just something no one got around to doing?
> 
> It would do the trick for airport cards in G5s.. a little bit of OF
> walking to find the card.

Walking the DT means we need to hardcode it on PCI IDs, since the Apple
OF doesn't give the Airport device a logical name. It's probably easier
to implement than walking PCI, but we'd need to maintain a table. My
vote is for PCI walking, I'll give that a shot over the weekend.

> It won't help with cardbus broadcom's but then, there is currently no G5
> with a cardbus adaptor that I know of :) It's possible I suppose to get
> a pci<->cardbus adapter but I suppose in that case, we can ignore it ...

Yep, that should be rare enough.

-Olof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 16:07         ` Olof Johansson
@ 2006-04-13 17:31           ` Muli Ben-Yehuda
  2006-04-13 20:52             ` Benjamin Herrenschmidt
  2006-04-13 20:51           ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 19+ messages in thread
From: Muli Ben-Yehuda @ 2006-04-13 17:31 UTC (permalink / raw)
  To: Olof Johansson; +Cc: paulus, linux-kernel, linuxppc-dev

On Thu, Apr 13, 2006 at 11:07:12AM -0500, Olof Johansson wrote:

> Walking the DT means we need to hardcode it on PCI IDs, since the Apple
> OF doesn't give the Airport device a logical name. It's probably easier
> to implement than walking PCI, but we'd need to maintain a table. My
> vote is for PCI walking, I'll give that a shot over the weekend.

Cool! bonus points if you do it in drivers/pci and we can steal it
easily for Calgary on x8-64 :-)

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 16:07         ` Olof Johansson
  2006-04-13 17:31           ` Muli Ben-Yehuda
@ 2006-04-13 20:51           ` Benjamin Herrenschmidt
  2006-04-13 22:27             ` Olof Johansson
  1 sibling, 1 reply; 19+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-13 20:51 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, paulus, linux-kernel

On Thu, 2006-04-13 at 11:07 -0500, Olof Johansson wrote:
> On Thu, Apr 13, 2006 at 08:45:49PM +1000, Benjamin Herrenschmidt wrote:
> > On Thu, 2006-04-13 at 09:40 +0300, Muli Ben-Yehuda wrote:
> > > On Wed, Apr 12, 2006 at 09:52:33PM -0500, Olof Johansson wrote:
> > > 
> > > > iommu=off can still be used for those who don't want to deal with the
> > > > overhead (and don't need it for any devices).
> > > 
> > > I've been pondering walking the PCI bus before deciding to enable an
> > > IOMMU and checking each device's DMA mask. Is this something that you
> > > considered and rejected, or just something no one got around to doing?
> > 
> > It would do the trick for airport cards in G5s.. a little bit of OF
> > walking to find the card.
> 
> Walking the DT means we need to hardcode it on PCI IDs, since the Apple
> OF doesn't give the Airport device a logical name. It's probably easier
> to implement than walking PCI, but we'd need to maintain a table. My
> vote is for PCI walking, I'll give that a shot over the weekend.

PCI walking it soo late to decide wether to enable the DART no ? In any
case, we need a table, so I wouldn't bother with PCI walking here.
Anyway... we should be able to have almost no perf. degradation or even
an improvement with the DART thanks to virtual merging. Currently, we
pay a cost due to our stupid invalidate mecanism that we should really
fix by shooting the TLB directly. Also have you made sure all your
additions for handling crappy hardware are nicely wrapped in unlikely()
statements ? :)

> > It won't help with cardbus broadcom's but then, there is currently no G5
> > with a cardbus adaptor that I know of :) It's possible I suppose to get
> > a pci<->cardbus adapter but I suppose in that case, we can ignore it ...
> 
> Yep, that should be rare enough.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 17:31           ` Muli Ben-Yehuda
@ 2006-04-13 20:52             ` Benjamin Herrenschmidt
  2006-04-14 14:48               ` Muli Ben-Yehuda
  0 siblings, 1 reply; 19+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-13 20:52 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Thu, 2006-04-13 at 20:31 +0300, Muli Ben-Yehuda wrote:
> On Thu, Apr 13, 2006 at 11:07:12AM -0500, Olof Johansson wrote:
> 
> > Walking the DT means we need to hardcode it on PCI IDs, since the Apple
> > OF doesn't give the Airport device a logical name. It's probably easier
> > to implement than walking PCI, but we'd need to maintain a table. My
> > vote is for PCI walking, I'll give that a shot over the weekend.
> 
> Cool! bonus points if you do it in drivers/pci and we can steal it
> easily for Calgary on x8-64 :-)

How so ? Anything remotely related to the iommu is totally different...
Besides, on x86-64, laptops _are_ more common, and thus the problem of
cardbus cards is much more significant.

Ben.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 20:51           ` Benjamin Herrenschmidt
@ 2006-04-13 22:27             ` Olof Johansson
  2006-04-13 22:38               ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 19+ messages in thread
From: Olof Johansson @ 2006-04-13 22:27 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, paulus, linux-kernel

On Fri, Apr 14, 2006 at 06:51:55AM +1000, Benjamin Herrenschmidt wrote:

> an improvement with the DART thanks to virtual merging. Currently, we
> pay a cost due to our stupid invalidate mecanism that we should really
> fix by shooting the TLB directly.

What was keeping me from implementing this before was the lack of public
documentation on how to do it. Has that changed? I'd be happy to do the
implementation.

> Also have you made sure all your
> additions for handling crappy hardware are nicely wrapped in unlikely()
> statements ? :)

I would expect the dynamic predictor to work quite well on this. I'm not
worried about the overhead of the tests as much as the overhead of
having to enable the DART for smaller configs. If benchmark profiling
shows different down the road then we can add them.


-Olof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 22:27             ` Olof Johansson
@ 2006-04-13 22:38               ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 19+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-13 22:38 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, paulus, linux-kernel

On Thu, 2006-04-13 at 17:27 -0500, Olof Johansson wrote:
> On Fri, Apr 14, 2006 at 06:51:55AM +1000, Benjamin Herrenschmidt wrote:
> 
> > an improvement with the DART thanks to virtual merging. Currently, we
> > pay a cost due to our stupid invalidate mecanism that we should really
> > fix by shooting the TLB directly.
> 
> What was keeping me from implementing this before was the lack of public
> documentation on how to do it. Has that changed? I'd be happy to do the
> implementation.

Darwin has the macros to access the TLB though it doesn't use them... I
suppose I can get the necessary doco bit from the microelectronics folks
for the CPC925, that should apply to U3 as well, though U4 has a
different format afaik. I'll dig and will come back to you.

> > Also have you made sure all your
> > additions for handling crappy hardware are nicely wrapped in unlikely()
> > statements ? :)
> 
> I would expect the dynamic predictor to work quite well on this. I'm not
> worried about the overhead of the tests as much as the overhead of
> having to enable the DART for smaller configs. If benchmark profiling
> shows different down the road then we can add them.

Ok.

Ben.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-13 20:52             ` Benjamin Herrenschmidt
@ 2006-04-14 14:48               ` Muli Ben-Yehuda
  2006-04-14 20:57                 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 19+ messages in thread
From: Muli Ben-Yehuda @ 2006-04-14 14:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Fri, Apr 14, 2006 at 06:52:44AM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2006-04-13 at 20:31 +0300, Muli Ben-Yehuda wrote:
> > On Thu, Apr 13, 2006 at 11:07:12AM -0500, Olof Johansson wrote:
> > 
> > > Walking the DT means we need to hardcode it on PCI IDs, since the Apple
> > > OF doesn't give the Airport device a logical name. It's probably easier
> > > to implement than walking PCI, but we'd need to maintain a table. My
> > > vote is for PCI walking, I'll give that a shot over the weekend.
> > 
> > Cool! bonus points if you do it in drivers/pci and we can steal it
> > easily for Calgary on x8-64 :-)
> 
> How so ? Anything remotely related to the iommu is totally different...
> Besides, on x86-64, laptops _are_ more common, and thus the problem of
> cardbus cards is much more significant.

What I had in mind is an interface that given a PCI bridge will tell
you what's the most restrictive DMA mask for a device on that bridge,
so that you'll know whether you need to enable the IOMMU for that
bridge. I'll even settle for a function that tells you what's the most
restrictive DMA mask in the system, preiod. There's nothing inherently
arch specific about this.

(and as a side note, the IOMMU we are working on on x86-64 is Calgary,
which is actually roughly the same chipset used in some PPC
machines...)

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask
  2006-04-13  2:05 [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask Olof Johansson
  2006-04-13  2:28 ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB Olof Johansson
@ 2006-04-14 18:55 ` Olof Johansson
  1 sibling, 0 replies; 19+ messages in thread
From: Olof Johansson @ 2006-04-14 18:55 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, plush, linux-kernel

On Wed, Apr 12, 2006 at 09:05:59PM -0500, Olof Johansson wrote:

> Since time is somewhat of essense (if 2.6.17 is still an option), I went
> for the choice of sending now and follow up with a small bugfix later
> in case something shows up, especially since quick regression tests seem
> ok.

FYI, I now have a positive test report from a bcm43xx user with a 1.5GB G5.
(Thanks for testing this, Marc!).


-Olof

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-14 14:48               ` Muli Ben-Yehuda
@ 2006-04-14 20:57                 ` Benjamin Herrenschmidt
  2006-04-15  7:45                   ` Muli Ben-Yehuda
  2006-04-15 13:37                   ` Jon Mason
  0 siblings, 2 replies; 19+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-14 20:57 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel


> What I had in mind is an interface that given a PCI bridge will tell
> you what's the most restrictive DMA mask for a device on that bridge,
> so that you'll know whether you need to enable the IOMMU for that
> bridge. I'll even settle for a function that tells you what's the most
> restrictive DMA mask in the system, preiod. There's nothing inherently
> arch specific about this.
>
> (and as a side note, the IOMMU we are working on on x86-64 is Calgary,
> which is actually roughly the same chipset used in some PPC
> machines...)

Not sure I ever heard about that... What chipsets ?

Ben.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-14 20:57                 ` Benjamin Herrenschmidt
@ 2006-04-15  7:45                   ` Muli Ben-Yehuda
  2006-04-15 13:09                     ` Jimi Xenidis
  2006-04-15 13:37                   ` Jon Mason
  1 sibling, 1 reply; 19+ messages in thread
From: Muli Ben-Yehuda @ 2006-04-15  7:45 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Sat, Apr 15, 2006 at 06:57:55AM +1000, Benjamin Herrenschmidt wrote:

> Not sure I ever heard about that... What chipsets ?

I'm not sure which IBM pSeries modesl have Calgary in them. Perhaps
Jon or Olof know?

Cheers,
Muli
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-15  7:45                   ` Muli Ben-Yehuda
@ 2006-04-15 13:09                     ` Jimi Xenidis
  0 siblings, 0 replies; 19+ messages in thread
From: Jimi Xenidis @ 2006-04-15 13:09 UTC (permalink / raw)
  To: Muli Ben-Yehuda; +Cc: Olof Johansson, paulus, linux-kernel, linuxppc-dev

I believe its in Regatta platforms, spin 180 degrees and ask anton :)
-JX
On Apr 15, 2006, at 3:45 AM, Muli Ben-Yehuda wrote:

> On Sat, Apr 15, 2006 at 06:57:55AM +1000, Benjamin Herrenschmidt  
> wrote:
>
>> Not sure I ever heard about that... What chipsets ?
>
> I'm not sure which IBM pSeries modesl have Calgary in them. Perhaps
> Jon or Olof know?
>
> Cheers,
> Muli
> -- 
> Muli Ben-Yehuda
> http://www.mulix.org | http://mulix.livejournal.com/
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-14 20:57                 ` Benjamin Herrenschmidt
  2006-04-15  7:45                   ` Muli Ben-Yehuda
@ 2006-04-15 13:37                   ` Jon Mason
  2006-04-15 20:28                     ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 19+ messages in thread
From: Jon Mason @ 2006-04-15 13:37 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Sat, Apr 15, 2006 at 06:57:55AM +1000, Benjamin Herrenschmidt wrote:
> 
> > What I had in mind is an interface that given a PCI bridge will tell
> > you what's the most restrictive DMA mask for a device on that bridge,
> > so that you'll know whether you need to enable the IOMMU for that
> > bridge. I'll even settle for a function that tells you what's the most
> > restrictive DMA mask in the system, period. There's nothing inherently
> > arch specific about this.
> >
> > (and as a side note, the IOMMU we are working on on x86-64 is Calgary,
> > which is actually roughly the same chipset used in some PPC
> > machines...)
> 
> Not sure I ever heard about that... What chipsets ?

The pSeries POWER4 based systems (Regatta) had Calgary, and the 
RS/6000 POWER3 based systems (Condor) had Winnipeg (a precursor to
Calgary, with many of the same features).

Thanks,
Jon

> 
> Ben.
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2
  2006-04-15 13:37                   ` Jon Mason
@ 2006-04-15 20:28                     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 19+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-15 20:28 UTC (permalink / raw)
  To: Jon Mason; +Cc: Olof Johansson, linuxppc-dev, paulus, linux-kernel

On Sat, 2006-04-15 at 08:37 -0500, Jon Mason wrote:
> On Sat, Apr 15, 2006 at 06:57:55AM +1000, Benjamin Herrenschmidt wrote:
> > 
> > > What I had in mind is an interface that given a PCI bridge will tell
> > > you what's the most restrictive DMA mask for a device on that bridge,
> > > so that you'll know whether you need to enable the IOMMU for that
> > > bridge. I'll even settle for a function that tells you what's the most
> > > restrictive DMA mask in the system, period. There's nothing inherently
> > > arch specific about this.
> > >
> > > (and as a side note, the IOMMU we are working on on x86-64 is Calgary,
> > > which is actually roughly the same chipset used in some PPC
> > > machines...)
> > 
> > Not sure I ever heard about that... What chipsets ?
> 
> The pSeries POWER4 based systems (Regatta) had Calgary, and the 
> RS/6000 POWER3 based systems (Condor) had Winnipeg (a precursor to
> Calgary, with many of the same features).

Ah ok, I'm not familiar with the IBM chipset names

Ben.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2006-04-15 20:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-13  2:05 [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask Olof Johansson
2006-04-13  2:28 ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB Olof Johansson
2006-04-13  2:52   ` [PATCH] [2/2] POWERPC: Lower threshold for DART enablement to 1GB, V2 Olof Johansson
2006-04-13  6:40     ` Muli Ben-Yehuda
2006-04-13 10:45       ` Benjamin Herrenschmidt
2006-04-13 16:07         ` Olof Johansson
2006-04-13 17:31           ` Muli Ben-Yehuda
2006-04-13 20:52             ` Benjamin Herrenschmidt
2006-04-14 14:48               ` Muli Ben-Yehuda
2006-04-14 20:57                 ` Benjamin Herrenschmidt
2006-04-15  7:45                   ` Muli Ben-Yehuda
2006-04-15 13:09                     ` Jimi Xenidis
2006-04-15 13:37                   ` Jon Mason
2006-04-15 20:28                     ` Benjamin Herrenschmidt
2006-04-13 20:51           ` Benjamin Herrenschmidt
2006-04-13 22:27             ` Olof Johansson
2006-04-13 22:38               ` Benjamin Herrenschmidt
2006-04-13 15:57       ` Olof Johansson
2006-04-14 18:55 ` [PATCH] [1/2] POWERPC: IOMMU support for honoring dma_mask Olof Johansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).