Skip to contentSkip to conversation

PCI: Add 'nodomains' boot option, and pci_domains_supported global

PATCH In review Jeff Garzik 2 participants 7 messages Oct 11, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 PCI: Add 'nodomains' boot option, and pci_domains_supported global

* Introduce pci_domains_supported global, hardcoded to zero if !CONFIG_PCI_DOMAINS.

* Introduce 'nodomains' boot option, which clears pci_domains_supported on platforms that enable it by default (x86, x86-64, and others when they are converted to use this).

---
Revised per Andi's comments, and split into two patches.

As found in jgarzik/misc-2.6.git#ALL and jgarzik/misc-2.6.git#pciseg.

 Documentation/kernel-parameters.txt |    2 ++
 drivers/pci/pci.c                   |   13 +++++++++++++
 include/linux/pci.h                 |    7 +++++--
 3 files changed, 20 insertions(+), 2 deletions(-)

5d29ec863821020822c00384eca8b1006ab3c686

Documentation/kernel-parameters.txt +2 -0
index 4d175c7..a4d43ae 100644
@@ -1269,6 +1269,8 @@ and is between 256 and 4096 characters. It is defined in the file
 				Mechanism 1.
 		conf2		[X86-32] Force use of PCI Configuration
 				Mechanism 2.
+		nodomains	[PCI] Disable support for multiple PCI
+				root domains (aka PCI segments, in ACPI-speak).
 		nommconf	[X86-32,X86_64] Disable use of MMCONFIG for PCI
 				Configuration
 		nomsi		[MSI] If the PCI_MSI kernel config parameter is
drivers/pci/pci.c +13 -0
index 37c00f6..a82b4d1 100644
@@ -22,6 +22,10 @@
 
 unsigned int pci_pm_d3_delay = 10;
 
+#ifdef CONFIG_PCI_DOMAINS
+int pci_domains_supported = 1;
+#endif
+
 #define DEFAULT_CARDBUS_IO_SIZE		(256)
 #define DEFAULT_CARDBUS_MEM_SIZE	(64*1024*1024)
 /* pci=cbmemsize=nnM,cbiosize=nn can override this */
@@ -1566,6 +1570,13 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
 	return bars;
 }
 
+static void __devinit pci_no_domains(void)
+{
+#ifdef CONFIG_PCI_DOMAINS
+	pci_domains_supported = 0;
+#endif
+}
+
 static int __devinit pci_init(void)
 {
 	struct pci_dev *dev = NULL;
@@ -1585,6 +1596,8 @@ static int __devinit pci_setup(char *str)
 		if (*str && (str = pcibios_setup(str)) && *str) {
 			if (!strcmp(str, "nomsi")) {
 				pci_no_msi();
+			} else if (!strcmp(str, "nodomains")) {
+				pci_no_domains();
 			} else if (!strncmp(str, "cbiosize=", 9)) {
 				pci_cardbus_io_size = memparse(str + 9, &str);
 			} else if (!strncmp(str, "cbmemsize=", 10)) {
include/linux/pci.h +5 -2
index 038a0dc..ee99959 100644
@@ -685,13 +685,16 @@ extern void pci_unblock_user_cfg_access(struct pci_dev *dev);
  * a PCI domain is defined to be a set of PCI busses which share
  * configuration space.
  */
-#ifndef CONFIG_PCI_DOMAINS
+#ifdef CONFIG_PCI_DOMAINS
+extern int pci_domains_supported;
+#else
+enum { pci_domains_supported = 0; };
 static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
 static inline int pci_proc_domain(struct pci_bus *bus)
 {
 	return 0;
 }
-#endif
+#endif /* CONFIG_PCI_DOMAINS */
 
 #else /* CONFIG_PCI is not enabled */
 
#1 lore raw

PATCH v2 2/2 X86: Introduce and enable PCI domain support

* fix bug in pci_read() and pci_write() which prevented PCI domain support from working (hardcoded domain 0).

* unconditionally enable CONFIG_PCI_DOMAINS

* implement pci_domain_nr() and pci_proc_domain(), as required of all arches when CONFIG_PCI_DOMAINS is enabled.

* store domain in struct pci_sysdata, as assigned by ACPI

* support "pci=nodomains"

---
Revised per Andi's comments, and split into two patches.

As found in jgarzik/misc-2.6.git#ALL and jgarzik/misc-2.6.git#pciseg.

 arch/i386/Kconfig        |    5 +++++
 arch/i386/pci/acpi.c     |   13 +++++++------
 arch/i386/pci/common.c   |    6 ++++--
 arch/x86_64/Kconfig      |    5 +++++
 include/asm-i386/pci.h   |   12 ++++++++++++
 include/asm-x86_64/pci.h |   12 ++++++++++++
 6 files changed, 45 insertions(+), 8 deletions(-)

d2978874ffb1a980238ab68aa528b700a1ec2b30

arch/i386/Kconfig +5 -0
index 97b64d7..5237791 100644
@@ -1137,6 +1137,11 @@ config PCI_MMCONFIG
 	depends on PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY)
 	default y
 
+config PCI_DOMAINS
+	bool
+	depends on PCI
+	default y
+
 source "drivers/pci/pcie/Kconfig"
 
 source "drivers/pci/Kconfig"
arch/i386/pci/acpi.c +7 -6
index bc8a44b..5c9827b 100644
@@ -11,6 +11,12 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
 	struct pci_sysdata *sd;
 	int pxm;
 
+	if (domain && !pci_domains_supported) {
+		printk(KERN_WARNING "PCI: Multiple domains not supported "
+		       "(dom %d, bus %d)\n", domain, busnum);
+		return NULL;
+	}
+
 	/* Allocate per-root-bus (not per bus) arch-specific data.
 	 * TODO: leak; this memory is never freed.
 	 * It's arguable whether it's worth the trouble to care.
@@ -21,12 +27,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
 		return NULL;
 	}
 
-	if (domain != 0) {
-		printk(KERN_WARNING "PCI: Multiple domains not supported\n");
-		kfree(sd);
-		return NULL;
-	}
-
+	sd->domain = domain;
 	sd->node = -1;
 
 	pxm = acpi_get_pxm(device->handle);
arch/i386/pci/common.c +4 -2
index ebc6f3c..6d7a274 100644
@@ -29,12 +29,14 @@ struct pci_raw_ops *raw_pci_ops;
 
 static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
 {
-	return raw_pci_ops->read(0, bus->number, devfn, where, size, value);
+	return raw_pci_ops->read(pci_domain_nr(bus), bus->number,
+				 devfn, where, size, value);
 }
 
 static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
 {
-	return raw_pci_ops->write(0, bus->number, devfn, where, size, value);
+	return raw_pci_ops->write(pci_domain_nr(bus), bus->number,
+				  devfn, where, size, value);
 }
 
 struct pci_ops pci_root_ops = {
arch/x86_64/Kconfig +5 -0
index b4d9089..f3ea9e0 100644
@@ -724,6 +724,11 @@ config PCI_MMCONFIG
 	bool "Support mmconfig PCI config space access"
 	depends on PCI && ACPI
 
+config PCI_DOMAINS
+	bool
+	depends on PCI
+	default y
+
 source "drivers/pci/pcie/Kconfig"
 
 source "drivers/pci/Kconfig"
include/asm-i386/pci.h +12 -0
index 4fcacc7..0d91605 100644
@@ -5,12 +5,24 @@
 #ifdef __KERNEL__
 
 struct pci_sysdata {
+	int		domain;		/* PCI domain */
 	int		node;		/* NUMA node */
 };
 
 /* scan a bus after allocating a pci_sysdata for it */
 extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
 
+static inline int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_sysdata *sd = bus->sysdata;
+	return sd->domain;
+}
+
+static inline int pci_proc_domain(struct pci_bus *bus)
+{
+	return pci_domain_nr(bus);
+}
+
 #include <linux/mm.h>		/* for struct page */
 
 /* Can be used to override the logic in pci_scan_bus for skipping
include/asm-x86_64/pci.h +12 -0
index 5da8cb0..0a123d6 100644
@@ -6,12 +6,24 @@
 #ifdef __KERNEL__
 
 struct pci_sysdata {
+	int		domain;		/* PCI domain */
 	int		node;		/* NUMA node */
 	void*		iommu;		/* IOMMU private data */
 };
 
 extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);
 
+static inline int pci_domain_nr(struct pci_bus *bus)
+{
+	struct pci_sysdata *sd = bus->sysdata;
+	return sd->domain;
+}
+
+static inline int pci_proc_domain(struct pci_bus *bus)
+{
+	return pci_domain_nr(bus);
+}
+
 #ifdef CONFIG_CALGARY_IOMMU
 static inline void* pci_iommu(struct pci_bus *bus)
 {
#2 lore raw

Re: [PATCH v2 2/2] X86: Introduce and enable PCI domain support

Quoted 9 lines · Jeff Garzik

* fix bug in pci_read() and pci_write() which prevented PCI domain support from working (hardcoded domain 0).

* unconditionally enable CONFIG_PCI_DOMAINS

* implement pci_domain_nr() and pci_proc_domain(), as required of all arches when CONFIG_PCI_DOMAINS is enabled.

Quoted 7 lines

* store domain in struct pci_sysdata, as assigned by ACPI

* support "pci=nodomains"

---
Revised per Andi's comments, and split into two patches.

Ugh:
In file included from include/linux/pci.h:785,
from drivers/pci/access.c:2:
include/asm/pci.h:16: error: redefinition of 'pci_domain_nr' include/linux/pci.h:692: error: previous definition of 'pci_domain_nr' was here include/asm/pci.h:22: error: redefinition of 'pci_proc_domain' include/linux/pci.h:694: error: previous definition of 'pci_proc_domain' was here make[1]: *** [drivers/pci/access.o] Error 1

I'll see if I can fix it up...

thanks,

greg k-h

#3 lore raw

Re: [PATCH v2 2/2] X86: Introduce and enable PCI domain support

Quoted 27 lines · Greg KH
Quoted 9 lines · Jeff Garzik

* fix bug in pci_read() and pci_write() which prevented PCI domain support from working (hardcoded domain 0).

* unconditionally enable CONFIG_PCI_DOMAINS

* implement pci_domain_nr() and pci_proc_domain(), as required of all arches when CONFIG_PCI_DOMAINS is enabled.

Quoted 7 lines

* store domain in struct pci_sysdata, as assigned by ACPI

* support "pci=nodomains"

---
Revised per Andi's comments, and split into two patches.

Ugh:
In file included from include/linux/pci.h:785,
from drivers/pci/access.c:2:
include/asm/pci.h:16: error: redefinition of 'pci_domain_nr' include/linux/pci.h:692: error: previous definition of 'pci_domain_nr' was here include/asm/pci.h:22: error: redefinition of 'pci_proc_domain' include/linux/pci.h:694: error: previous definition of 'pci_proc_domain' was here make[1]: *** [drivers/pci/access.o] Error 1

Quoted 1 line

I'll see if I can fix it up...

Hm, sorry, my fault, error with not upadating the config...

nevermind...

greg k-h

#4 lore raw
In reply to Jeff Garzik
Quoted 11 lines · Jeff Garzik

* Introduce pci_domains_supported global, hardcoded to zero if !CONFIG_PCI_DOMAINS.

* Introduce 'nodomains' boot option, which clears pci_domains_supported on platforms that enable it by default (x86, x86-64, and others when they are converted to use this).

---
Revised per Andi's comments, and split into two patches.

Quoted 6 lines

As found in jgarzik/misc-2.6.git#ALL and jgarzik/misc-2.6.git#pciseg.

 Documentation/kernel-parameters.txt |    2 ++
 drivers/pci/pci.c                   |   13 +++++++++++++
 include/linux/pci.h                 |    7 +++++--
 3 files changed, 20 insertions(+), 2 deletions(-)

As a note, if this wasn't obvious, this was not implemented in x86-specific code because I think other arches can/should be able to hook into this.

The default !CONFIG_PCI_DOMAINS implementation continues to work for all such arches.

#5 lore raw
In reply to Jeff Garzik
Quoted 1 line · Jeff Garzik

+enum { pci_domains_supported = 0; };

I don't think you compiled this option :)

I've fixed the compiler error in my version.

thanks,

greg k-h

#6 lore raw
Quoted 6 lines · Greg KH
Quoted 1 line · Jeff Garzik

+enum { pci_domains_supported = 0; };

I don't think you compiled this option :)

I've fixed the compiler error in my version.

Thanks!