All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	olof@austin.ibm.com, dsd@gentoo.org
Subject: [patch 05/16] PPC64: Fix LPAR IOMMU setup code for p630
Date: Mon, 23 May 2005 16:21:03 -0700	[thread overview]
Message-ID: <20050523232103.GQ27549@shell0.pdx.osdl.net> (raw)
In-Reply-To: <20050523231529.GL27549@shell0.pdx.osdl.net>

Here's a fix to deal with p630 systems in LPAR mode.  They're to date the
only system that in some cases might lack a dma-window property for the
bus, but contain an overriding property in the device node for the specific
adapter/slot.  This makes the device setup code a bit more complex since it
needs to do some of the things that the bus setup code has already done.

Signed-off-by: Olof Johansson <olof@austin.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 arch/ppc64/kernel/pSeries_iommu.c |   55 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 54 insertions(+), 1 deletion(-)

--- linux-2.6.11.10.orig/arch/ppc64/kernel/pSeries_iommu.c	2005-05-16 10:50:31.000000000 -0700
+++ linux-2.6.11.10/arch/ppc64/kernel/pSeries_iommu.c	2005-05-20 09:36:25.091359360 -0700
@@ -401,6 +401,8 @@
 	struct device_node *dn, *pdn;
 	unsigned int *dma_window = NULL;
 
+	DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self);
+
 	dn = pci_bus_to_OF_node(bus);
 
 	/* Find nearest ibm,dma-window, walking up the device tree */
@@ -455,6 +457,56 @@
 	}
 }
 
+static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
+{
+	struct device_node *pdn, *dn;
+	struct iommu_table *tbl;
+	int *dma_window = NULL;
+
+	DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, dev->pretty_name);
+
+	/* dev setup for LPAR is a little tricky, since the device tree might
+	 * contain the dma-window properties per-device and not neccesarily
+	 * for the bus. So we need to search upwards in the tree until we
+	 * either hit a dma-window property, OR find a parent with a table
+	 * already allocated.
+	 */
+	dn = pci_device_to_OF_node(dev);
+
+	for (pdn = dn; pdn && !pdn->iommu_table; pdn = pdn->parent) {
+		dma_window = (unsigned int *)get_property(pdn, "ibm,dma-window", NULL);
+		if (dma_window)
+			break;
+	}
+
+	/* Check for parent == NULL so we don't try to setup the empty EADS
+	 * slots on POWER4 machines.
+	 */
+	if (dma_window == NULL || pdn->parent == NULL) {
+		/* Fall back to regular (non-LPAR) dev setup */
+		DBG("No dma window for device, falling back to regular setup\n");
+		iommu_dev_setup_pSeries(dev);
+		return;
+	} else {
+		DBG("Found DMA window, allocating table\n");
+	}
+
+	if (!pdn->iommu_table) {
+		/* iommu_table_setparms_lpar needs bussubno. */
+		pdn->bussubno = pdn->phb->bus->number;
+
+		tbl = (struct iommu_table *)kmalloc(sizeof(struct iommu_table),
+						    GFP_KERNEL);
+
+		iommu_table_setparms_lpar(pdn->phb, pdn, tbl, dma_window);
+
+		pdn->iommu_table = iommu_init_table(tbl);
+	}
+
+	if (pdn != dn)
+		dn->iommu_table = pdn->iommu_table;
+}
+
 static void iommu_bus_setup_null(struct pci_bus *b) { }
 static void iommu_dev_setup_null(struct pci_dev *d) { }
 
@@ -479,13 +531,14 @@
 			ppc_md.tce_free	 = tce_free_pSeriesLP;
 		}
 		ppc_md.iommu_bus_setup = iommu_bus_setup_pSeriesLP;
+		ppc_md.iommu_dev_setup = iommu_dev_setup_pSeriesLP;
 	} else {
 		ppc_md.tce_build = tce_build_pSeries;
 		ppc_md.tce_free  = tce_free_pSeries;
 		ppc_md.iommu_bus_setup = iommu_bus_setup_pSeries;
+		ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries;
 	}
 
-	ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries;
 
 	pci_iommu_init();
 }

  parent reply	other threads:[~2005-05-23 23:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-23 23:15 [00/16] -stable review Chris Wright
2005-05-23 23:17 ` [patch 01/16] Fix get_unmapped_area sanity tests Chris Wright
2005-05-23 23:18 ` [patch 02/16] 3c59x: only put the device into D3 when we're actually using WOL Chris Wright
2005-05-25 17:30   ` Daniel Ritz
2005-05-23 23:19 ` [patch 03/16] [EBTABLES]: Fix smp race Chris Wright
2005-05-23 23:20 ` [patch 04/16] ext3: fix race between ext3 make block reservation and reservation window discard Chris Wright
2005-05-30 13:28   ` Rodrigo Steinmüller Wanderley
2005-05-31  6:23     ` Mingming Cao
2005-05-23 23:21 ` Chris Wright [this message]
2005-05-23 23:22 ` [patch 06/16] Fix matroxfb on big-endian hardware Chris Wright
2005-05-23 23:50   ` Al Viro
2005-05-24  1:17     ` Chris Wright
2005-05-24 10:15       ` Petr Vandrovec
2005-05-23 23:24 ` [patch 07/16] ide-disk: Fix LBA8 DMA Chris Wright
2005-05-23 23:25 ` [patch 08/16] [ROSE]: Fix minor security hole Chris Wright
2005-05-23 23:26 ` [patch 09/16] usbaudio: prevent oops & dead keyboard on usb unplugging Chris Wright
2005-05-23 23:27 ` [patch 10/16] usbusx2y: " Chris Wright
2005-05-23 23:28 ` [patch 11/16] USB: fix bug in visor driver with throttle/unthrottle causing oopses Chris Wright
2005-05-23 23:29 ` [patch 12/16] x86_64: check if ptrace RIP is canonical Chris Wright
2005-05-23 23:30 ` [patch 13/16] x86_64: Fix canonical checking for segment registers in ptrace Chris Wright
2005-05-23 23:30 ` [patch 14/16] x86_64: Add a guard page at the end of the 47bit address space Chris Wright
2005-05-23 23:31 ` [patch 15/16] x86_64: When checking vmalloc mappings don't use pte_page Chris Wright
2005-05-23 23:32 ` [patch 16/16] x86_64: Don't look up struct page pointer of physical address in iounmap Chris Wright

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050523232103.GQ27549@shell0.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chuckw@quantumlinux.com \
    --cc=dsd@gentoo.org \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@austin.ibm.com \
    --cc=rdunlap@xenotime.net \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.