Skip to contentSkip to conversation

PCI changes and fixes for 2.5.72

PATCH New Greg KH 1 participant 9 messages Jun 19, 2003

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 PCI changes and fixes for 2.5.72

Hi,

Here's some PCI changes that are against the latest 2.5.72 bk tree. They contain a number of different pci core changes, all listed below. Included in these patches is the pci list locking patch that has been reviewed a bunch on lkml.

Please pull from:

	bk://kernel.bkbits.net/gregkh/linux/pci-2.5

thanks,

greg k-h

p.s. I'll send these as patches in response to this email to lkml for those who want to see them.

 MAINTAINERS              |    6 -
 arch/i386/pci/common.c   |   23 ++++++
 arch/i386/pci/direct.c   |   82 +++++++-----------------
 arch/i386/pci/fixup.c    |    6 -
 arch/i386/pci/irq.c      |    2 
 arch/i386/pci/legacy.c   |    6 -
 arch/i386/pci/numa.c     |   26 ++-----
 arch/i386/pci/pcbios.c   |   22 +-----
 arch/i386/pci/pci.h      |    2 
 arch/ia64/pci/pci.c      |   33 +++++-----
 drivers/acpi/osl.c       |   41 +++---------
 drivers/acpi/pci_root.c  |    2 
 drivers/pci/bus.c        |    6 +
 drivers/pci/hotplug.c    |   36 +++++++---
 drivers/pci/pci-driver.c |   20 +++---
 drivers/pci/pci-sysfs.c  |   24 +++----
 drivers/pci/pci.h        |    3 
 drivers/pci/probe.c      |    2 
 drivers/pci/proc.c       |   53 +++++++++-------
 drivers/pci/search.c     |  155 +++++++++++++++++++++++++++++++++++++++++------
 include/linux/pci.h      |   41 ++++++++----
 21 files changed, 351 insertions(+), 240 deletions(-)

-----

David Mosberger:
o PCI: move pci_domain_nr() inside "#ifdef CONFIG_PCI" bracket

Greg Kroah-Hartman:
o PCI: rename pci_get_dev() and pci_put_dev() to pci_dev_get() and pci_dev_put()
o PCI: well, everyone is treating me like the maintainer
o PCI: merge bits missed from the pci locking patch
o PCI: add locking to the pci device lists

Matthew Wilcox:
o PCI: pci_raw_ops patch to fix acpi on ia64
o PCI: Unconfuse /proc
o PCI: Tidy up sysfs a bit

author
#1 lore raw

PATCH 1/1 PCI changes and fixes for 2.5.72

ChangeSet 1.1327.5.1, 2003/06/16 16:43:45-07:00, [email protected]

[PATCH] PCI: Tidy up sysfs a bit

This patch contains a set of uncontroversial changes to PCI sysfs.

- Always output 64-bit resources so userspace doesn't need ifdefs and 32-bit userspace works on 64-bit architectures. Separate them with spaces rather than tabs.
- Prefix hex quantities with "0x"
- Always show 7 resources for non-bridge devices, and all resources for bridges rather than stopping on the first empty resource.

 drivers/pci/pci-sysfs.c |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)
drivers/pci/pci-sysfs.c +11 -13
diff -Nru a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
@@ -18,12 +18,6 @@
 
 #include "pci.h"
 
-#if BITS_PER_LONG == 32
-#define LONG_FORMAT "\t%08lx"
-#else
-#define LONG_FORMAT "\t%16lx"
-#endif
-
 /* show configuration fields */
 #define pci_config_attr(field, format_string)				\
 static ssize_t								\
@@ -36,11 +30,11 @@
 }									\
 static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
 
-pci_config_attr(vendor, "%04x\n");
-pci_config_attr(device, "%04x\n");
-pci_config_attr(subsystem_vendor, "%04x\n");
-pci_config_attr(subsystem_device, "%04x\n");
-pci_config_attr(class, "%06x\n");
+pci_config_attr(vendor, "0x%04x\n");
+pci_config_attr(device, "0x%04x\n");
+pci_config_attr(subsystem_vendor, "0x%04x\n");
+pci_config_attr(subsystem_device, "0x%04x\n");
+pci_config_attr(class, "0x%06x\n");
 pci_config_attr(irq, "%u\n");
 
 /* show resources */
@@ -50,9 +44,13 @@
 	struct pci_dev * pci_dev = to_pci_dev(dev);
 	char * str = buf;
 	int i;
+	int max = 7;
+
+	if (pci_dev->subordinate)
+		max = DEVICE_COUNT_RESOURCE;
 
-	for (i = 0; i < DEVICE_COUNT_RESOURCE && pci_resource_start(pci_dev,i); i++) {
-		str += sprintf(str,LONG_FORMAT LONG_FORMAT LONG_FORMAT "\n",
+	for (i = 0; i < max; i++) {
+		str += sprintf(str,"0x%016lx 0x%016lx 0x%016lx\n",
 			       pci_resource_start(pci_dev,i),
 			       pci_resource_end(pci_dev,i),
 			       pci_resource_flags(pci_dev,i));
author
#2 lore raw

ChangeSet 1.1327.5.2, 2003/06/16 16:44:06-07:00, [email protected]

[PATCH] PCI: Unconfuse /proc

If we are to cope with multiple domains with clashing PCI bus numbers, we must refrain from creating two directories of the same name in /proc/bus/pci. This is one solution to the problem; busses with a non-zero domain number get it prepended.

Alternative solutions include cowardly refusing to create non-domain-zero bus directories, refusing to create directories with clashing names, and sticking our heads in the sand and pretending the problem doesn't exist.

 drivers/pci/proc.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)
drivers/pci/proc.c +5 -1
diff -Nru a/drivers/pci/proc.c b/drivers/pci/proc.c
@@ -383,7 +383,11 @@
 		return -EACCES;
 
 	if (!(de = bus->procdir)) {
-		sprintf(name, "%02x", bus->number);
+		if (pci_domain_nr(bus) == 0) {
+			sprintf(name, "%02x", bus->number);
+		} else {
+			sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
+		}
 		de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
 		if (!de)
 			return -ENOMEM;
author
#3 lore raw

ChangeSet 1.1327.5.3, 2003/06/18 14:56:52-07:00, [email protected]

[PATCH] PCI: move pci_domain_nr() inside "#ifdef CONFIG_PCI" bracket

Trivial build fix: pci_domain_nr() cannot be declared unless CONFIG_PCI is defined (otherwise, struct pci_bus hasn't been defined).

 include/linux/pci.h |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)
include/linux/pci.h +9 -10
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -743,6 +743,15 @@
 	return rc;
 }
 
+/*
+ * PCI domain support.  Sometimes called PCI segment (eg by ACPI),
+ * a PCI domain is defined to be a set of PCI busses which share
+ * configuration space.
+ */
+#ifndef CONFIG_PCI_DOMAINS
+static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
+#endif
+
 #endif /* !CONFIG_PCI */
 
 /* these helpers provide future and backwards compatibility
@@ -799,16 +808,6 @@
 #define PCIPCI_VIAETBF		8
 #define PCIPCI_VSFX		16
 #define PCIPCI_ALIMAGIK		32
-
-/*
- * PCI domain support.  Sometimes called PCI segment (eg by ACPI),
- * a PCI domain is defined to be a set of PCI busses which share
- * configuration space.
- */
-
-#ifndef CONFIG_PCI_DOMAINS
-static inline int pci_domain_nr(struct pci_bus *bus) { return 0; }
-#endif
 
 #endif /* __KERNEL__ */
 #endif /* LINUX_PCI_H */
author
#4 lore raw

ChangeSet 1.1327.5.4, 2003/06/19 15:03:04-07:00, [email protected]

PCI: add locking to the pci device lists.

This also creates two new functions, pci_get_device() and pci_get_subsys() which should be used from now on instead of pci_find_device() and pci_find_subsys().

Thanks to Chris Wright and Andrew Morton for help in reviewing these changes.

 drivers/pci/hotplug.c |   34 +++++++----
 drivers/pci/pci.h     |    3 
 drivers/pci/proc.c    |   43 +++++++-------
 drivers/pci/search.c  |  151 ++++++++++++++++++++++++++++++++++++++++++++------
 include/linux/pci.h   |   11 +++
 5 files changed, 196 insertions(+), 46 deletions(-)
drivers/pci/hotplug.c +23 -11
diff -Nru a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
@@ -173,6 +173,24 @@
 }
 EXPORT_SYMBOL(pci_visit_dev);
 
+static void pci_destroy_dev(struct pci_dev *dev)
+{
+	pci_proc_detach_device(dev);
+	device_unregister(&dev->dev);
+
+	/* Remove the device from the device lists, and prevent any further
+	 * list accesses from this device */
+	spin_lock(&pci_bus_lock);
+	list_del(&dev->bus_list);
+	list_del(&dev->global_list);
+	dev->bus_list.next = dev->bus_list.prev = NULL;
+	dev->global_list.next = dev->global_list.prev = NULL;
+	spin_unlock(&pci_bus_lock);
+
+	pci_free_resources(dev);
+	pci_put_dev(dev);
+}
+
 /**
  * pci_remove_device_safe - remove an unused hotplug device
  * @dev: the device to remove
@@ -186,11 +204,7 @@
 {
 	if (pci_dev_driver(dev))
 		return -EBUSY;
-	device_unregister(&dev->dev);
-	list_del(&dev->bus_list);
-	list_del(&dev->global_list);
-	pci_free_resources(dev);
-	pci_proc_detach_device(dev);
+	pci_destroy_dev(dev);
 	return 0;
 }
 EXPORT_SYMBOL(pci_remove_device_safe);
@@ -237,17 +251,15 @@
 		pci_remove_behind_bridge(dev);
 		pci_proc_detach_bus(b);
 
+		spin_lock(&pci_bus_lock);
 		list_del(&b->node);
+		spin_unlock(&pci_bus_lock);
+
 		kfree(b);
 		dev->subordinate = NULL;
 	}
 
-	device_unregister(&dev->dev);
-	list_del(&dev->bus_list);
-	list_del(&dev->global_list);
-	pci_free_resources(dev);
-	pci_proc_detach_device(dev);
-	pci_put_dev(dev);
+	pci_destroy_dev(dev);
 }
 
 /**
drivers/pci/pci.h +3 -0
diff -Nru a/drivers/pci/pci.h b/drivers/pci/pci.h
@@ -58,3 +58,6 @@
 extern int pci_visit_dev(struct pci_visit *fn,
 			 struct pci_dev_wrapped *wrapped_dev,
 			 struct pci_bus_wrapped *wrapped_parent);
+
+/* Lock for read/write access to pci device and bus lists */
+extern spinlock_t pci_bus_lock;
drivers/pci/proc.c +24 -19

82 lines not on this page · raw message

drivers/pci/search.c +135 -16

222 lines not on this page · raw message

include/linux/pci.h +11 -0
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -566,6 +566,10 @@
 int pci_find_capability (struct pci_dev *dev, int cap);
 struct pci_bus * pci_find_next_bus(const struct pci_bus *from);
 
+struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
+struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
+				unsigned int ss_vendor, unsigned int ss_device,
+				struct pci_dev *from);
 int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val);
 int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val);
 int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val);
@@ -686,6 +690,13 @@
 
 static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int device,
 unsigned int ss_vendor, unsigned int ss_device, const struct pci_dev *from)
+{ return NULL; }
+
+static inline struct pci_dev *pci_get_device (unsigned int vendor, unsigned int device, struct pci_dev *from)
+{ return NULL; }
+
+static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device,
+unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from)
 { return NULL; }
 
 static inline void pci_set_master(struct pci_dev *dev) { }
author
#5 lore raw

ChangeSet 1.1360, 2003/06/19 16:02:39-07:00, [email protected]

[PATCH] PCI: pci_raw_ops patch to fix acpi on ia64

 arch/i386/pci/common.c  |   23 +++++++++++--
 arch/i386/pci/direct.c  |   82 ++++++++++++++----------------------------------
 arch/i386/pci/fixup.c   |    6 +--
 arch/i386/pci/irq.c     |    2 -
 arch/i386/pci/legacy.c  |    6 +--
 arch/i386/pci/numa.c    |   26 ++++-----------
 arch/i386/pci/pcbios.c  |   22 ++----------
 arch/i386/pci/pci.h     |    2 -
 arch/ia64/pci/pci.c     |   33 +++++++++++--------
 drivers/acpi/osl.c      |   41 +++++++-----------------
 drivers/acpi/pci_root.c |    2 -
 include/linux/pci.h     |    7 ++++
 12 files changed, 103 insertions(+), 149 deletions(-)
arch/i386/pci/common.c +20 -3
diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c
@@ -23,7 +23,24 @@
 
 int pcibios_last_bus = -1;
 struct pci_bus *pci_root_bus = NULL;
-struct pci_ops *pci_root_ops = NULL;
+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, PCI_SLOT(devfn), 
+		PCI_FUNC(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, PCI_SLOT(devfn), 
+		PCI_FUNC(devfn), where, size, value);
+}
+
+struct pci_ops pci_root_ops = {
+	.read = pci_read,
+	.write = pci_write,
+};
 
 /*
  * legacy, numa, and acpi all want to call pcibios_scan_root
@@ -115,7 +132,7 @@
 
 	printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
 
-	return pci_scan_bus(busnum, pci_root_ops, NULL);
+	return pci_scan_bus(busnum, &pci_root_ops, NULL);
 }
 
 extern u8 pci_cache_line_size;
@@ -124,7 +141,7 @@
 {
 	struct cpuinfo_x86 *c = &boot_cpu_data;
 
-	if (!pci_root_ops) {
+	if (!raw_pci_ops) {
 		printk("PCI: System does not support PCI\n");
 		return 0;
 	}
arch/i386/pci/direct.c +25 -57

147 lines not on this page · raw message

arch/i386/pci/fixup.c +3 -3
diff -Nru a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
@@ -23,9 +23,9 @@
 		pci_read_config_byte(d, reg++, &subb);
 		DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb);
 		if (busno)
-			pci_scan_bus(busno, pci_root_ops, NULL);	/* Bus A */
+			pci_scan_bus(busno, &pci_root_ops, NULL);	/* Bus A */
 		if (suba < subb)
-			pci_scan_bus(suba+1, pci_root_ops, NULL);	/* Bus B */
+			pci_scan_bus(suba+1, &pci_root_ops, NULL);	/* Bus B */
 	}
 	pcibios_last_bus = -1;
 }
@@ -39,7 +39,7 @@
 	u8 busno;
 	pci_read_config_byte(d, 0x4a, &busno);
 	printk(KERN_INFO "PCI: i440KX/GX host bridge %s: secondary bus %02x\n", d->slot_name, busno);
-	pci_scan_bus(busno, pci_root_ops, NULL);
+	pci_scan_bus(busno, &pci_root_ops, NULL);
 	pcibios_last_bus = -1;
 }
 
arch/i386/pci/irq.c +1 -1
diff -Nru a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
@@ -107,7 +107,7 @@
 		 *  It might be a secondary bus, but in this case its parent is already
 		 *  known (ascending bus order) and therefore pci_scan_bus returns immediately.
 		 */
-		if (busmap[i] && pci_scan_bus(i, pci_root_bus->ops, NULL))
+		if (busmap[i] && pci_scan_bus(i, &pci_root_ops, NULL))
 			printk(KERN_INFO "PCI: Discovered primary peer bus %02x [IRQ]\n", i);
 	pcibios_last_bus = -1;
 }
arch/i386/pci/legacy.c +3 -3
diff -Nru a/arch/i386/pci/legacy.c b/arch/i386/pci/legacy.c
@@ -31,14 +31,14 @@
 		if (pci_bus_exists(&pci_root_buses, n))
 			continue;
 		bus->number = n;
-		bus->ops = pci_root_ops;
+		bus->ops = &pci_root_ops;
 		dev->bus = bus;
 		for (dev->devfn=0; dev->devfn<256; dev->devfn += 8)
 			if (!pci_read_config_word(dev, PCI_VENDOR_ID, &l) &&
 			    l != 0x0000 && l != 0xffff) {
 				DBG("Found device at %02x:%02x [%04x]\n", n, dev->devfn, l);
 				printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
-				pci_scan_bus(n, pci_root_ops, NULL);
+				pci_scan_bus(n, &pci_root_ops, NULL);
 				break;
 			}
 	}
@@ -49,7 +49,7 @@
 
 static int __init pci_legacy_init(void)
 {
-	if (!pci_root_ops) {
+	if (!raw_pci_ops) {
 		printk("PCI: System does not support PCI\n");
 		return 0;
 	}
arch/i386/pci/numa.c +7 -19
diff -Nru a/arch/i386/pci/numa.c b/arch/i386/pci/numa.c
@@ -13,7 +13,7 @@
 #define PCI_CONF1_MQ_ADDRESS(bus, dev, fn, reg) \
 	(0x80000000 | (BUS2LOCAL(bus) << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
 
-static int __pci_conf1_mq_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+static int pci_conf1_mq_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
 	unsigned long flags;
 
@@ -41,7 +41,7 @@
 	return 0;
 }
 
-static int __pci_conf1_mq_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+static int pci_conf1_mq_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
 {
 	unsigned long flags;
 
@@ -71,19 +71,7 @@
 
 #undef PCI_CONF1_MQ_ADDRESS
 
-static int pci_conf1_mq_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
-{
-	return __pci_conf1_mq_read(0, bus->number, PCI_SLOT(devfn), 
-		PCI_FUNC(devfn), where, size, value);
-}
-
-static int pci_conf1_mq_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
-{
-	return __pci_conf1_mq_write(0, bus->number, PCI_SLOT(devfn), 
-		PCI_FUNC(devfn), where, size, value);
-}
-
-static struct pci_ops pci_direct_conf1_mq = {
+static struct pci_raw_ops pci_direct_conf1_mq = {
 	.read	= pci_conf1_mq_read,
 	.write	= pci_conf1_mq_write
 };
@@ -106,9 +94,9 @@
 		pci_read_config_byte(d, reg++, &subb);
 		DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb);
 		if (busno)
-			pci_scan_bus(QUADLOCAL2BUS(quad,busno), pci_root_ops, NULL);	/* Bus A */
+			pci_scan_bus(QUADLOCAL2BUS(quad,busno), &pci_root_ops, NULL);	/* Bus A */
 		if (suba < subb)
-			pci_scan_bus(QUADLOCAL2BUS(quad,suba+1), pci_root_ops, NULL);	/* Bus B */
+			pci_scan_bus(QUADLOCAL2BUS(quad,suba+1), &pci_root_ops, NULL);	/* Bus B */
 	}
 	pcibios_last_bus = -1;
 }
@@ -121,7 +109,7 @@
 {
 	int quad;
 
-	pci_root_ops = &pci_direct_conf1_mq;
+	raw_pci_ops = &pci_direct_conf1_mq;
 
 	if (pcibios_scanned++)
 		return 0;
@@ -132,7 +120,7 @@
 			printk("Scanning PCI bus %d for quad %d\n", 
 				QUADLOCAL2BUS(quad,0), quad);
 			pci_scan_bus(QUADLOCAL2BUS(quad,0), 
-				pci_root_ops, NULL);
+				&pci_root_ops, NULL);
 		}
 	}
 	return 0;
arch/i386/pci/pcbios.c +5 -17
diff -Nru a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c
@@ -172,7 +172,7 @@
 	return (int) (ret & 0xff00) >> 8;
 }
 
-static int __pci_bios_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+static int pci_bios_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
 	unsigned long result = 0;
 	unsigned long flags;
@@ -227,7 +227,7 @@
 	return (int)((result & 0xff00) >> 8);
 }
 
-static int __pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+static int pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
 {
 	unsigned long result = 0;
 	unsigned long flags;
@@ -282,24 +282,12 @@
 	return (int)((result & 0xff00) >> 8);
 }
 
-static int pci_bios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
-{
-	return __pci_bios_read(0, bus->number, PCI_SLOT(devfn), 
-		PCI_FUNC(devfn), where, size, value);
-}
-
-static int pci_bios_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
-{
-	return __pci_bios_write(0, bus->number, PCI_SLOT(devfn),
-		PCI_FUNC(devfn), where, size, value);
-}
-
 
 /*
  * Function table for BIOS32 access
  */
 
-static struct pci_ops pci_bios_access = {
+static struct pci_raw_ops pci_bios_access = {
 	.read =		pci_bios_read,
 	.write =	pci_bios_write
 };
@@ -308,7 +296,7 @@
  * Try to find PCI BIOS.
  */
 
-static struct pci_ops * __devinit pci_find_bios(void)
+static struct pci_raw_ops * __devinit pci_find_bios(void)
 {
 	union bios32 *check;
 	unsigned char sum;
@@ -484,7 +472,7 @@
 static int __init pci_pcbios_init(void)
 {
 	if ((pci_probe & PCI_PROBE_BIOS) 
-		&& ((pci_root_ops = pci_find_bios()))) {
+		&& ((raw_pci_ops = pci_find_bios()))) {
 		pci_probe |= PCI_BIOS_SORT;
 		pci_bios_present = 1;
 	}
arch/i386/pci/pci.h +1 -1
diff -Nru a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
@@ -37,7 +37,7 @@
 
 extern int pcibios_last_bus;
 extern struct pci_bus *pci_root_bus;
-extern struct pci_ops *pci_root_ops;
+extern struct pci_ops pci_root_ops;
 
 /* pci-irq.c */
 
arch/ia64/pci/pci.c +19 -14
diff -Nru a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
@@ -59,7 +59,7 @@
 
 
 static int
-__pci_sal_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+pci_sal_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
 	int result = 0;
 	u64 data = 0;
@@ -75,7 +75,7 @@
 }
 
 static int
-__pci_sal_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+pci_sal_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
 {
 	if ((seg > 255) || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
 		return -EINVAL;
@@ -83,28 +83,33 @@
 	return ia64_sal_pci_config_write(PCI_SAL_ADDRESS(seg, bus, dev, fn, reg), len, value);
 }
 
+struct pci_raw_ops pci_sal_ops = {
+	.read = 	pci_sal_read,
+	.write =	pci_sal_write
+};
+
+struct pci_raw_ops *raw_pci_ops = &pci_sal_ops;	/* default to SAL */
+
 
 static int
-pci_sal_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
+pci_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
 {
-	return __pci_sal_read(pci_domain_nr(bus), bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
-			      where, size, value);
+	return raw_pci_ops->read(pci_domain_nr(bus), bus->number,
+			PCI_SLOT(devfn), PCI_FUNC(devfn), where, size, value);
 }
 
 static int
-pci_sal_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+pci_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
 {
-	return __pci_sal_write(pci_domain_nr(bus), bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
-			       where, size, value);
+	return raw_pci_ops->write(pci_domain_nr(bus), bus->number,
+			PCI_SLOT(devfn), PCI_FUNC(devfn), where, size, value);
 }
 
-struct pci_ops pci_sal_ops = {
-	.read = 	pci_sal_read,
-	.write =	pci_sal_write
+static struct pci_ops pci_root_ops = {
+	.read = pci_read,
+	.write = pci_write,
 };
 
-struct pci_ops *pci_root_ops = &pci_sal_ops;	/* default to SAL */
-
 static int __init
 pci_acpi_init (void)
 {
@@ -307,7 +312,7 @@
 	info.name = name;
 	acpi_walk_resources(handle, METHOD_NAME__CRS, add_window, &info);
 
-	return scan_root_bus(bus, pci_root_ops, controller);
+	return scan_root_bus(bus, &pci_root_ops, controller);
 
 out3:
 	kfree(controller->window);
drivers/acpi/osl.c +12 -29

82 lines not on this page · raw message

drivers/acpi/pci_root.c +0 -2
diff -Nru a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
@@ -44,8 +44,6 @@
 #define ACPI_PCI_ROOT_DRIVER_NAME	"ACPI PCI Root Bridge Driver"
 #define ACPI_PCI_ROOT_DEVICE_NAME	"PCI Root Bridge"
 
-extern struct pci_ops *pci_root_ops;
-
 static int acpi_pci_root_add (struct acpi_device *device);
 static int acpi_pci_root_remove (struct acpi_device *device, int type);
 
include/linux/pci.h +7 -0
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -486,6 +486,13 @@
 	int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
 };
 
+struct pci_raw_ops {
+	int (*read)(int dom, int bus, int dev, int func, int reg, int len, u32 *val);
+	int (*write)(int dom, int bus, int dev, int func, int reg, int len, u32 val);
+};
+
+extern struct pci_raw_ops *raw_pci_ops;
+
 struct pci_bus_region {
 	unsigned long start;
 	unsigned long end;
author
#6 lore raw

ChangeSet 1.1361, 2003/06/19 16:10:44-07:00, [email protected]

PCI: merge bits missed from the pci locking patch.

 drivers/pci/bus.c |    6 ++++++
 1 files changed, 6 insertions(+)
drivers/pci/bus.c +6 -0
diff -Nru a/drivers/pci/bus.c b/drivers/pci/bus.c
@@ -93,7 +93,11 @@
 			continue;
 
 		device_add(&dev->dev);
+
+		spin_lock(&pci_bus_lock);
 		list_add_tail(&dev->global_list, &pci_devices);
+		spin_unlock(&pci_bus_lock);
+
 		pci_proc_attach_device(dev);
 		pci_create_sysfs_dev_files(dev);
 
@@ -108,7 +112,9 @@
 		 * it and then scan for unattached PCI devices.
 		 */
 		if (dev->subordinate && list_empty(&dev->subordinate->node)) {
+			spin_lock(&pci_bus_lock);
 			list_add_tail(&dev->subordinate->node, &dev->bus->children);
+			spin_unlock(&pci_bus_lock);
 			pci_bus_add_devices(dev->subordinate);
 		}
 	}
author
#7 lore raw

ChangeSet 1.1362, 2003/06/19 16:12:34-07:00, [email protected]

PCI: well, everyone is treating me like the maintainer...

And Martin has said he doesn't want to do it for 2.5/2.6

 MAINTAINERS |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
MAINTAINERS +3 -3
diff -Nru a/MAINTAINERS b/MAINTAINERS
@@ -1429,10 +1429,10 @@
 S:	Maintained
 
 PCI SUBSYSTEM
-P:	Martin Mares
-M:	[email protected]
+P:	Greg Kroah-Hartman
+M:	[email protected]
 L:	[email protected]
-S:	Odd Fixes
+S:	Supported
 
 PCI HOTPLUG CORE
 P:	Greg Kroah-Hartman
author
#8 lore raw

ChangeSet 1.1363, 2003/06/19 16:14:18-07:00, [email protected]

[PATCH] PCI: rename pci_get_dev() and pci_put_dev() to pci_dev_get() and pci_dev_put()

This makes things more consistant with the other get and put functions in the driver code.

 drivers/pci/hotplug.c    |    2 +-
 drivers/pci/pci-driver.c |   20 ++++++++++----------
 drivers/pci/probe.c      |    2 +-
 drivers/pci/proc.c       |    4 ++--
 drivers/pci/search.c     |    4 ++--
 include/linux/pci.h      |    4 ++--
 6 files changed, 18 insertions(+), 18 deletions(-)
drivers/pci/hotplug.c +1 -1
diff -Nru a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
@@ -188,7 +188,7 @@
 	spin_unlock(&pci_bus_lock);
 
 	pci_free_resources(dev);
-	pci_put_dev(dev);
+	pci_dev_put(dev);
 }
 
 /**
drivers/pci/pci-driver.c +10 -10
diff -Nru a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
@@ -138,10 +138,10 @@
 
 	drv = to_pci_driver(dev->driver);
 	pci_dev = to_pci_dev(dev);
-	pci_get_dev(pci_dev);
+	pci_dev_get(pci_dev);
 	error = __pci_device_probe(drv, pci_dev);
 	if (error)
-		pci_put_dev(pci_dev);
+		pci_dev_put(pci_dev);
 
 	return error;
 }
@@ -156,7 +156,7 @@
 			drv->remove(pci_dev);
 		pci_dev->driver = NULL;
 	}
-	pci_put_dev(pci_dev);
+	pci_dev_put(pci_dev);
 	return 0;
 }
 
@@ -448,18 +448,18 @@
 }
 
 /**
- * pci_get_dev - increments the reference count of the pci device structure
+ * pci_dev_get - increments the reference count of the pci device structure
  * @dev: the device being referenced
  *
  * Each live reference to a device should be refcounted.
  *
  * Drivers for PCI devices should normally record such references in
  * their probe() methods, when they bind to a device, and release
- * them by calling pci_put_dev(), in their disconnect() methods.
+ * them by calling pci_dev_put(), in their disconnect() methods.
  *
  * A pointer to the device with the incremented reference counter is returned.
  */
-struct pci_dev *pci_get_dev (struct pci_dev *dev)
+struct pci_dev *pci_dev_get(struct pci_dev *dev)
 {
 	struct device *tmp;
 
@@ -474,13 +474,13 @@
 }
 
 /**
- * pci_put_dev - release a use of the pci device structure
+ * pci_dev_put - release a use of the pci device structure
  * @dev: device that's been disconnected
  *
  * Must be called when a user of a device is finished with it.  When the last
  * user of the device calls this function, the memory of the device is freed.
  */
-void pci_put_dev(struct pci_dev *dev)
+void pci_dev_put(struct pci_dev *dev)
 {
 	if (dev)
 		put_device(&dev->dev);
@@ -504,5 +504,5 @@
 EXPORT_SYMBOL(pci_unregister_driver);
 EXPORT_SYMBOL(pci_dev_driver);
 EXPORT_SYMBOL(pci_bus_type);
-EXPORT_SYMBOL(pci_get_dev);
-EXPORT_SYMBOL(pci_put_dev);
+EXPORT_SYMBOL(pci_dev_get);
+EXPORT_SYMBOL(pci_dev_put);
drivers/pci/probe.c +1 -1
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
@@ -524,7 +524,7 @@
 	}
 	device_initialize(&dev->dev);
 	dev->dev.release = pci_release_dev;
-	pci_get_dev(dev);
+	pci_dev_get(dev);
 
 	pci_name_device(dev);
 
drivers/pci/proc.c +2 -2
diff -Nru a/drivers/pci/proc.c b/drivers/pci/proc.c
@@ -334,7 +334,7 @@
 {
 	if (v) {
 		struct pci_dev *dev = v;
-		pci_put_dev(dev);
+		pci_dev_put(dev);
 	}
 }
 
@@ -471,7 +471,7 @@
 	first_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	if (dev == first_dev)
 		seq_puts(m, "PCI devices found:\n");
-	pci_put_dev(first_dev);
+	pci_dev_put(first_dev);
 
 	drv = pci_dev_driver(dev);
 
drivers/pci/search.c +2 -2
diff -Nru a/drivers/pci/search.c b/drivers/pci/search.c
@@ -205,8 +205,8 @@
 	}
 	dev = NULL;
 exit:
-	pci_put_dev(from);
-	dev = pci_get_dev(dev);
+	pci_dev_put(from);
+	dev = pci_dev_get(dev);
 	spin_unlock(&pci_bus_lock);
 	return dev;
 }
include/linux/pci.h +2 -2
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -556,8 +556,8 @@
 void pci_read_bridge_bases(struct pci_bus *child);
 struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);
 int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
-extern struct pci_dev *pci_get_dev(struct pci_dev *dev);
-extern void pci_put_dev(struct pci_dev *dev);
+extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
+extern void pci_dev_put(struct pci_dev *dev);
 
 extern void pci_remove_bus_device(struct pci_dev *dev);