Skip to contentSkip to conversation

PCI fixes for 2.6.10-rc1

PATCH New Greg KH 3 participants 52 messages Nov 12, 2004 – Nov 13, 2004

Subsystems (15)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 PCI fixes for 2.6.10-rc1

Hi,

Here are some PCI patches for 2.6.10-rc1. They include:
- pci roms ysfs interface
- lots of some pci_find_device fixes
- other minor stuff.

Almost all of these patches lot of these have been in the past few -mm releases.

Please pull from:

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

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.

 arch/i386/pci/changelog                |   62 -----
 Documentation/kernel-parameters.txt    |   12 +
 arch/i386/kernel/acpi/boot.c           |   10 
 arch/i386/kernel/quirks.c              |    4 
 arch/i386/pci/acpi.c                   |   32 +-
 arch/i386/pci/common.c                 |    4 
 arch/i386/pci/fixup.c                  |  129 ++++++++++
 arch/i386/pci/irq.c                    |   41 ++-
 arch/i386/pci/mmconfig.c               |    5 
 arch/ia64/pci/pci.c                    |   66 ++++-
 arch/ppc/platforms/chrp_pci.c          |    2 
 arch/ppc/platforms/gemini_pci.c        |    2 
 arch/ppc/platforms/k2.c                |    3 
 arch/ppc/platforms/lopec.c             |    3 
 arch/ppc/platforms/mcpn765.c           |    7 
 arch/ppc/platforms/pcore.c             |    3 
 arch/ppc/platforms/pmac_pci.c          |    4 
 arch/ppc/platforms/pplus.c             |    9 
 arch/ppc/platforms/prep_pci.c          |   15 -
 arch/ppc/platforms/prpmc750.c          |    3 
 arch/ppc/platforms/sandpoint.c         |    3 
 arch/sh/drivers/pci/fixups-dreamcast.c |    2 
 arch/sparc/kernel/ebus.c               |    6 
 arch/sparc64/kernel/isa.c              |    2 
 arch/sparc64/kernel/pci_iommu.c        |    3 
 arch/v850/kernel/rte_mb_a_pci.c        |    2 
 arch/x86_64/kernel/pci-gart.c          |    2 
 arch/x86_64/pci/mmconfig.c             |    3 
 drivers/atm/idt77252.c                 |   12 -
 drivers/char/agp/sis-agp.c             |    2 
 drivers/char/cyclades.c                |    4 
 drivers/char/drm/drm_drv.h             |    3 
 drivers/char/watchdog/scx200_wdt.c     |   12 -
 drivers/ide/ide.c                      |   14 +
 drivers/isdn/tpam/tpam_main.c          |    4 
 drivers/media/video/zr36120.c          |    5 
 drivers/misc/ibmasm/module.c           |    6 
 drivers/net/tulip/de4x5.c              |    8 
 drivers/pci/Makefile                   |    8 
 drivers/pci/bus.c                      |   31 +-
 drivers/pci/hotplug/acpiphp_glue.c     |    4 
 drivers/pci/hotplug/cpcihp_generic.c   |   18 -
 drivers/pci/hotplug/fakephp.c          |  128 ++++++++++
 drivers/pci/hotplug/ibmphp_core.c      |   10 
 drivers/pci/hotplug/pciehp.h           |   21 +
 drivers/pci/hotplug/pciehp_core.c      |   18 -
 drivers/pci/hotplug/pciehp_ctrl.c      |  391 +++++++++++++++++++++------------
 drivers/pci/hotplug/pciehp_hpc.c       |   36 ++-
 drivers/pci/hotplug/pciehp_pci.c       |    8 
 drivers/pci/hotplug/pciehprm_acpi.c    |   43 +++
 drivers/pci/hotplug/shpchp_ctrl.c      |   34 ++
 drivers/pci/hotplug/shpchp_hpc.c       |    1 
 drivers/pci/pci-acpi.c                 |  209 +++++++++++++++++
 drivers/pci/pci-driver.c               |   15 -
 drivers/pci/pci-sysfs.c                |  120 ++++++++++
 drivers/pci/pci.c                      |   12 +
 drivers/pci/pci.h                      |    6 
 drivers/pci/probe.c                    |   33 +-
 drivers/pci/quirks.c                   |   19 +
 drivers/pci/remove.c                   |    2 
 drivers/pci/rom.c                      |  225 ++++++++++++++++++
 drivers/pci/setup-res.c                |    2 
 drivers/video/matrox/matroxfb_base.c   |    7 
 include/asm-generic/vmlinux.lds.h      |    3 
 include/linux/ioport.h                 |    5 
 include/linux/pci-acpi.h               |   61 +++++
 include/linux/pci.h                    |   43 ++-
 include/linux/pci_ids.h                |    8 
 sound/pci/cmipci.c                     |    7 
 69 files changed, 1613 insertions(+), 424 deletions(-)

-----

<jdittmer:ppp0.net>:
o fakephp: add pci bus rescan ability
o fakephp: introduce pci_bus_add_device

<thockin:google.com>:
o PCI: small PCI probe patch for odd 64 bit BARs

Adrian Bunk:
o PCI: kill old PCI changelog

Bjorn Helgaas:
o PCI: remove unconditional PCI ACPI IRQ routing
o PCI: propagate pci_enable_device() errors
o acpi: better encapsulate eisa_set_level_irq()

Dely Sy:
o PCI: ASPM patch for
o PCI: Updated patch to fix adapter speed mismatch for 2.6 kernel
o PCI: Updated patch to add ExpressCard support

Greg Kroah-Hartman:
o PCI Hotplug: fix up remaining MODULE_PARAM usage in pci hotplug drivers
o PCI: remove kernel log message about drivers not calling pci_disable_device()
o PCI: use pci_dev_present() in irq.c check

Hanna V. Linder:
o prep_pci.c: replace pci_find_device with pci_get_device
o pplus.c: replace pci_find_device with pci_get_device
o pmac_pci.c: replace pci_find_device with pci_get_device
o pcore.c: replace pci_find_device with pci_get_device
o mcpn765.c: replace pci_find_device with pci_get_device
o prpmc750.c: replace pci_find_device with pci_get_device
o sandpoint.c: replace pci_find_device with pci_get_device
o fixups-dreamcast.c: replace pci_find_device with pci_get_device
o ebus.c: replace pci_find_device with pci_get_device
o isa.c: replace pci_find_device with pci_get_device
o pci_iommu.c: replace pci_find_device with pci_get_device
o ret_mb_a_pci.c: replace pci_find_device with pci_get_device
o pci-gart.c: replace pci_find_device with pci_get_device
o sis-agp.c: replace pci_find_device with pci_get_device
o drm_drv.h: replace pci_find_device
o cmipci.c: convert pci_find_device to pci_get_device
o k2.c: replace pci_find_device with pci_get_device
o lopec.c: replace pci_find_device with pci_get_device
o matroxfb_base.c: convert pci_find_device to pci_get_device
o gemini_pci.c: replace pci_find_device with for_each_pci_dev
o chrp_pci.c: replace pci_find_device with for_each_pci_dev
o ibmphp_core.c: replace pci_get_device with pci_dev_present
o scx200_wdt.c: replace pci_find_device with pci_dev_present
o ide.c: replace pci_find_device with pci_dev_present
o zr36120.c: Convert pci_find_device to pci_dev_present
o cyclades.c: replace pci_find_device
o PCI: Changed pci_find_device to pci_get_device

Ivan Kokshaysky:
o PCI: add pci_fixup_early

Jon Smirl:
o PCI: add PCI ROMs to sysfs

Kenji Kaneshige:
o PCI: add hook for PCI resource deallocation

Thomas Gleixner:
o Lock initializer unifying Batch 2 (PCI)

Tom L. Nguyen:
o PCI: pci-mmconfig fix

author
#1 lore raw

PATCH 1/1 PCI fixes for 2.6.10-rc1

ChangeSet 1.2000.10.1, 2004/10/20 15:35:44-07:00, [email protected]

PCI: use pci_dev_present() in irq.c check

 arch/i386/pci/irq.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
arch/i386/pci/irq.c +6 -10
diff -Nru a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
@@ -452,21 +452,17 @@
 
 #endif
 
-
 static __init int intel_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
 {
-	struct pci_dev *dev1, *dev2;
+	static struct pci_device_id pirq_440gx[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_0) },
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443GX_2) },
+		{ },
+	};
 
 	/* 440GX has a proprietary PIRQ router -- don't use it */
-	dev1 = pci_get_device(PCI_VENDOR_ID_INTEL,
-				PCI_DEVICE_ID_INTEL_82443GX_0, NULL);
-	dev2 = pci_get_device(PCI_VENDOR_ID_INTEL,
-				PCI_DEVICE_ID_INTEL_82443GX_2, NULL);
-	if ((dev1 != NULL) || (dev2 != NULL)) {
-		pci_dev_put(dev1);
-		pci_dev_put(dev2);
+	if (pci_dev_present(pirq_440gx))
 		return 0;
-	}
 
 	switch(device)
 	{
author
#2 lore raw

ChangeSet 1.2026.35.2, 2004/10/28 15:14:02-05:00, [email protected]

[PATCH] acpi: better encapsulate eisa_set_level_irq()

From: Bjorn Helgaas <[email protected]>

Move the "only do this once" stuff from acpi_register_gsi() into eisa_set_level().

 arch/i386/kernel/acpi/boot.c |    8 +-------
 arch/i386/pci/irq.c          |    9 ++++++++-
 2 files changed, 9 insertions(+), 8 deletions(-)
arch/i386/kernel/acpi/boot.c +1 -7
diff -Nru a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
@@ -457,16 +457,10 @@
 	 * Make sure all (legacy) PCI IRQs are set as level-triggered.
 	 */
 	if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
-		static u16 irq_mask;
 		extern void eisa_set_level_irq(unsigned int irq);
 
-		if (edge_level == ACPI_LEVEL_SENSITIVE) {
-			if ((gsi < 16) && !((1 << gsi) & irq_mask)) {
-				Dprintk(KERN_DEBUG PREFIX "Setting GSI %u as level-triggered\n", gsi);
-				irq_mask |= (1 << gsi);
+		if (edge_level == ACPI_LEVEL_SENSITIVE)
 				eisa_set_level_irq(gsi);
-			}
-		}
 	}
 #endif
 
arch/i386/pci/irq.c +8 -1
diff -Nru a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
@@ -127,8 +127,15 @@
 {
 	unsigned char mask = 1 << (irq & 7);
 	unsigned int port = 0x4d0 + (irq >> 3);
-	unsigned char val = inb(port);
+	unsigned char val;
+	static u16 eisa_irq_mask;
 
+	if (irq >= 16 || (1 << irq) & eisa_irq_mask)
+		return;
+
+	eisa_irq_mask |= (1 << irq);
+	printk("PCI: setting IRQ %u as level-triggered\n", irq);
+	val = inb(port);
 	if (!(val & mask)) {
 		DBG(" -> edge");
 		outb(val | mask, port);
author
#3 lore raw

ChangeSet 1.2026.35.3, 2004/10/28 15:15:12-05:00, [email protected]

[PATCH] PCI: propagate pci_enable_device() errors

From: Bjorn Helgaas <[email protected]>

Jeff Garzik pointed out that I should have propagated the error returned from pci_enable_device() rather than making up -ENODEV.

Propagate pci_enable_device() error returns rather than using -ENODEV.

 drivers/atm/idt77252.c        |    4 ++--
 drivers/isdn/tpam/tpam_main.c |    4 ++--
 drivers/misc/ibmasm/module.c  |    6 +++---
 drivers/net/tulip/de4x5.c     |    4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
drivers/atm/idt77252.c +2 -2
diff -Nru a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
@@ -3685,9 +3685,9 @@
 	int i, err;
 
 
-	if (pci_enable_device(pcidev)) {
+	if ((err = pci_enable_device(pcidev))) {
 		printk("idt77252: can't enable PCI device at %s\n", pci_name(pcidev));
-		return -ENODEV;
+		return err;
 	}
 
 	if (pci_read_config_word(pcidev, PCI_REVISION_ID, &revision)) {
drivers/isdn/tpam/tpam_main.c +2 -2
diff -Nru a/drivers/isdn/tpam/tpam_main.c b/drivers/isdn/tpam/tpam_main.c
@@ -88,10 +88,10 @@
 	tpam_card *card, *c;
 	int i, err;
 
-	if (pci_enable_device(dev)) {
+	if ((err = pci_enable_device(dev))) {
 		printk(KERN_ERR "TurboPAM: can't enable PCI device at %s\n",
 			pci_name(dev));
-		return -ENODEV;
+		return err;
 	}
 
 	/* allocate memory for the board structure */
drivers/misc/ibmasm/module.c +3 -3
diff -Nru a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
@@ -59,13 +59,13 @@
 
 static int __init ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
-	int result = -ENOMEM;
+	int err, result = -ENOMEM;
 	struct service_processor *sp;
 
-	if (pci_enable_device(pdev)) {
+	if ((err = pci_enable_device(pdev))) {
 		printk(KERN_ERR "%s: can't enable PCI device at %s\n",
 			DRIVER_NAME, pci_name(pdev));
-		return -ENODEV;
+		return err;
 	}
 
 	sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
drivers/net/tulip/de4x5.c +2 -2
diff -Nru a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
@@ -2242,8 +2242,8 @@
 		return -ENODEV;
 
 	/* Ok, the device seems to be for us. */
-	if (pci_enable_device (pdev))
-		return -ENODEV;
+	if ((error = pci_enable_device (pdev)))
+		return error;
 
 	if (!(dev = alloc_etherdev (sizeof (struct de4x5_private)))) {
 		error = -ENOMEM;
author
#4 lore raw

ChangeSet 1.2026.35.4, 2004/10/28 15:56:14-05:00, [email protected]

[PATCH] PCI: remove unconditional PCI ACPI IRQ routing

From: Bjorn Helgaas <[email protected]>

Now that PCI interrupts are routed in pci_enable_device(), remove the unconditional routing previously done in pci_acpi_init().

This has the potential to break drivers that don't use pci_enable_device() correctly, so I also added a "pci=routeirq" kernel option that restores the previous behavior. I intend to remove that option, along with all the code below, in a month or so.

 Documentation/kernel-parameters.txt |    4 ++++
 arch/i386/pci/acpi.c                |   30 ++++++++++++++++++++++--------
 arch/i386/pci/common.c              |    4 ++++
 arch/ia64/pci/pci.c                 |   33 ++++++++++++++++++++++++++-------
 4 files changed, 56 insertions(+), 15 deletions(-)
Documentation/kernel-parameters.txt +4 -0
diff -Nru a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
@@ -912,6 +912,10 @@
 					enabled.
 		noacpi			[IA-32] Do not use ACPI for IRQ routing
 					or for PCI scanning.
+		routeirq		Do IRQ routing for all PCI devices.
+					This is normally done in pci_enable_device(),
+					so this option is a temporary workaround
+					for broken drivers that don't call it.
 
 		firmware		[ARM] Do not re-enumerate the bus but
 					instead just use the configuration
arch/i386/pci/acpi.c +22 -8
diff -Nru a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
@@ -15,6 +15,7 @@
 	return pcibios_scan_root(busnum);
 }
 
+extern int pci_routeirq;
 static int __init pci_acpi_init(void)
 {
 	struct pci_dev *dev = NULL;
@@ -30,14 +31,27 @@
 	pcibios_scanned++;
 	pcibios_enable_irq = acpi_pci_irq_enable;
 
-	/*
-	 * PCI IRQ routing is set up by pci_enable_device(), but we
-	 * also do it here in case there are still broken drivers that
-	 * don't use pci_enable_device().
-	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
-		acpi_pci_irq_enable(dev);
-
+	if (pci_routeirq) {
+		/*
+		 * PCI IRQ routing is set up by pci_enable_device(), but we
+		 * also do it here in case there are still broken drivers that
+		 * don't use pci_enable_device().
+		 */
+		printk(KERN_INFO "** Routing PCI interrupts for all devices because \"pci=routeirq\"\n");
+		printk(KERN_INFO "** was specified.  If this was required to make a driver work,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to [email protected]\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+		while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+			acpi_pci_irq_enable(dev);
+	} else {
+		printk(KERN_INFO "** PCI interrupts are no longer routed automatically.  If this\n");
+		printk(KERN_INFO "** causes a device to stop working, it is probably because the\n");
+		printk(KERN_INFO "** driver failed to call pci_enable_device().  As a temporary\n");
+		printk(KERN_INFO "** workaround, the \"pci=routeirq\" argument restores the old\n");
+		printk(KERN_INFO "** behavior.  If this argument makes the device work again,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to [email protected]\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+	}
 #ifdef CONFIG_X86_IO_APIC
 	if (acpi_ioapic)
 		print_IO_APIC();
arch/i386/pci/common.c +4 -0
diff -Nru a/arch/i386/pci/common.c b/arch/i386/pci/common.c
@@ -23,6 +23,7 @@
 unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
 				PCI_PROBE_MMCONF;
 
+int pci_routeirq;
 int pcibios_last_bus = -1;
 struct pci_bus *pci_root_bus = NULL;
 struct pci_raw_ops *raw_pci_ops;
@@ -226,6 +227,9 @@
 		return NULL;
 	} else if (!strcmp(str, "assign-busses")) {
 		pci_probe |= PCI_ASSIGN_ALL_BUSSES;
+		return NULL;
+	} else if (!strcmp(str, "routeirq")) {
+		pci_routeirq = 1;
 		return NULL;
 	}
 	return str;
arch/ia64/pci/pci.c +26 -7
diff -Nru a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
@@ -46,6 +46,8 @@
 #define DBG(x...)
 #endif
 
+static int pci_routeirq;
+
 /*
  * Low-level SAL-based PCI configuration access functions. Note that SAL
  * calls are already serialized (via sal_lock), so we don't need another
@@ -141,13 +143,28 @@
 
 	acpi_get_devices(NULL, acpi_map_iosapic, NULL, NULL);
 #endif
-	/*
-	 * PCI IRQ routing is set up by pci_enable_device(), but we
-	 * also do it here in case there are still broken drivers that
-	 * don't use pci_enable_device().
-	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
-		acpi_pci_irq_enable(dev);
+
+	if (pci_routeirq) {
+		/*
+		 * PCI IRQ routing is set up by pci_enable_device(), but we
+		 * also do it here in case there are still broken drivers that
+		 * don't use pci_enable_device().
+		 */
+		printk(KERN_INFO "** Routing PCI interrupts for all devices because \"pci=routeirq\"\n");
+		printk(KERN_INFO "** was specified.  If this was required to make a driver work,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to [email protected]\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+		while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+			acpi_pci_irq_enable(dev);
+	} else {
+		printk(KERN_INFO "** PCI interrupts are no longer routed automatically.  If this\n");
+		printk(KERN_INFO "** causes a device to stop working, it is probably because the\n");
+		printk(KERN_INFO "** driver failed to call pci_enable_device().  As a temporary\n");
+		printk(KERN_INFO "** workaround, the \"pci=routeirq\" argument restores the old\n");
+		printk(KERN_INFO "** behavior.  If this argument makes the device work again,\n");
+		printk(KERN_INFO "** please email the output of \"lspci\" to [email protected]\n");
+		printk(KERN_INFO "** so I can fix the driver.\n");
+	}
 
 	return 0;
 }
@@ -443,6 +460,8 @@
 char * __init
 pcibios_setup (char *str)
 {
+	if (!strcmp(str, "routeirq"))
+		pci_routeirq = 1;
 	return NULL;
 }
 
author
#5 lore raw

ChangeSet 1.2026.35.5, 2004/10/28 16:25:06-05:00, [email protected]

[PATCH] PCI: add hook for PCI resource deallocation

From: Kenji Kaneshige <[email protected]>

This patch adds a hook 'pcibios_disable_device()' into pci_disable_device() to call architecture specific PCI resource deallocation code. It's a opposite part of pcibios_enable_device(). We need this hook to deallocate architecture specific PCI resource such as IRQ resource, etc.. This patch is just for adding the hook, so 'pcibios_disable_device()' is defined as a null function on all architecture so far.

I tested this patch on i386, x86_64 and ia64. But it has not been tested on other architectures because I don't have these machines.

 drivers/pci/pci.c |   12 ++++++++++++
 1 files changed, 12 insertions(+)
drivers/pci/pci.c +12 -0
diff -Nru a/drivers/pci/pci.c b/drivers/pci/pci.c
@@ -375,6 +375,16 @@
 }
 
 /**
+ * pcibios_disable_device - disable arch specific PCI resources for device dev
+ * @dev: the PCI device to disable
+ *
+ * Disables architecture specific PCI resources for the device. This
+ * is the default implementation. Architecture implementations can
+ * override this.
+ */
+void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
+
+/**
  * pci_disable_device - Disable PCI device after use
  * @dev: PCI device to be disabled
  *
@@ -394,6 +404,8 @@
 		pci_command &= ~PCI_COMMAND_MASTER;
 		pci_write_config_word(dev, PCI_COMMAND, pci_command);
 	}
+
+	pcibios_disable_device(dev);
 }
 
 /**
author
#6 lore raw

ChangeSet 1.2026.35.6, 2004/10/28 16:26:11-05:00, [email protected]

[PATCH] PCI: Changed pci_find_device to pci_get_device

From: Hanna Linder <[email protected]>

Another simple patch to complete the /i386 conversion to pci_get_device. I was able to compile and boot this patch to verify it didn't break anything (on my T22).

 arch/i386/pci/acpi.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/i386/pci/acpi.c +1 -1
diff -Nru a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
@@ -41,7 +41,7 @@
 		printk(KERN_INFO "** was specified.  If this was required to make a driver work,\n");
 		printk(KERN_INFO "** please email the output of \"lspci\" to [email protected]\n");
 		printk(KERN_INFO "** so I can fix the driver.\n");
-		while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
+		while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
 			acpi_pci_irq_enable(dev);
 	} else {
 		printk(KERN_INFO "** PCI interrupts are no longer routed automatically.  If this\n");
author
#7 lore raw

ChangeSet 1.2026.55.2, 2004/11/01 14:51:06-08:00, [email protected]

[PATCH] PCI: Updated patch to add ExpressCard support

This patch adds ExpressCard support to pciehp driver. It also includes the code that implements _OSC method call in driver/pci/pci-acpi.c for use by the drivers.

 drivers/pci/Makefile                |    5 
 drivers/pci/hotplug/pciehp.h        |   21 +
 drivers/pci/hotplug/pciehp_core.c   |   18 -
 drivers/pci/hotplug/pciehp_ctrl.c   |  382 ++++++++++++++++++++++--------------
 drivers/pci/hotplug/pciehp_hpc.c    |   30 +-
 drivers/pci/hotplug/pciehprm_acpi.c |   43 +++-
 drivers/pci/pci-acpi.c              |  209 +++++++++++++++++++
 include/linux/pci-acpi.h            |   61 +++++
 8 files changed, 601 insertions(+), 168 deletions(-)
drivers/pci/Makefile +5 -0
diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile
@@ -28,6 +28,11 @@
 obj-$(CONFIG_X86_VISWS) += setup-irq.o
 obj-$(CONFIG_PCI_MSI) += msi.o
 
+#
+# ACPI Related PCI FW Functions
+#
+obj-$(CONFIG_ACPI)    += pci-acpi.o
+
 # Cardbus & CompactPCI use setup-bus
 obj-$(CONFIG_HOTPLUG) += setup-bus.o
 
drivers/pci/hotplug/pciehp.h +17 -4
diff -Nru a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
@@ -127,8 +127,7 @@
 	enum pci_bus_speed speed;
 	u32 first_slot;		/* First physical slot number */  /* PCIE only has 1 slot */
 	u8 slot_bus;		/* Bus where the slots handled by this controller sit */
-	u8 push_flag;
-	u16 ctlrcap;
+	u8 ctrlcap;
 	u16 vendor_id;
 };
 
@@ -180,6 +179,21 @@
 
 #define DISABLE_CARD			1
 
+/* Field definitions in Slot Capabilities Register */
+#define ATTN_BUTTN_PRSN	0x00000001
+#define	PWR_CTRL_PRSN	0x00000002
+#define MRL_SENS_PRSN	0x00000004
+#define ATTN_LED_PRSN	0x00000008
+#define PWR_LED_PRSN	0x00000010
+#define HP_SUPR_RM_SUP	0x00000020
+
+#define ATTN_BUTTN(cap)		(cap & ATTN_BUTTN_PRSN)
+#define POWER_CTRL(cap)		(cap & PWR_CTRL_PRSN)
+#define MRL_SENS(cap)		(cap & MRL_SENS_PRSN)
+#define ATTN_LED(cap)		(cap & ATTN_LED_PRSN)
+#define PWR_LED(cap)		(cap & PWR_LED_PRSN) 
+#define HP_SUPR_RM(cap)		(cap & HP_SUPR_RM_SUP)
+
 /*
  * error Messages
  */
@@ -312,8 +326,7 @@
 		int *num_ctlr_slots,
 		int *first_device_num,
 		int *physical_slot_num,
-		int *updown,
-		int *flags);
+		u8 *ctrlcap);
 
 struct hpc_ops {
 	int	(*power_on_slot)	(struct slot *slot);
drivers/pci/hotplug/pciehp_core.c +10 -8
diff -Nru a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
@@ -204,11 +204,10 @@
 	int num_ctlr_slots;		/* Not needed; PCI Express has 1 slot per port*/
 	int first_device_num;		/* Not needed */
 	int physical_slot_num;
-	int updown;			/* Not needed */
+	u8 ctrlcap;			
 	int rc;
-	int flags;			/* Not needed */
 
-	rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags);
+	rc = pcie_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &ctrlcap);
 	if (rc) {
 		err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device);
 		return (-1);
@@ -217,10 +216,10 @@
 	ctrl->num_slots = num_ctlr_slots;	/* PCI Express has 1 slot per port */
 	ctrl->slot_device_offset = first_device_num;
 	ctrl->first_slot = physical_slot_num;
-	ctrl->slot_num_inc = updown; 	/* Not needed */		/* either -1 or 1 */
+	ctrl->ctrlcap = ctrlcap; 	
 
-	dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n",
-		__FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, updown, 
+	dbg("%s: bus(0x%x) num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) ctrlcap(%x) for b:d (%x:%x)\n",
+		__FUNCTION__, ctrl->slot_bus, num_ctlr_slots, first_device_num, physical_slot_num, ctrlcap, 
 		ctrl->bus, ctrl->device);
 
 	return (0);
@@ -237,7 +236,9 @@
 	dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
 
 	hotplug_slot->info->attention_status = status;
-	slot->hpc_ops->set_attention_status(slot, status);
+	
+	if (ATTN_LED(slot->ctrl->ctrlcap)) 
+		slot->hpc_ops->set_attention_status(slot, status);
 
 	return 0;
 }
@@ -451,7 +452,8 @@
 
 	t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
 	dbg("%s: adpater value %x\n", __FUNCTION__, value);
-	if (!value) {
+	
+	if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
 		rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
 		if (rc) {
 			/* Done with exclusive hardware access */
drivers/pci/hotplug/pciehp_ctrl.c +242 -140

499 lines not on this page · raw message

drivers/pci/hotplug/pciehp_hpc.c +20 -10
diff -Nru a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
@@ -182,7 +182,7 @@
 #define MRL_SENS_PRSN	0x00000004
 #define ATTN_LED_PRSN	0x00000008
 #define PWR_LED_PRSN	0x00000010
-#define HP_SUPR_RM	0x00000020
+#define HP_SUPR_RM_SUP	0x00000020
 #define HP_CAP		0x00000040
 #define SLOT_PWR_VALUE	0x000003F8
 #define SLOT_PWR_LIMIT	0x00000C00
@@ -237,8 +237,8 @@
 static spinlock_t hpc_event_lock;
 
 DEFINE_DBG_BUFFER		/* Debug string buffer for entire HPC defined here */
-static struct php_ctlr_state_s *php_ctlr_list_head;	/* HPC state linked list */
-static int ctlr_seq_num;	/* Controller sequence # */
+static struct php_ctlr_state_s *php_ctlr_list_head = 0;	/* HPC state linked list */
+static int ctlr_seq_num = 0;	/* Controller sequence # */
 static spinlock_t list_lock;
 
 static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs);
@@ -691,8 +691,7 @@
 	int *num_ctlr_slots,	/* number of slots in this HPC; only 1 in PCIE  */	
 	int *first_device_num,	/* PCI dev num of the first slot in this PCIE	*/
 	int *physical_slot_num,	/* phy slot num of the first slot in this PCIE	*/
-	int *updown,		/* physical_slot_num increament: 1 or -1	*/
-	int *flags)
+	u8 *ctrlcap)
 {
 	struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
 	u32 slot_cap;
@@ -716,8 +715,9 @@
 	}
 	
 	*physical_slot_num = slot_cap >> 19;
-
-	*updown = -1;
+	dbg("%s: PSN %d \n", __FUNCTION__, *physical_slot_num);
+	
+	*ctrlcap = slot_cap & 0x0000007f;
 
 	DBG_LEAVE_ROUTINE 
 	return 0;
@@ -1259,7 +1259,7 @@
 	static int first = 1;
 	u16 temp_word;
 	u16 cap_reg;
-	u16 intr_enable;
+	u16 intr_enable = 0;
 	u32 slot_cap;
 	int cap_base, saved_cap_base;
 	u16 slot_status, slot_ctrl;
@@ -1412,6 +1412,7 @@
 			} else 
 				php_ctlr->irq = pdev->irq;
 		}
+
 		rc = request_irq(php_ctlr->irq, pcie_isr, SA_SHIRQ, MY_NAME, (void *) ctrl);
 		dbg("%s: request_irq %d for hpc%d (returns %d)\n", __FUNCTION__, php_ctlr->irq, ctlr_seq_num, rc);
 		if (rc) {
@@ -1426,9 +1427,18 @@
 		goto abort_free_ctlr;
 	}
 	dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word);
+	dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap);
 
-	intr_enable = ATTN_BUTTN_ENABLE | PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE |
-					PRSN_DETECT_ENABLE;
+	intr_enable = intr_enable | PRSN_DETECT_ENABLE;
+
+	if (ATTN_BUTTN(slot_cap))
+		intr_enable = intr_enable | ATTN_BUTTN_ENABLE;
+	
+	if (POWER_CTRL(slot_cap))
+		intr_enable = intr_enable | PWR_FAULT_DETECT_ENABLE;
+	
+	if (MRL_SENS(slot_cap))
+		intr_enable = intr_enable | MRL_DETECT_ENABLE;
 
 	temp_word = (temp_word & ~intr_enable) | intr_enable; 
 
drivers/pci/hotplug/pciehprm_acpi.c +37 -6

92 lines not on this page · raw message

drivers/pci/pci-acpi.c new file +209 -0

209 lines not on this page · raw message

include/linux/pci-acpi.h new file +61 -0

61 lines not on this page · raw message

author
#8 lore raw

ChangeSet 1.2026.55.3, 2004/11/01 15:02:37-08:00, [email protected]

[PATCH] PCI: Updated patch to fix adapter speed mismatch for 2.6 kernel

After doing more testing, I found that I couldn't use quirk to set the flag to identify the chipset, for there are platforms that have other bridge chip with PCI-X hotpluggable slots in the same system. Therefore, I use the vendor id and device id to identify the bridge chip that needs the workaround. The code doing the workaround remains unchanged.

 drivers/pci/hotplug/shpchp_ctrl.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+)
drivers/pci/hotplug/shpchp_ctrl.c +34 -0
diff -Nru a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -1157,6 +1157,40 @@
 		return -1;
 	}
 
+	
+	if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
+		if (slots_not_empty)
+			return WRONG_BUS_FREQUENCY;
+		
+		if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
+			err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return WRONG_BUS_FREQUENCY;
+		}
+		wait_for_ctrl_irq (ctrl);
+		
+		if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
+			err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
+				  __FUNCTION__);
+			err("%s: Error code (%d)\n", __FUNCTION__, rc);
+			up(&ctrl->crit_sect);
+			return WRONG_BUS_FREQUENCY;
+		}
+		/* turn on board, blink green LED, turn off Amber LED */
+		if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
+			err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
+			up(&ctrl->crit_sect);
+			return rc;
+		}
+		wait_for_ctrl_irq (ctrl);
+
+		if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
+			err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
+			up(&ctrl->crit_sect);
+			return rc;  
+		}
+	}
+ 
 	rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &adapter_speed);
 	/* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */
 	/* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC,  0xa = PCI-X 133 Mhz 266, */
author
#9 lore raw

ChangeSet 1.2026.66.11, 2004/11/05 14:09:34-08:00, [email protected]

PCI: remove kernel log message about drivers not calling pci_disable_device()

 drivers/pci/pci-driver.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
drivers/pci/pci-driver.c +6 -9
diff -Nru a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
@@ -271,17 +271,14 @@
 		pci_dev->driver = NULL;
 	}
 
-#ifdef CONFIG_DEBUG_KERNEL
 	/*
-	 * If the driver decides to stop using the device, it should
-	 * call pci_disable_device().
+	 * We would love to complain here if pci_dev->is_enabled is set, that
+	 * the driver should have called pci_disable_device(), but the
+	 * unfortunate fact is there are too many odd BIOS and bridge setups
+	 * that don't like drivers doing that all of the time.  
+	 * Oh well, we can dream of sane hardware when we sleep, no matter how
+	 * horrible the crap we have to deal with is when we are awake...
 	 */
-	if (pci_dev->is_enabled) {
-		dev_warn(&pci_dev->dev, "Device was removed without properly "
-			 "calling pci_disable_device(). This may need fixing.\n");
-		/* WARN_ON(1); */
-	}
-#endif /* CONFIG_DEBUG_KERNEL */
 
 	pci_dev_put(pci_dev);
 	return 0;
author
#10 lore raw

ChangeSet 1.2026.66.12, 2004/11/05 15:05:02-08:00, [email protected]

[PATCH] PCI: kill old PCI changelog

There's not much value in shipping a changelog who's last update was five years ago.

 arch/i386/pci/changelog |   62 ------------------------------------------------
 1 files changed, 62 deletions(-)
arch/i386/pci/changelog deleted +0 -62
diff -Nru a/arch/i386/pci/changelog b/arch/i386/pci/changelog
@@ -1,62 +0,0 @@
-/*
- * CHANGELOG :
- * Jun 17, 1994 : Modified to accommodate the broken pre-PCI BIOS SPECIFICATION
- *	Revision 2.0 present on <[email protected]>'s ASUS mainboard.
- *
- * Jan 5,  1995 : Modified to probe PCI hardware at boot time by Frederic
- *     Potter, [email protected]
- *
- * Jan 10, 1995 : Modified to store the information about configured pci
- *      devices into a list, which can be accessed via /proc/pci by
- *      Curtis Varner, [email protected]
- *
- * Jan 12, 1995 : CPU-PCI bridge optimization support by Frederic Potter.
- *	Alpha version. Intel & UMC chipset support only.
- *
- * Apr 16, 1995 : Source merge with the DEC Alpha PCI support. Most of the code
- *	moved to drivers/pci/pci.c.
- *
- * Dec 7, 1996  : Added support for direct configuration access of boards
- *      with Intel compatible access schemes ([email protected])
- *
- * Feb 3, 1997  : Set internal functions to static, save/restore flags
- *	avoid dead locks reading broken PCI BIOS, [email protected] 
- *
- * Apr 26, 1997 : Fixed case when there is BIOS32, but not PCI BIOS
- *	([email protected])
- *
- * May 7,  1997 : Added some missing cli()'s. [mj]
- * 
- * Jun 20, 1997 : Corrected problems in "conf1" type accesses.
- *      ([email protected])
- *
- * Aug 2,  1997 : Split to PCI BIOS handling and direct PCI access parts
- *	and cleaned it up...     Martin Mares <[email protected]>
- *
- * Feb 6,  1998 : No longer using BIOS to find devices and device classes. [mj]
- *
- * May 1,  1998 : Support for peer host bridges. [mj]
- *
- * Jun 19, 1998 : Changed to use spinlocks, so that PCI configuration space
- *	can be accessed from interrupts even on SMP systems. [mj]
- *
- * August  1998 : Better support for peer host bridges and more paranoid
- *	checks for direct hardware access. Ugh, this file starts to look as
- *	a large gallery of common hardware bug workarounds (watch the comments)
- *	-- the PCI specs themselves are sane, but most implementors should be
- *	hit hard with \hammer scaled \magstep5. [mj]
- *
- * Jan 23, 1999 : More improvements to peer host bridge logic. i450NX fixup. [mj]
- *
- * Feb 8,  1999 : Added UM8886BF I/O address fixup. [mj]
- *
- * August  1999 : New resource management and configuration access stuff. [mj]
- *
- * Sep 19, 1999 : Use PCI IRQ routing tables for detection of peer host bridges.
- *		  Based on ideas by Chris Frantz and David Hinds. [mj]
- *
- * Sep 28, 1999 : Handle unreported/unassigned IRQs. Thanks to Shuu Yamaguchi
- *		  for a lot of patience during testing. [mj]
- *
- * Oct  8, 1999 : Split to pci-i386.c, pci-pc.c and pci-visws.c. [mj]
- */
\ No newline at end of file
author
#11 lore raw

ChangeSet 1.2026.66.13, 2004/11/05 15:05:24-08:00, [email protected]

[PATCH] PCI: add pci_fixup_early

Port Ivan's early PCI fixups patch to 2.6.10-rc1. Also fix some indentation to make it less than 80 columns.

From: Ivan Kokshaysky <[email protected]>

 drivers/pci/probe.c               |    3 +++
 include/asm-generic/vmlinux.lds.h |    3 +++
 include/linux/pci.h               |   34 ++++++++++++++++++----------------
 3 files changed, 24 insertions(+), 16 deletions(-)
drivers/pci/probe.c +3 -0
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
@@ -478,6 +478,9 @@
 	/* "Unknown power state" */
 	dev->current_state = 4;
 
+	/* Early fixups, before probing the BARs */
+	pci_fixup_device(pci_fixup_early, dev);
+
 	switch (dev->hdr_type) {		    /* header type */
 	case PCI_HEADER_TYPE_NORMAL:		    /* standard header */
 		if (class == PCI_CLASS_BRIDGE_PCI)
include/asm-generic/vmlinux.lds.h +3 -0
diff -Nru a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
@@ -18,6 +18,9 @@
 									\
 	/* PCI quirks */						\
 	.pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {	\
+		VMLINUX_SYMBOL(__start_pci_fixups_early) = .;		\
+		*(.pci_fixup_early)					\
+		VMLINUX_SYMBOL(__end_pci_fixups_early) = .;		\
 		VMLINUX_SYMBOL(__start_pci_fixups_header) = .;		\
 		*(.pci_fixup_header)					\
 		VMLINUX_SYMBOL(__end_pci_fixups_header) = .;		\
include/linux/pci.h +18 -16
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -989,31 +989,33 @@
  */
 
 struct pci_fixup {
-	u16 vendor, device;			/* You can use PCI_ANY_ID here of course */
+	u16 vendor, device;	/* You can use PCI_ANY_ID here of course */
 	void (*hook)(struct pci_dev *dev);
 };
 
 enum pci_fixup_pass {
-	pci_fixup_header,	/* Called immediately after reading configuration header */
+	pci_fixup_early,	/* Before probing BARs */
+	pci_fixup_header,	/* After reading configuration header */
 	pci_fixup_final,	/* Final phase of device fixups */
 	pci_fixup_enable,	/* pci_enable_device() time */
 };
 
 /* Anonymous variables would be nice... */
-#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook)					\
-	static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__	\
-	__attribute__((__section__(".pci_fixup_header"))) = {				\
-		vendor, device, hook };
-
-#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook)				\
-	static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__	\
-	__attribute__((__section__(".pci_fixup_final"))) = {				\
-		vendor, device, hook };
-
-#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook)				\
-	static struct pci_fixup __pci_fixup_##vendor##device##hook __attribute_used__	\
-	__attribute__((__section__(".pci_fixup_enable"))) = {				\
-		vendor, device, hook };
+#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook)	\
+	static struct pci_fixup __pci_fixup_##name __attribute_used__	\
+	__attribute__((__section__(#section))) = { vendor, device, hook };
+#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early,			\
+			vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header,			\
+			vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final,			\
+			vendor##device##hook, vendor, device, hook)
+#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook)			\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable,			\
+			vendor##device##hook, vendor, device, hook)
 
 
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
author Acked-by Ingo Molnar
#12 lore raw

ChangeSet 1.2026.66.14, 2004/11/05 15:05:43-08:00, [email protected]

[PATCH] Lock initializer unifying Batch 2 (PCI)

To make spinlock/rwlock initialization consistent all over the kernel, this patch converts explicit lock-initializers into spin_lock_init() and rwlock_init() calls.

Currently, spinlocks and rwlocks are initialized in two different ways:

lock = SPIN_LOCK_UNLOCKED
spin_lock_init(&lock)

rwlock = RW_LOCK_UNLOCKED
rwlock_init(&rwlock)

this patch converts all explicit lock initializations to spin_lock_init() or rwlock_init(). (Besides consistency this also helps automatic lock validators and debugging code.)

The conversion was done with a script, it was verified manually and it was reviewed, compiled and tested as far as possible on x86, ARM, PPC.

There is no runtime overhead or actual code change resulting out of this patch, because spin_lock_init() and rwlock_init() are macros and are thus equivalent to the explicit initialization method.

That's the second batch of the unifying patches.

 drivers/pci/hotplug/acpiphp_glue.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +2 -2
diff -Nru a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
@@ -389,7 +389,7 @@
 
 	bridge->pci_bus = pci_find_bus(seg, bus);
 
-	bridge->res_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&bridge->res_lock);
 
 	/* to be overridden when we decode _CRS	*/
 	bridge->sub = bridge->bus;
@@ -457,7 +457,7 @@
 		return;
 	}
 
-	bridge->res_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&bridge->res_lock);
 
 	bridge->bus = bridge->pci_bus->number;
 	bridge->sub = bridge->pci_bus->subordinate;
author
#13 lore raw

ChangeSet 1.2026.66.15, 2004/11/05 15:06:04-08:00, [email protected]

[PATCH] PCI: ASPM patch for

This is the ASPM patch against 2.6.10-rc1-mm2.

As mentioned in my last email, this patch has a slight difference than the one for 2.6.10-rc1, because the irqbalance quirk was moved from drivers/pci/quirks.c in 2.6.10-rc1 to arch/i386/kernel/quirks.c in 2.6.10-rc1-mm2.

 arch/i386/kernel/quirks.c         |    4 -
 arch/i386/pci/fixup.c             |   91 ++++++++++++++++++++++++++++++++++++++
 drivers/pci/hotplug/pciehp_ctrl.c |    9 +++
 drivers/pci/hotplug/pciehp_hpc.c  |    6 +-
 drivers/pci/hotplug/pciehp_pci.c  |    8 +++
 drivers/pci/hotplug/shpchp_hpc.c  |    1 
 drivers/pci/pci.h                 |    2 
 drivers/pci/quirks.c              |   18 ++++---
 include/linux/pci_ids.h           |    8 ++-
 9 files changed, 133 insertions(+), 14 deletions(-)
arch/i386/kernel/quirks.c +2 -2
diff -Nru a/arch/i386/kernel/quirks.c b/arch/i386/kernel/quirks.c
@@ -6,7 +6,7 @@
 
 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP)
 
-void __init quirk_intel_irqbalance(struct pci_dev *dev)
+void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
 {
 	u8 config, rev;
 	u32 word;
@@ -45,5 +45,5 @@
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7320_MCH,	quirk_intel_irqbalance);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7525_MCH,	quirk_intel_irqbalance);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_SMCH,	quirk_intel_irqbalance);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7520_MCH,	quirk_intel_irqbalance);
 #endif
arch/i386/pci/fixup.c +91 -0

94 lines not on this page · raw message

drivers/pci/hotplug/pciehp_ctrl.c +8 -1
diff -Nru a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -38,6 +38,7 @@
 #include <linux/wait.h>
 #include <linux/smp_lock.h>
 #include <linux/pci.h>
+#include "../pci.h"
 #include "pciehp.h"
 #include "pciehprm.h"
 
@@ -1220,7 +1221,13 @@
 				pciehp_configure_device(ctrl, new_func);
 			}
 		} while (new_func);
-  		
+
+ 		/* 
+ 		 * Some PCI Express root ports require fixup after hot-plug operation.
+ 		 */
+ 		if (pcie_mch_quirk)
+ 			pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
+ 
   		if (PWR_LED(ctrl->ctrlcap)) {
   			/* Wait for exclusive access to hardware */
   			down(&ctrl->crit_sect);
drivers/pci/hotplug/pciehp_hpc.c +4 -2
diff -Nru a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
@@ -741,6 +741,8 @@
 		if (php_ctlr->irq) {
 			free_irq(php_ctlr->irq, ctrl);
 			php_ctlr->irq = 0;
+			if (!pcie_mch_quirk) 
+				pci_disable_msi(php_ctlr->pci_dev);
 		}
 	}
 	if (php_ctlr->pci_dev) 
@@ -1402,8 +1404,8 @@
 		start_int_poll_timer( php_ctlr, 10 );   /* start with 10 second delay */
 	} else {
 		/* Installs the interrupt handler */
-		dbg("%s: pciehp_msi_quirk = %x\n", __FUNCTION__, pciehp_msi_quirk);
-		if (!pciehp_msi_quirk) {
+		dbg("%s: pcie_mch_quirk = %x\n", __FUNCTION__, pcie_mch_quirk);
+		if (!pcie_mch_quirk) {
 			rc = pci_enable_msi(pdev);
 			if (rc) {
 				info("Can't get msi for the hotplug controller\n");
drivers/pci/hotplug/pciehp_pci.c +8 -0
diff -Nru a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
@@ -82,9 +82,11 @@
 {
 	int rc = 0;
 	int j;
+	struct pci_bus *pbus;
 
 	dbg("%s: bus/dev/func = %x/%x/%x\n", __FUNCTION__, func->bus,
 				func->device, func->function);
+	pbus = func->pci_dev->bus;
 
 	for (j=0; j<8 ; j++) {
 		struct pci_dev* temp = pci_find_slot(func->bus,
@@ -93,6 +95,12 @@
 			pci_remove_bus_device(temp);
 		}
 	}
+	/* 
+	 * Some PCI Express root ports require fixup after hot-plug operation.
+	 */
+	if (pcie_mch_quirk) 
+		pci_fixup_device(pci_fixup_final, pbus->self);
+	
 	return rc;
 }
 
drivers/pci/hotplug/shpchp_hpc.c +1 -0
diff -Nru a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
@@ -792,6 +792,7 @@
 		if (php_ctlr->irq) {
 			free_irq(php_ctlr->irq, ctrl);
 			php_ctlr->irq = 0;
+			pci_disable_msi(php_ctlr->pci_dev);
 		}
 	}
 	if (php_ctlr->pci_dev) {
drivers/pci/pci.h +1 -1
diff -Nru a/drivers/pci/pci.h b/drivers/pci/pci.h
@@ -61,7 +61,7 @@
 /* Lock for read/write access to pci device and bus lists */
 extern spinlock_t pci_bus_lock;
 
-extern int pciehp_msi_quirk;
+extern int pcie_mch_quirk;
 extern struct device_attribute pci_dev_attrs[];
 
 /**
drivers/pci/quirks.c +11 -7
diff -Nru a/drivers/pci/quirks.c b/drivers/pci/quirks.c
@@ -1135,7 +1135,7 @@
 #endif
 
 #ifdef CONFIG_SCSI_SATA
-static void __init quirk_intel_ide_combined(struct pci_dev *pdev)
+static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
 {
 	u8 prog, comb, tmp;
 	int ich = 0;
@@ -1209,14 +1209,15 @@
 #endif /* CONFIG_SCSI_SATA */
 
 
-int pciehp_msi_quirk;
+int pcie_mch_quirk;
 
-static void __devinit quirk_pciehp_msi(struct pci_dev *pdev)
+static void __devinit quirk_pcie_mch(struct pci_dev *pdev)
 {
-	pciehp_msi_quirk = 1;
+	pcie_mch_quirk = 1;
 }
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_SMCH,	quirk_pciehp_msi );
-
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7520_MCH,	quirk_pcie_mch );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7320_MCH,	quirk_pcie_mch );
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_E7525_MCH,	quirk_pcie_mch );
 
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end)
 {
@@ -1265,4 +1266,7 @@
 	pci_do_fixups(dev, start, end);
 }
 
-EXPORT_SYMBOL(pciehp_msi_quirk);
+EXPORT_SYMBOL(pcie_mch_quirk);
+#ifdef CONFIG_HOTPLUG
+EXPORT_SYMBOL(pci_fixup_device);
+#endif
include/linux/pci_ids.h +7 -1
diff -Nru a/include/linux/pci_ids.h b/include/linux/pci_ids.h
@@ -2206,8 +2206,14 @@
 #define PCI_DEVICE_ID_INTEL_82830_CGC	0x3577
 #define PCI_DEVICE_ID_INTEL_82855GM_HB	0x3580
 #define PCI_DEVICE_ID_INTEL_82855GM_IG	0x3582
-#define PCI_DEVICE_ID_INTEL_SMCH	0x3590
+#define PCI_DEVICE_ID_INTEL_E7520_MCH	0x3590
 #define PCI_DEVICE_ID_INTEL_E7320_MCH	0x3592
+#define PCI_DEVICE_ID_INTEL_MCH_PA	0x3595
+#define PCI_DEVICE_ID_INTEL_MCH_PA1	0x3596
+#define PCI_DEVICE_ID_INTEL_MCH_PB	0x3597
+#define PCI_DEVICE_ID_INTEL_MCH_PB1	0x3598
+#define PCI_DEVICE_ID_INTEL_MCH_PC	0x3599
+#define PCI_DEVICE_ID_INTEL_MCH_PC1	0x359a
 #define PCI_DEVICE_ID_INTEL_E7525_MCH	0x359e
 #define PCI_DEVICE_ID_INTEL_80310	0x530d
 #define PCI_DEVICE_ID_INTEL_82371SB_0	0x7000
author
#14 lore raw

ChangeSet 1.2026.66.16, 2004/11/05 15:06:26-08:00, [email protected]

[PATCH] PCI: add PCI ROMs to sysfs

Linus has requested that the sysfs rom attribute be changed to require enabling before it works. echo "0" to the attribute to disable, echoing anything else enables the rom output. The concern is that something like a file browser could inadvertently read the attribute and change the state of the hardware without the user's knowledge.

The attached patch includes the previous patch plus the enabling logic.

[root@smirl 0000:02:02.0]#
[root@smirl 0000:02:02.0]# cat rom
cat: rom: Invalid argument
[root@smirl 0000:02:02.0]# echo "1" >rom
[root@smirl 0000:02:02.0]# hexdump -C -n 20 rom

00000000  55 aa 60 e9 d6 01 00 00  00 00 00 00 00 00 00 00  |U.`.............|
00000010  00 00 00 00                                       |....|

00000014
[root@smirl 0000:02:02.0]# echo "0" >rom
[root@smirl 0000:02:02.0]# hexdump -C -n 20 rom
hexdump: rom: Invalid argument
[root@smirl 0000:02:02.0]#

 arch/i386/pci/fixup.c   |   38 ++++++++
 drivers/pci/Makefile    |    3 
 drivers/pci/pci-sysfs.c |  120 +++++++++++++++++++++++++
 drivers/pci/pci.h       |    4 
 drivers/pci/probe.c     |    2 
 drivers/pci/remove.c    |    2 
 drivers/pci/rom.c       |  225 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/setup-res.c |    2 
 include/linux/ioport.h  |    5 +
 include/linux/pci.h     |    8 +
 10 files changed, 404 insertions(+), 5 deletions(-)
arch/i386/pci/fixup.c +38 -0
diff -Nru a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
@@ -346,3 +346,41 @@
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PC,	pcie_rootport_aspm_quirk );
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_MCH_PC1,	pcie_rootport_aspm_quirk );
 
+/*
+ * Fixup to mark boot BIOS video selected by BIOS before it changes
+ *
+ * From information provided by "Jon Smirl" <[email protected]>
+ *
+ * The standard boot ROM sequence for an x86 machine uses the BIOS
+ * to select an initial video card for boot display. This boot video 
+ * card will have it's BIOS copied to C0000 in system RAM. 
+ * IORESOURCE_ROM_SHADOW is used to associate the boot video
+ * card with this copy. On laptops this copy has to be used since
+ * the main ROM may be compressed or combined with another image.
+ * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW
+ * is marked here since the boot video device will be the only enabled
+ * video device at this point.
+ *
+ */static void __devinit pci_fixup_video(struct pci_dev *pdev)
+{
+	struct pci_dev *bridge;
+	struct pci_bus *bus;
+	u16 l;
+
+	if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
+		return;
+
+	/* Is VGA routed to us? */
+	bus = pdev->bus;
+	while (bus) {
+		bridge = bus->self;
+		if (bridge) {
+			pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &l);
+			if (!(l & PCI_BRIDGE_CTL_VGA))
+				return;
+		}
+		bus = bus->parent;
+	}
+	pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
drivers/pci/Makefile +2 -1
diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile
@@ -3,7 +3,8 @@
 #
 
 obj-y		+= access.o bus.o probe.o remove.o pci.o quirks.o \
-			names.o pci-driver.o search.o pci-sysfs.o
+			names.o pci-driver.o search.o pci-sysfs.o \
+			rom.o
 obj-$(CONFIG_PROC_FS) += proc.o
 
 ifndef CONFIG_SPARC64
drivers/pci/pci-sysfs.c +119 -1

150 lines not on this page · raw message

drivers/pci/pci.h +3 -1
diff -Nru a/drivers/pci/pci.h b/drivers/pci/pci.h
@@ -2,7 +2,9 @@
 
 extern int pci_hotplug (struct device *dev, char **envp, int num_envp,
 			 char *buffer, int buffer_size);
-extern void pci_create_sysfs_dev_files(struct pci_dev *pdev);
+extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
+extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
+extern void pci_cleanup_rom(struct pci_dev *dev);
 extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
 				  unsigned long size, unsigned long align,
 				  unsigned long min, unsigned int type_mask,
drivers/pci/probe.c +1 -1
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
@@ -170,7 +170,7 @@
 		if (sz && sz != 0xffffffff) {
 			sz = pci_size(l, sz, PCI_ROM_ADDRESS_MASK);
 			if (sz) {
-				res->flags = (l & PCI_ROM_ADDRESS_ENABLE) |
+				res->flags = (l & IORESOURCE_ROM_ENABLE) |
 				  IORESOURCE_MEM | IORESOURCE_PREFETCH |
 				  IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
 				res->start = l & PCI_ROM_ADDRESS_MASK;
drivers/pci/remove.c +2 -0
diff -Nru a/drivers/pci/remove.c b/drivers/pci/remove.c
@@ -16,6 +16,7 @@
 
  	msi_remove_pci_irq_vectors(dev);
 
+	pci_cleanup_rom(dev);
 	for (i = 0; i < PCI_NUM_RESOURCES; i++) {
 		struct resource *res = dev->resource + i;
 		if (res->parent)
@@ -26,6 +27,7 @@
 static void pci_destroy_dev(struct pci_dev *dev)
 {
 	pci_proc_detach_device(dev);
+	pci_remove_sysfs_dev_files(dev);
 	device_unregister(&dev->dev);
 
 	/* Remove the device from the device lists, and prevent any further
drivers/pci/rom.c new file +225 -0

225 lines not on this page · raw message

drivers/pci/setup-res.c +1 -1
diff -Nru a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
@@ -56,7 +56,7 @@
 	if (resno < 6) {
 		reg = PCI_BASE_ADDRESS_0 + 4 * resno;
 	} else if (resno == PCI_ROM_RESOURCE) {
-		new |= res->flags & PCI_ROM_ADDRESS_ENABLE;
+		new |= res->flags & IORESOURCE_ROM_ENABLE;
 		reg = dev->rom_base_reg;
 	} else {
 		/* Hmm, non-standard resource. */
include/linux/ioport.h +5 -0
diff -Nru a/include/linux/ioport.h b/include/linux/ioport.h
@@ -82,6 +82,11 @@
 #define IORESOURCE_MEM_SHADOWABLE	(1<<5)	/* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM	(1<<6)
 
+/* PCI ROM control bits (IORESOURCE_BITS) */
+#define IORESOURCE_ROM_ENABLE		(1<<0)	/* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
+#define IORESOURCE_ROM_SHADOW		(1<<1)	/* ROM is copy at C000:0 */
+#define IORESOURCE_ROM_COPY		(1<<2)	/* ROM is alloc'd copy, resource field overlaid */
+
 /* PC/ISA/whatever - the normal PC address spaces: IO and memory */
 extern struct resource ioport_resource;
 extern struct resource iomem_resource;
include/linux/pci.h +8 -0
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -537,6 +537,8 @@
 	unsigned int	is_busmaster:1; /* device is busmaster */
 	
 	u32		saved_config_space[16]; /* config space saved at suspend time */
+	struct bin_attribute *rom_attr; /* attribute descriptor for sysfs ROM entry */
+	int rom_attr_enabled;		/* has display of the rom attribute been enabled? */
 #ifdef CONFIG_PCI_NAMES
 #define PCI_NAME_SIZE	96
 #define PCI_NAME_HALF	__stringify(43)	/* less than half to handle slop */
@@ -784,6 +786,12 @@
 int pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask);
 int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
 int pci_assign_resource(struct pci_dev *dev, int i);
+
+/* ROM control related routines */
+void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size);
+void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size);
+void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
+void pci_remove_rom(struct pci_dev *pdev);
 
 /* Power management related routines */
 int pci_save_state(struct pci_dev *dev);
author
#15 lore raw

ChangeSet 1.2026.66.17, 2004/11/05 15:06:47-08:00, [email protected]

[PATCH] cyclades.c: replace pci_find_device

As pci_find_device is going away I've replaced it with pci_get_device. If someone with this hardware could test it I would appreciate it.

 drivers/char/cyclades.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/char/cyclades.c +1 -1
diff -Nru a/drivers/char/cyclades.c b/drivers/char/cyclades.c
@@ -4725,7 +4725,7 @@
         for (i = 0; i < NR_CARDS; i++) {
                 /* look for a Cyclades card by vendor and device id */
                 while((device_id = cy_pci_dev_id[dev_index]) != 0) {
-                        if((pdev = pci_find_device(PCI_VENDOR_ID_CYCLADES,
+                        if((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
                                         device_id, pdev)) == NULL) {
                                 dev_index++;    /* try next device id */
                         } else {
author
#16 lore raw

ChangeSet 1.2026.66.18, 2004/11/10 16:43:46-08:00, [email protected]

[PATCH] PCI: pci-mmconfig fix

Here I have attached pci mmconfig fix for 2.6.9 kernel.

This will fix the flush error in pci_mmcfg_write.

When pci_mmcfg_write is used to program the PMCSR in the Power Management Capability structure of PCI config space in the PCI Express device to a different power state, the dummy readl to flush the previous write violates the transition delay specified in the PCI power management spec. Please see PCI Power Management Spec. 1.2 Table 5-6. For example, while changing the power state of the device through PMCSR register, a transition delay of 10msec is required before any access can be made to the device.

Since the configuration write access for PCI Express is non posted, flushing is not necessary and it will be safe to remove the dummy readl.

This patch will remove dummy readl function implemented in "pci_mmcfg_write" and use set_fixmap_nocahe instead of set_fixmap.

 arch/i386/pci/mmconfig.c   |    5 +----
 arch/x86_64/pci/mmconfig.c |    3 ---
 2 files changed, 1 insertion(+), 7 deletions(-)
arch/i386/pci/mmconfig.c +1 -4
diff -Nru a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
@@ -30,7 +30,7 @@
 	u32 dev_base = pci_mmcfg_base_addr | (bus << 20) | (devfn << 12);
 	if (dev_base != mmcfg_last_accessed_device) {
 		mmcfg_last_accessed_device = dev_base;
-		set_fixmap(FIX_PCIE_MCFG, dev_base);
+		set_fixmap_nocache(FIX_PCIE_MCFG, dev_base);
 	}
 }
 
@@ -84,9 +84,6 @@
 		writel(value, mmcfg_virt_addr + reg);
 		break;
 	}
-
-	/* Dummy read to flush PCI write */
-	readl(mmcfg_virt_addr);
 
 	spin_unlock_irqrestore(&pci_config_lock, flags);
 
arch/x86_64/pci/mmconfig.c +0 -3
diff -Nru a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
@@ -63,9 +63,6 @@
 		break;
 	}
 
-	/* Dummy read to flush PCI write */
-	readl(addr);
-
 	return 0;
 }
 
author
#17 lore raw

ChangeSet 1.2026.66.19, 2004/11/10 16:44:13-08:00, [email protected]

[PATCH] zr36120.c: Convert pci_find_device to pci_dev_present

Quoted 9 lines · --On Thursday, September 30, 2004 10:27:48 AM +0200 Gerd Knorr…
Quoted 2 lines

The whole driver is CONFIG_BROKEN anyway... I only verified my changes didn't add new compiler errors. What part should I remove? Just this check?

pci/quirks.c does these checks and sets the flags.
Replacing with a check for "pci_pci_problems & PCIPCI_TRITON" should do.

bttv does simliar things in bttv_check_chipset() (bttv-cards.c), you might want to have a look there ...

Thanks a lot for your help. Is this what you were thinking?

 drivers/media/video/zr36120.c |    5 +----
 1 files changed, 1 insertion(+), 4 deletions(-)
drivers/media/video/zr36120.c +1 -4
diff -Nru a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
@@ -145,14 +145,11 @@
 static
 void __init handle_chipset(void)
 {
-	struct pci_dev *dev = NULL;
-
 	/* Just in case some nut set this to something dangerous */
 	if (triton1)
 		triton1 = ZORAN_VDC_TRICOM;
 
-	while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, dev)))
-	{
+	if (pci_pci_problems & PCIPCI_TRITON) {
 		printk(KERN_INFO "zoran: Host bridge 82437FX Triton PIIX\n");
 		triton1 = ZORAN_VDC_TRICOM;
 	}
author
#18 lore raw

ChangeSet 1.2026.66.20, 2004/11/10 16:44:40-08:00, [email protected]

[PATCH] ide.c: replace pci_find_device with pci_dev_present

As pci_find_device is going away it needs to be replaced. In this case the dev returned from pci_find_device was not being used so pci_dev_present was the appropriate replacement.

This has been compile and boot tested on a T22.

 drivers/ide/ide.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletion(-)
drivers/ide/ide.c +6 -1
diff -Nru a/drivers/ide/ide.c b/drivers/ide/ide.c
@@ -335,11 +335,16 @@
 
 int ide_system_bus_speed (void)
 {
+	static struct pci_device_id pci_default[] = {
+		{ PCI_DEVICE(PCI_ANY_ID, PCI_ANY_ID) },
+		{ }
+	};
+
 	if (!system_bus_speed) {
 		if (idebus_parameter) {
 			/* user supplied value */
 			system_bus_speed = idebus_parameter;
-		} else if (pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL) != NULL) {
+		} else if (pci_dev_present(pci_default)) {
 			/* safe default value for PCI */
 			system_bus_speed = 33;
 		} else {
author
#19 lore raw

ChangeSet 1.2026.66.21, 2004/11/10 16:45:21-08:00, [email protected]

[PATCH] scx200_wdt.c: replace pci_find_device with pci_dev_present

Patch to replace the soon to be defunct pci_find_device with the new function pci_dev_present. I found 8 .c files (outside of /drivers/net) that used pci_find_device without the dev it returned. therefore it was replaceable with the new function.

 drivers/char/watchdog/scx200_wdt.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/char/watchdog/scx200_wdt.c +6 -6
diff -Nru a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c
@@ -217,6 +217,11 @@
 static int __init scx200_wdt_init(void)
 {
 	int r;
+	static struct pci_device_id ns_sc[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
+		{ PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
+		{ },
+	};
 
 	printk(KERN_DEBUG NAME ": NatSemi SCx200 Watchdog Driver\n");
 
@@ -224,12 +229,7 @@
 	 * First check that this really is a NatSemi SCx200 CPU or a Geode
 	 * SC1100 processor
 	 */
-	if ((pci_find_device(PCI_VENDOR_ID_NS,
-			     PCI_DEVICE_ID_NS_SCx200_BRIDGE,
-			     NULL)) == NULL
-	    && (pci_find_device(PCI_VENDOR_ID_NS,
-				PCI_DEVICE_ID_NS_SC1100_BRIDGE,
-				NULL)) == NULL)
+	if (!pci_dev_present(ns_sc))
 		return -ENODEV;
 
 	/* More sanity checks, verify that the configuration block is there */
author
#20 lore raw

ChangeSet 1.2026.66.22, 2004/11/10 17:38:03-08:00, [email protected]

[PATCH] ibmphp_core.c: replace pci_get_device with pci_dev_present

This can be converted to pci_dev_present as the dev returned is never used. Compile tested.

 drivers/pci/hotplug/ibmphp_core.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/pci/hotplug/ibmphp_core.c +5 -3
diff -Nru a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
@@ -838,8 +838,11 @@
 	int rc;
 	u8 speed;
 	u8 cmd = 0x0;
-	struct pci_dev *dev = NULL;
 	int retval;
+	static struct pci_device_id ciobx[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, 0x0101) },
+	        { },
+	};	
 
 	debug ("%s - entry slot # %d\n", __FUNCTION__, slot_cur->number);
 	if (SET_BUS_STATUS (slot_cur->ctrl) && is_bus_empty (slot_cur)) {
@@ -886,8 +889,7 @@
 				break;
 			case BUS_SPEED_133:
 				/* This is to take care of the bug in CIOBX chip */
-				while ((dev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS,
-							      0x0101, dev)) != NULL)
+				if (pci_dev_present(ciobx))
 					ibmphp_hpc_writeslot (slot_cur, HPC_BUS_100PCIXMODE);
 				cmd = HPC_BUS_133PCIXMODE;
 				break;
author
#21 lore raw

ChangeSet 1.2026.66.23, 2004/11/11 15:40:24-08:00, [email protected]

PCI Hotplug: fix up remaining MODULE_PARAM usage in pci hotplug drivers

 drivers/pci/hotplug/cpcihp_generic.c |   14 +++++++-------
 drivers/pci/hotplug/fakephp.c        |    2 +-
 drivers/pci/hotplug/ibmphp_core.c    |    2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/pci/hotplug/cpcihp_generic.c +7 -7
diff -Nru a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
@@ -63,7 +63,7 @@
 
 /* local variables */
 static int debug;
-static char* bridge;
+static char bridge[256];
 static u8 bridge_busnr;
 static u8 bridge_slot;
 static struct pci_bus *bus;
@@ -209,15 +209,15 @@
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
-MODULE_PARM(bridge, "s");
+module_param_string(bridge, bridge, 256, 0);
 MODULE_PARM_DESC(bridge, "Hotswap bus bridge device, <bus>:<slot> (bus and slot are in hexadecimal)");
-MODULE_PARM(first_slot, "b");
+module_param(first_slot, byte, 0);
 MODULE_PARM_DESC(first_slot, "Hotswap bus first slot number");
-MODULE_PARM(last_slot, "b");
+module_param(last_slot, byte, 0);
 MODULE_PARM_DESC(last_slot, "Hotswap bus last slot number");
-MODULE_PARM(port, "h");
+module_param(port, ushort, 0);
 MODULE_PARM_DESC(port, "#ENUM signal I/O port");
-MODULE_PARM(enum_bit, "i");
+module_param(enum_bit, int, 0);
 MODULE_PARM_DESC(enum_bit, "#ENUM signal bit (0-7)");
drivers/pci/hotplug/fakephp.c +1 -1
diff -Nru a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
@@ -227,6 +227,6 @@
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
 
drivers/pci/hotplug/ibmphp_core.c +1 -1
diff -Nru a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
@@ -51,7 +51,7 @@
 int ibmphp_debug;
 
 static int debug;
-MODULE_PARM (debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC (debug, "Debugging mode enabled or not");
 MODULE_LICENSE ("GPL");
 MODULE_DESCRIPTION (DRIVER_DESC);
author
#22 lore raw

ChangeSet 1.2091.1.2, 2004/11/11 16:32:25-08:00, [email protected]

[PATCH] fakephp: introduce pci_bus_add_device

fakephp needs to add newly discovered devices to the global pci list. Therefore seperate out the appropriate chunk from pci_bus_add_devices to pci_bus_add_device to add a single device to sysfs, procfs and the global device list.

 drivers/pci/bus.c   |   31 +++++++++++++++++++++----------
 include/linux/pci.h |    1 +
 2 files changed, 22 insertions(+), 10 deletions(-)
drivers/pci/bus.c +21 -10
diff -Nru a/drivers/pci/bus.c b/drivers/pci/bus.c
@@ -69,6 +69,25 @@
 }
 
 /**
+ * add a single device
+ * @dev: device to add
+ *
+ * This adds a single pci device to the global
+ * device list and adds sysfs and procfs entries
+ */
+void __devinit pci_bus_add_device(struct pci_dev *dev)
+{
+	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);
+}
+
+/**
  * pci_bus_add_devices - insert newly discovered PCI devices
  * @bus: bus to check for new devices
  *
@@ -91,16 +110,7 @@
 		 */
 		if (!list_empty(&dev->global_list))
 			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);
-
+		pci_bus_add_device(dev);
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -136,5 +146,6 @@
 }
 
 EXPORT_SYMBOL(pci_bus_alloc_resource);
+EXPORT_SYMBOL_GPL(pci_bus_add_device);
 EXPORT_SYMBOL(pci_bus_add_devices);
 EXPORT_SYMBOL(pci_enable_bridges);
include/linux/pci.h +1 -0
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -715,6 +715,7 @@
 int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
+void pci_bus_add_device(struct pci_dev *dev);
 void pci_bus_add_devices(struct pci_bus *bus);
 void pci_name_device(struct pci_dev *dev);
 char *pci_class_name(u32 class);
author
#23 lore raw

ChangeSet 1.2091.1.3, 2004/11/11 16:33:31-08:00, [email protected]

[PATCH] fakephp: add pci bus rescan ability

This adds the ability to rescan the pci bus for newly inserted, reprogrammed or previously disabled pci devices.
To initiate a rescan you need to write '1' to any of the /sys/bus/pci/slots/*/power control files. No known pci devices will be touched.
Additionally this fixes a bug, when someone tries to disable a device with subfunctions. The subfunctions will be disabled first now.

Short demo:

 # modprobe fakephp
 # ls /sys/bus/pci/slots | grep "0000:04"
0000:04:02.0
0000:04:02.1
0000:04:02.2
0000:04:03.0
0000:04:03.1
 # echo -n 0 > /sys/bus/pci/slots/0000\:04\:02.0/power
 # ls /sys/bus/pci/slots | grep "0000:04"
0000:04:03.0
0000:04:03.1
 # echo -n 1 > /sys/bus/pci/slots/0000\:03\:01.0/power
 # ls /sys/bus/pci/slots | grep "0000:04"
0000:04:02.0
0000:04:02.1
0000:04:02.2
0000:04:03.0
0000:04:03.1
 # lspci | grep "0000:04"
0000:04:02.0 Multimedia audio controller: Creative Labs SB Audigy (rev 03)
0000:04:02.1 Input device controller: Creative Labs SB Audigy MIDI/Gameport (rev 03)
0000:04:02.2 FireWire (IEEE 1394): Creative Labs SB Audigy FireWire Port
0000:04:03.0 SCSI storage controller: Adaptec AHA-3960D / AIC-7899A U160/m (rev 01)
0000:04:03.1 SCSI storage controller: Adaptec AHA-3960D / AIC-7899A U160/m (rev 01)
 drivers/pci/hotplug/fakephp.c |  126 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 126 insertions(+)
drivers/pci/hotplug/fakephp.c +126 -0
diff -Nru a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
@@ -165,14 +165,123 @@
 		err("Problem unregistering a slot %s\n", dslot->slot->name);
 }
 
+/**
+ * Rescan slot.
+ * Tries hard not to re-enable already existing devices
+ * also handles scanning of subfunctions
+ *
+ * @param temp   Device template. Should be set: bus and devfn.
+ */
+static void pci_rescan_slot(struct pci_dev *temp)
+{
+	struct pci_bus *bus = temp->bus;
+	struct pci_dev *dev;
+	int func;
+	u8 hdr_type;
+	if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) {
+		temp->hdr_type = hdr_type & 0x7f;
+		if (!pci_find_slot(bus->number, temp->devfn)) {
+			dev = pci_scan_single_device(bus, temp->devfn);
+			if (dev) {
+				dbg("New device on %s function %x:%x\n",
+					bus->name, temp->devfn >> 3,
+					temp->devfn & 7);
+				pci_bus_add_device(dev);
+				add_slot(dev);
+			}
+		}
+		/* multifunction device? */
+		if (!(hdr_type & 0x80))
+			return;
+
+		/* continue scanning for other functions */
+		for (func = 1, temp->devfn++; func < 8; func++, temp->devfn++) {
+			if (pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type))
+				continue;
+			temp->hdr_type = hdr_type & 0x7f;
+
+			if (!pci_find_slot(bus->number, temp->devfn)) {
+				dev = pci_scan_single_device(bus, temp->devfn);
+				if (dev) {
+					dbg("New device on %s function %x:%x\n",
+						bus->name, temp->devfn >> 3,
+						temp->devfn & 7);
+					pci_bus_add_device(dev);
+					add_slot(dev);
+				}
+			}
+		}
+	}
+}
+
+
+/**
+ * Rescan PCI bus.
+ * call pci_rescan_slot for each possible function of the bus
+ *
+ * @param bus
+ */
+static void pci_rescan_bus(const struct pci_bus *bus)
+{
+	unsigned int devfn;
+	struct pci_dev *dev;
+	dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+	if (!dev)
+		return;
+
+	memset(dev, 0, sizeof(dev));
+	dev->bus = (struct pci_bus*)bus;
+	dev->sysdata = bus->sysdata;
+	for (devfn = 0; devfn < 0x100; devfn += 8) {
+		dev->devfn = devfn;
+		pci_rescan_slot(dev);
+	}
+	kfree(dev);
+}
+
+/* recursively scan all buses */
+static void pci_rescan_buses(const struct list_head *list)
+{
+	const struct list_head *l;
+	list_for_each(l,list) {
+		const struct pci_bus *b = pci_bus_b(l);
+		pci_rescan_bus(b);
+		pci_rescan_buses(&b->children);
+	}
+}
+
+/* initiate rescan of all pci buses */
+static inline void pci_rescan(void) {
+	pci_rescan_buses(&pci_root_buses);
+}
+
+
 static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
+	/* mis-use enable_slot for rescanning of the pci bus */
+	pci_rescan();
 	return -ENODEV;
 }
 
+/* find the hotplug_slot for the pci_dev */
+static struct hotplug_slot *get_slot_from_dev(struct pci_dev *dev)
+{
+	struct dummy_slot *dslot;
+
+	list_for_each_entry(dslot, &slot_list, node) {
+		if (dslot->dev == dev)
+			return dslot->slot;
+	}
+	return NULL;
+}
+
+
 static int disable_slot(struct hotplug_slot *slot)
 {
 	struct dummy_slot *dslot;
+	struct hotplug_slot *hslot;
+	struct pci_dev *dev;
+	int func;
 
 	if (!slot)
 		return -ENODEV;
@@ -184,6 +293,23 @@
 	if (dslot->dev->subordinate) {
 		err("Can't remove PCI devices with other PCI devices behind it yet.\n");
 		return -ENODEV;
+	}
+	/* search for subfunctions and disable them first */
+	if (!(dslot->dev->devfn & 7)) {
+		for (func = 1; func < 8; func++) {
+			dev = pci_find_slot(dslot->dev->bus->number,
+					dslot->dev->devfn + func);
+			if (dev) {
+				hslot = get_slot_from_dev(dev);
+				if (hslot)
+					disable_slot(hslot);
+				else {
+					err("Hotplug slot not found for subfunction of PCI device\n");
+					return -ENODEV;
+				}
+			} else
+				dbg("No device in slot found\n");
+		}
 	}
 
 	/* remove the device from the pci core */
author
#24 lore raw

ChangeSet 1.2091.1.4, 2004/11/12 14:01:32-08:00, [email protected]

[PATCH] PCI: small PCI probe patch for odd 64 bit BARs

Quoted 1 line · Greg KH

I'll wait till you test this on 2.6 before applying it.

OK. Tested now on real hardware in 32 bit and 64 bit kernels. 32 bit found another dumbness, that we can fix up.

Some PCI bridges default their UPPER prefetch windows to an unused state of base > limit. We should not use those values if we find that. It might be nice to reprogram them to 0, in fact.

Yes, BIOS should fix that up, but apparently, some do not.

 drivers/pci/probe.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)
drivers/pci/probe.c +19 -9
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
@@ -144,9 +144,11 @@
 			pci_write_config_dword(dev, reg+4, ~0);
 			pci_read_config_dword(dev, reg+4, &sz);
 			pci_write_config_dword(dev, reg+4, l);
-			if (~sz)
-				res->end = res->start + 0xffffffff +
-						(((unsigned long) ~sz) << 32);
+			sz = pci_size(l, sz, 0xffffffff);
+			if (sz) {
+				/* This BAR needs > 4GB?  Wow. */
+				res->end |= (unsigned long)sz<<32;
+			}
 #else
 			if (l) {
 				printk(KERN_ERR "PCI: Unable to handle 64-bit address for device %s\n", pci_name(dev));
@@ -243,15 +245,23 @@
 		u32 mem_base_hi, mem_limit_hi;
 		pci_read_config_dword(dev, PCI_PREF_BASE_UPPER32, &mem_base_hi);
 		pci_read_config_dword(dev, PCI_PREF_LIMIT_UPPER32, &mem_limit_hi);
+
+		/*
+		 * Some bridges set the base > limit by default, and some
+		 * (broken) BIOSes do not initialize them.  If we find
+		 * this, just assume they are not being used.
+		 */
+		if (mem_base_hi <= mem_limit_hi) {
 #if BITS_PER_LONG == 64
-		base |= ((long) mem_base_hi) << 32;
-		limit |= ((long) mem_limit_hi) << 32;
+			base |= ((long) mem_base_hi) << 32;
+			limit |= ((long) mem_limit_hi) << 32;
 #else
-		if (mem_base_hi || mem_limit_hi) {
-			printk(KERN_ERR "PCI: Unable to handle 64-bit address space for %s\n", child->name);
-			return;
-		}
+			if (mem_base_hi || mem_limit_hi) {
+				printk(KERN_ERR "PCI: Unable to handle 64-bit address space for bridge %s\n", pci_name(dev));
+				return;
+			}
 #endif
+		}
 	}
 	if (base <= limit) {
 		res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM | IORESOURCE_PREFETCH;
author
#25 lore raw

ChangeSet 1.2091.1.5, 2004/11/12 14:01:55-08:00, [email protected]

[PATCH] chrp_pci.c: replace pci_find_device with for_each_pci_dev

 arch/ppc/platforms/chrp_pci.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/ppc/platforms/chrp_pci.c +1 -1
diff -Nru a/arch/ppc/platforms/chrp_pci.c b/arch/ppc/platforms/chrp_pci.c
@@ -158,7 +158,7 @@
 	struct device_node *np;
 
 	/* PCI interrupts are controlled by the OpenPIC */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		np = pci_device_to_OF_node(dev);
 		if ((np != 0) && (np->n_intrs > 0) && (np->intrs[0].line != 0))
 			dev->irq = np->intrs[0].line;
author
#26 lore raw

ChangeSet 1.2091.1.6, 2004/11/12 14:02:20-08:00, [email protected]

[PATCH] gemini_pci.c: replace pci_find_device with for_each_pci_dev

 arch/ppc/platforms/gemini_pci.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/ppc/platforms/gemini_pci.c +1 -1
diff -Nru a/arch/ppc/platforms/gemini_pci.c b/arch/ppc/platforms/gemini_pci.c
@@ -15,7 +15,7 @@
 	int i;
 	struct pci_dev *dev = NULL;
 	
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		for(i = 0; i < 6; i++) {
 			if (dev->resource[i].flags & IORESOURCE_IO) {
 				dev->resource[i].start |= (0xfe << 24);
author
#27 lore raw

ChangeSet 1.2091.1.7, 2004/11/12 14:03:20-08:00, [email protected]

[PATCH] matroxfb_base.c: convert pci_find_device to pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 drivers/video/matrox/matroxfb_base.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletion(-)
drivers/video/matrox/matroxfb_base.c +6 -1
diff -Nru a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
@@ -1580,6 +1580,11 @@
 	unsigned int memsize;
 	int err;
 
+	static struct pci_device_id intel_82437[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437) },
+		{ },
+	};
+
 	DBG(__FUNCTION__)
 
 	/* set default values... */
@@ -1684,7 +1689,7 @@
 		mga_option |= MX_OPTION_BSWAP;
                 /* disable palette snooping */
                 cmd &= ~PCI_COMMAND_VGA_PALETTE;
-		if (pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, NULL)) {
+		if (pci_dev_present(intel_82437)) {
 			if (!(mga_option & 0x20000000) && !ACCESS_FBINFO(devflags.nopciretry)) {
 				printk(KERN_WARNING "matroxfb: Disabling PCI retries due to i82437 present\n");
 			}
author
#28 lore raw

ChangeSet 1.2091.1.8, 2004/11/12 14:04:45-08:00, [email protected]

[PATCH] lopec.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I have replaced this call with pci_get_device.

 arch/ppc/platforms/lopec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/ppc/platforms/lopec.c +2 -1
diff -Nru a/arch/ppc/platforms/lopec.c b/arch/ppc/platforms/lopec.c
@@ -189,7 +189,7 @@
 static void
 lopec_ide_probe(void)
 {
-	struct pci_dev *dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	struct pci_dev *dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 					      PCI_DEVICE_ID_WINBOND_82C105,
 					      NULL);
 	lopec_ide_ports_known = 1;
@@ -200,6 +200,7 @@
 		lopec_ide_ctl_regbase[0] = dev->resource[1].start;
 		lopec_ide_ctl_regbase[1] = dev->resource[3].start;
 		lopec_idedma_regbase = dev->resource[4].start;
+		pci_dev_put(dev);
 	}
 }
 
author
#29 lore raw

ChangeSet 1.2091.1.9, 2004/11/12 14:06:23-08:00, [email protected]

[PATCH] k2.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I have replaced this call with pci_get_device.

 arch/ppc/platforms/k2.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/ppc/platforms/k2.c +2 -1
diff -Nru a/arch/ppc/platforms/k2.c b/arch/ppc/platforms/k2.c
@@ -116,7 +116,7 @@
 	/*
 	 * Enable DMA support on hdc
 	 */
-	ide_dev = pci_find_device(PCI_VENDOR_ID_AL,
+	ide_dev = pci_get_device(PCI_VENDOR_ID_AL,
 				  PCI_DEVICE_ID_AL_M5229, NULL);
 
 	if (ide_dev) {
@@ -126,6 +126,7 @@
 		ide_dma_base = pci_resource_start(ide_dev, 4);
 		outb(0x00, ide_dma_base + 0x2);
 		outb(0x20, ide_dma_base + 0xa);
+		pci_dev_put(ide_dev);
 	}
 #endif
 }
author
#30 lore raw

ChangeSet 1.2091.1.10, 2004/11/12 14:07:13-08:00, [email protected]

[PATCH] cmipci.c: convert pci_find_device to pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 sound/pci/cmipci.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
sound/pci/cmipci.c +5 -2
diff -Nru a/sound/pci/cmipci.c b/sound/pci/cmipci.c
@@ -2572,6 +2572,10 @@
 	long iomidi = mpu_port[dev];
 	long iosynth = fm_port[dev];
 	int pcm_index, pcm_spdif_index;
+	static struct pci_device_id intel_82437vx[] = {
+		{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX) },
+		{ },
+	};
 
 	*rcmipci = NULL;
 
@@ -2647,8 +2651,7 @@
 	switch (pci->device) {
 	case PCI_DEVICE_ID_CMEDIA_CM8738:
 	case PCI_DEVICE_ID_CMEDIA_CM8738B:
-		/* PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX */
-		if (! pci_find_device(0x8086, 0x7030, NULL))
+		if (!pci_dev_present(intel_82437vx)) 
 			snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_TXVX);
 		break;
 	default:
author
#31 lore raw

ChangeSet 1.2091.1.11, 2004/11/12 14:07:33-08:00, [email protected]

[PATCH] drm_drv.h: replace pci_find_device

As pci_find_device is going away I've replaced it with pci_get_device. for_each_pci_dev is a macro wrapper around pci_get_device.

 drivers/char/drm/drm_drv.h |    3 +--
 1 files changed, 1 insertion(+), 2 deletions(-)
drivers/char/drm/drm_drv.h +1 -2
diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
@@ -556,9 +556,8 @@
 
 	DRM(mem_init)();
 
-	while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) {
+	for_each_pci_dev(pdev) 
 		DRM(probe)(pdev);
-	}
 	return 0;
 }
 
author
#32 lore raw

ChangeSet 1.2091.1.12, 2004/11/12 14:07:54-08:00, [email protected]

[PATCH] sis-agp.c: replace pci_find_device with pci_get_device

As pci_find_device is going away soon I have converted this file to use pci_get_device instead. for_each_pci_dev is a macro wrapper around pci_get_device.

 drivers/char/agp/sis-agp.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/char/agp/sis-agp.c +1 -1
diff -Nru a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
@@ -86,7 +86,7 @@
 	command |= AGPSTAT_AGP_ENABLE;
 	rate = (command & 0x7) << 2;
 
-	while ((device = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, device)) != NULL) {
+	for_each_pci_dev(device) {
 		u8 agp = pci_find_capability(device, PCI_CAP_ID_AGP);
 		if (!agp)
 			continue;
author
#33 lore raw

ChangeSet 1.2091.1.13, 2004/11/12 14:08:14-08:00, [email protected]

[PATCH] pci-gart.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/x86_64/kernel/pci-gart.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/x86_64/kernel/pci-gart.c +1 -1
diff -Nru a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
@@ -81,7 +81,7 @@
 
 #define for_all_nb(dev) \
 	dev = NULL;	\
-	while ((dev = pci_find_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)\
+	while ((dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1103, dev))!=NULL)\
 	     if (dev->bus->number == 0 && 				     \
 		    (PCI_SLOT(dev->devfn) >= 24) && (PCI_SLOT(dev->devfn) <= 31))
 
author
#34 lore raw

ChangeSet 1.2091.1.14, 2004/11/12 14:08:40-08:00, [email protected]

[PATCH] ret_mb_a_pci.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/v850/kernel/rte_mb_a_pci.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/v850/kernel/rte_mb_a_pci.c +1 -1
diff -Nru a/arch/v850/kernel/rte_mb_a_pci.c b/arch/v850/kernel/rte_mb_a_pci.c
@@ -254,7 +254,7 @@
 	struct pci_dev *dev = NULL;
 	struct resource *r;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		unsigned di_num;
 		unsigned class = dev->class >> 8;
 
author
#35 lore raw

ChangeSet 1.2091.1.15, 2004/11/12 14:09:00-08:00, [email protected]

[PATCH] pci_iommu.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/sparc64/kernel/pci_iommu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/sparc64/kernel/pci_iommu.c +2 -1
diff -Nru a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
@@ -814,7 +814,7 @@
 	/* ALI sound chips generate 31-bits of DMA, a special register
 	 * determines what bit 31 is emitted as.
 	 */
-	ali_isa_bridge = pci_find_device(PCI_VENDOR_ID_AL,
+	ali_isa_bridge = pci_get_device(PCI_VENDOR_ID_AL,
 					 PCI_DEVICE_ID_AL_M1533,
 					 NULL);
 
@@ -824,6 +824,7 @@
 	else
 		val &= ~0x01;
 	pci_write_config_byte(ali_isa_bridge, 0x7e, val);
+	pci_dev_put(ali_isa_bridge);
 }
 
 int pci_dma_supported(struct pci_dev *pdev, u64 device_mask)
author
#36 lore raw

ChangeSet 1.2091.1.16, 2004/11/12 14:09:21-08:00, [email protected]

[PATCH] isa.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/sparc64/kernel/isa.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/sparc64/kernel/isa.c +1 -1
diff -Nru a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c
@@ -262,7 +262,7 @@
 	device = PCI_DEVICE_ID_AL_M1533;
 
 	pdev = NULL;
-	while ((pdev = pci_find_device(vendor, device, pdev)) != NULL) {
+	while ((pdev = pci_get_device(vendor, device, pdev)) != NULL) {
 		struct pcidev_cookie *pdev_cookie;
 		struct pci_pbm_info *pbm;
 		struct sparc_isa_bridge *isa_br;
author
#37 lore raw

ChangeSet 1.2091.1.17, 2004/11/12 14:09:41-08:00, [email protected]

[PATCH] ebus.c: replace pci_find_device with pci_get_device

 arch/sparc/kernel/ebus.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
arch/sparc/kernel/ebus.c +4 -2
diff -Nru a/arch/sparc/kernel/ebus.c b/arch/sparc/kernel/ebus.c
@@ -275,7 +275,7 @@
 		}
 	}
 
-	pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, 0);
+	pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, 0);
 	if (!pdev) {
 		return;
 	}
@@ -342,7 +342,7 @@
 		}
 
 	next_ebus:
-		pdev = pci_find_device(PCI_VENDOR_ID_SUN,
+		pdev = pci_get_device(PCI_VENDOR_ID_SUN,
 				       PCI_DEVICE_ID_SUN_EBUS, pdev);
 		if (!pdev)
 			break;
@@ -356,4 +356,6 @@
 		ebus->next = 0;
 		++num_ebus;
 	}
+	if (pdev)
+		pci_dev_put(pdev);
 }
author
#38 lore raw

ChangeSet 1.2091.1.18, 2004/11/12 14:10:03-08:00, [email protected]

[PATCH] fixups-dreamcast.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device and pci_dev_put.

 arch/sh/drivers/pci/fixups-dreamcast.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
arch/sh/drivers/pci/fixups-dreamcast.c +1 -1
diff -Nru a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c
@@ -62,7 +62,7 @@
 {
 	struct pci_dev *dev = 0;
 
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		/*
 		 * The interrupt routing semantics here are quite trivial.
 		 *
author
#39 lore raw

ChangeSet 1.2091.1.19, 2004/11/12 14:10:24-08:00, [email protected]

[PATCH] sandpoint.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/ppc/platforms/sandpoint.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/ppc/platforms/sandpoint.c +2 -1
diff -Nru a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
@@ -575,7 +575,7 @@
 static void
 sandpoint_ide_probe(void)
 {
-	struct pci_dev *pdev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 			PCI_DEVICE_ID_WINBOND_82C105, NULL);
 
 	if (pdev) {
@@ -584,6 +584,7 @@
 		sandpoint_ide_ctl_regbase[0]=pdev->resource[1].start;
 		sandpoint_ide_ctl_regbase[1]=pdev->resource[3].start;
 		sandpoint_idedma_regbase=pdev->resource[4].start;
+		pci_dev_put(dev);
 	}
 
 	sandpoint_ide_ports_known = 1;
author
#40 lore raw

ChangeSet 1.2091.1.20, 2004/11/12 14:10:46-08:00, [email protected]

[PATCH] prpmc750.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/ppc/platforms/prpmc750.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/ppc/platforms/prpmc750.c +2 -1
diff -Nru a/arch/ppc/platforms/prpmc750.c b/arch/ppc/platforms/prpmc750.c
@@ -109,7 +109,7 @@
 	 * resource subsystem doesn't fixup the
 	 * PCI mem resources on the CL5446.
 	 */
-	if ((dev = pci_find_device(PCI_VENDOR_ID_CIRRUS,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_CIRRUS,
 				   PCI_DEVICE_ID_CIRRUS_5446, 0))) {
 		dev->resource[0].start += PRPMC750_PCI_PHY_MEM_OFFSET;
 		dev->resource[0].end += PRPMC750_PCI_PHY_MEM_OFFSET;
@@ -121,6 +121,7 @@
 		outb(0x0f, 0x3c4);
 		/* Set proper DRAM config */
 		outb(0xdf, 0x3c5);
+		pci_dev_put(dev);
 	}
 }
 
author
#41 lore raw

ChangeSet 1.2091.1.21, 2004/11/12 14:11:07-08:00, [email protected]

[PATCH] mcpn765.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device and pci_dev_put.

 arch/ppc/platforms/mcpn765.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
arch/ppc/platforms/mcpn765.c +4 -3
diff -Nru a/arch/ppc/platforms/mcpn765.c b/arch/ppc/platforms/mcpn765.c
@@ -185,7 +185,7 @@
 	struct pci_dev	*dev;
 	u_char		c;
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_0,
 				   NULL)) == NULL) {
 		printk("No VIA ISA bridge found\n");
@@ -209,8 +209,8 @@
 	pci_write_config_dword(dev, 0x54, 0);
 	pci_write_config_byte(dev, 0x58, 0);
 
-
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	pci_dev_put(dev);
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_1,
 				   NULL)) == NULL) {
 		printk("No VIA ISA bridge found\n");
@@ -225,6 +225,7 @@
 	pci_read_config_byte(dev, 0x40, &c);
 	c |= 0x03;
 	pci_write_config_byte(dev, 0x40, c);
+	pci_dev_put(dev);
 
 	return;
 }
author
#42 lore raw

ChangeSet 1.2091.1.22, 2004/11/12 14:11:29-08:00, [email protected]

[PATCH] pcore.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device and pci_dev_put.

 arch/ppc/platforms/pcore.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/ppc/platforms/pcore.c +2 -1
diff -Nru a/arch/ppc/platforms/pcore.c b/arch/ppc/platforms/pcore.c
@@ -89,7 +89,7 @@
 {
 	struct pci_dev *dev;
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				PCI_DEVICE_ID_WINBOND_83C553,
 				0)))
 	{
@@ -108,6 +108,7 @@
 		 */
  		outb(0x00, PCORE_WINBOND_PRI_EDG_LVL);
 		outb(0x1e, PCORE_WINBOND_SEC_EDG_LVL);
+		pci_dev_put(dev);
 	}
 }
 
author
#43 lore raw

ChangeSet 1.2091.1.23, 2004/11/12 14:11:49-08:00, [email protected]

[PATCH] pmac_pci.c: replace pci_find_device with pci_get_device

As pci_find_device is going away I've replaced it with pci_get_device.

 arch/ppc/platforms/pmac_pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/ppc/platforms/pmac_pci.c +2 -2
diff -Nru a/arch/ppc/platforms/pmac_pci.c b/arch/ppc/platforms/pmac_pci.c
@@ -889,7 +889,7 @@
 	 * should find the device node and apply the interrupt
 	 * obtained from the OF device-tree
 	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		struct device_node *node;
 		node = pci_device_to_OF_node(dev);
 		/* this is the node, see if it has interrupts */
@@ -989,7 +989,7 @@
 	 *
 	 * -- BenH
 	 */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		if ((dev->class >> 16) == PCI_BASE_CLASS_STORAGE)
 			pci_enable_device(dev);
 	}
author
#44 lore raw

ChangeSet 1.2091.1.24, 2004/11/12 14:12:11-08:00, [email protected]

[PATCH] pplus.c: replace pci_find_device with pci_get_device

 arch/ppc/platforms/pplus.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
arch/ppc/platforms/pplus.c +5 -4
diff -Nru a/arch/ppc/platforms/pplus.c b/arch/ppc/platforms/pplus.c
@@ -359,7 +359,7 @@
 	 * Perform specific configuration for the Via Tech or
 	 * or Winbond PCI-ISA-Bridge part.
 	 */
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_1, dev))) {
 		/*
 		 * PPCBUG does not set the enable bits
@@ -371,7 +371,7 @@
 		pci_write_config_byte(dev, 0x40, reg);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 				   PCI_DEVICE_ID_VIA_82C586_2,
 				   dev)) && (dev->devfn = 0x5a)) {
 		/* Force correct USB interrupt */
@@ -379,7 +379,7 @@
 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_83C553, dev))) {
 		/* Clear PCI Interrupt Routing Control Register. */
 		short_reg = 0x0000;
@@ -389,7 +389,7 @@
 		pci_write_config_byte(dev, 0x43, reg);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_82C105, dev))) {
 		/*
 		 * Disable LEGIRQ mode so PCI INTS are routed
@@ -401,6 +401,7 @@
 		dev->irq = 14;
 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
 	}
+	pci_dev_put(dev);
 }
 
 void __init pplus_set_VIA_IDE_legacy(void)
author
#45 lore raw

ChangeSet 1.2091.1.25, 2004/11/12 14:12:34-08:00, [email protected]

[PATCH] prep_pci.c: replace pci_find_device with pci_get_device

 arch/ppc/platforms/prep_pci.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
arch/ppc/platforms/prep_pci.c +9 -6
diff -Nru a/arch/ppc/platforms/prep_pci.c b/arch/ppc/platforms/prep_pci.c
@@ -1069,7 +1069,7 @@
 		 * Perform specific configuration for the Via Tech or
 		 * or Winbond PCI-ISA-Bridge part.
 		 */
-		if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+		if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 					PCI_DEVICE_ID_VIA_82C586_1, dev))) {
 			/*
 			 * PPCBUG does not set the enable bits
@@ -1080,7 +1080,7 @@
 			reg |= 0x03; /* IDE: Chip Enable Bits */
 			pci_write_config_byte(dev, 0x40, reg);
 		}
-		if ((dev = pci_find_device(PCI_VENDOR_ID_VIA,
+		if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
 						PCI_DEVICE_ID_VIA_82C586_2,
 						dev)) && (dev->devfn = 0x5a)) {
 			/* Force correct USB interrupt */
@@ -1089,7 +1089,7 @@
 					PCI_INTERRUPT_LINE,
 					dev->irq);
 		}
-		if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+		if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 					PCI_DEVICE_ID_WINBOND_83C553, dev))) {
 			 /* Clear PCI Interrupt Routing Control Register. */
 			short_reg = 0x0000;
@@ -1100,9 +1100,10 @@
 				pci_write_config_byte(dev, 0x43, reg);
 			}
 		}
+		pci_dev_put(dev);
 	}
 
-	if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
+	if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
 				   PCI_DEVICE_ID_WINBOND_82C105, dev))){
 		if (OpenPIC_Addr){
 			/*
@@ -1121,6 +1122,7 @@
 			pci_write_config_dword(dev, 0x40, 0x10ff08a1);
 		}
 	}
+	pci_dev_put(dev);
 }
 
 static void __init
@@ -1207,7 +1209,7 @@
 	printk("Setting PCI interrupts for a \"%s\"\n", Motherboard_map_name);
 
 	/* Iterate through all the PCI devices, setting the IRQ */
-	while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
+	for_each_pci_dev(dev) {
 		/*
 		 * If we have residual data, then this is easy: query the
 		 * residual data for the IRQ line allocated to the device.
@@ -1260,12 +1262,13 @@
 	 * instead of 0xc0000. vgacon.c (for example) is completely unaware of
 	 * this little quirk.
 	 */
-	dev = pci_find_device(PCI_VENDOR_ID_WD, PCI_DEVICE_ID_WD_90C, NULL);
+	dev = pci_get_device(PCI_VENDOR_ID_WD, PCI_DEVICE_ID_WD_90C, NULL);
 	if (dev) {
 		dev->resource[1].end -= dev->resource[1].start;
 		dev->resource[1].start = 0;
 		/* tell the hardware */
 		pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, 0x0);
+		pci_dev_put(dev);
 	}
 #endif
 }
#46 lore raw
In reply to Greg KH
Quoted 8 lines · Greg KH

ChangeSet 1.2091.1.2, 2004/11/11 16:32:25-08:00, [email protected]

[PATCH] fakephp: introduce pci_bus_add_device

fakephp needs to add newly discovered devices to the global pci list. Therefore seperate out the appropriate chunk from pci_bus_add_devices to pci_bus_add_device to add a single device to sysfs, procfs and the global device list.

Why is this needed? pci_bus_add_devices() is designed to only add new devices to the device tree - new devices have an empty dev->global_list.

Just calling pci_bus_add_devices() for the parent bus should suffice.

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#47 lore raw
Quoted 12 lines · Russell King
Quoted 8 lines · Greg KH

ChangeSet 1.2091.1.2, 2004/11/11 16:32:25-08:00, [email protected]

[PATCH] fakephp: introduce pci_bus_add_device

fakephp needs to add newly discovered devices to the global pci list. Therefore seperate out the appropriate chunk from pci_bus_add_devices to pci_bus_add_device to add a single device to sysfs, procfs and the global device list.

Quoted 4 lines

Why is this needed? pci_bus_add_devices() is designed to only add new devices to the device tree - new devices have an empty dev->global_list.

Just calling pci_bus_add_devices() for the parent bus should suffice.

The device got removed from bus->devices, so I can't call that. pci_do_scan_bus would probably the correct function to call. But it isn't aware of already existing devices and doesn't allow to add the hotplug slot after discovering new devices. Well I could walk the device tree afterwards and find unbound devices. Still pci_scan_slot would rescan and reenable all devices. What do I overlook?

Thanks,

Jan

#48 lore raw
Quoted 7 lines · Jan Dittmer
Quoted 4 lines · Russell King

Why is this needed? pci_bus_add_devices() is designed to only add new devices to the device tree - new devices have an empty dev->global_list.

Just calling pci_bus_add_devices() for the parent bus should suffice.

The device got removed from bus->devices, so I can't call that.

This sounds very wrong. Why did it get removed from bus->devices ?

If it isn't on bus->devices, how does pci_bus_add_device() help? Sure you get it onto the global list and into the device tree, but it won't be attached to the parent bus properly.

I think what you want to be using is:

int __devinit pci_scan_slot(struct pci_bus *bus, int devfn)

to discover the new device, which will do the right thing from the point of setting stuff up before calling pci_bus_add_device*().

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#49 lore raw
Quoted 18 lines · Russell King
Quoted 8 lines · Jan Dittmer
Quoted 4 lines · Russell King

Why is this needed? pci_bus_add_devices() is designed to only add new devices to the device tree - new devices have an empty dev->global_list.

Just calling pci_bus_add_devices() for the parent bus should suffice.

The device got removed from bus->devices, so I can't call that.

This sounds very wrong. Why did it get removed from bus->devices ?

If it isn't on bus->devices, how does pci_bus_add_device() help? Sure you get it onto the global list and into the device tree, but it won't be attached to the parent bus properly.

Quoted 7 lines

I think what you want to be using is:

int __devinit pci_scan_slot(struct pci_bus *bus, int devfn)

to discover the new device, which will do the right thing from the point of setting stuff up before calling pci_bus_add_device*().

I don't see how pci_scan_slot helps me here. I already call pci_scan_single_device which seems just about the same.

Thanks, Jan

#50 lore raw
Quoted 8 lines · Jan Dittmer
Quoted 8 lines

This sounds very wrong. Why did it get removed from bus->devices ?

If it isn't on bus->devices, how does pci_bus_add_device() help? Sure you get it onto the global list and into the device tree, but it won't be attached to the parent bus properly.

I think what you want to be using is:

Quoted 8 lines
Quoted 5 lines

int __devinit pci_scan_slot(struct pci_bus *bus, int devfn)

to discover the new device, which will do the right thing from the point of setting stuff up before calling pci_bus_add_device*().

I don't see how pci_scan_slot helps me here. I already call pci_scan_single_device which seems just about the same.

Which is also acceptable. The device will be on the bus->devices list. I still don't see why you can't use pci_bus_add_devices() though, or why you think you need to remove it from the bus->devices list.

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
#51 lore raw
Quoted 16 lines · Russell King
Quoted 14 lines · Jan Dittmer
Quoted 13 lines

This sounds very wrong. Why did it get removed from bus->devices ?

If it isn't on bus->devices, how does pci_bus_add_device() help? Sure you get it onto the global list and into the device tree, but it won't be attached to the parent bus properly.

I think what you want to be using is:

int __devinit pci_scan_slot(struct pci_bus *bus, int devfn)

to discover the new device, which will do the right thing from the point of setting stuff up before calling pci_bus_add_device*().

Quoted 8 lines
Quoted 2 lines

I don't see how pci_scan_slot helps me here. I already call pci_scan_single_device which seems just about the same.

Which is also acceptable. The device will be on the bus->devices list. I still don't see why you can't use pci_bus_add_devices() though, or why you think you need to remove it from the bus->devices list.

It's needed for fakephp, where the device gets removed from bus->devices if you disable the slot. pci_scan_single_device then re-adds the device to the list when enabling the slot again.

Jan