* [patch 01/16] PCI: add generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 02/16] alpha: use " Bjorn Helgaas
` (17 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Each architecture has its own pcibios_enable_resources() implementation.
These differ in many minor ways that have nothing to do with actual
architectural differences. Follow-on patches will make most arches
use this generic version instead.
This version is based on powerpc, which seemed most up-to-date. The only
functional difference from the x86 version is that this uses "!r->parent"
to check for resource collisions instead of "!r->start && r->end".
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/drivers/pci/setup-res.c
===================================================================
--- work8.orig/drivers/pci/setup-res.c 2008-03-04 09:56:53.000000000 -0700
+++ work8/drivers/pci/setup-res.c 2008-03-04 09:56:56.000000000 -0700
@@ -263,3 +263,46 @@
}
}
}
+
+int pci_enable_resources(struct pci_dev *dev, int mask)
+{
+ u16 cmd, old_cmd;
+ int i;
+ struct resource *r;
+
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ old_cmd = cmd;
+
+ for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+ if (!(mask & (1 << i)))
+ continue;
+
+ r = &dev->resource[i];
+
+ if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
+ continue;
+ if ((i == PCI_ROM_RESOURCE) &&
+ (!(r->flags & IORESOURCE_ROM_ENABLE)))
+ continue;
+
+ if (!r->parent) {
+ dev_err(&dev->dev, "device not available because of "
+ "BAR %d [%llx:%llx] collisions\n", i,
+ (unsigned long long) r->start,
+ (unsigned long long) r->end);
+ return -EINVAL;
+ }
+
+ if (r->flags & IORESOURCE_IO)
+ cmd |= PCI_COMMAND_IO;
+ if (r->flags & IORESOURCE_MEM)
+ cmd |= PCI_COMMAND_MEMORY;
+ }
+
+ if (cmd != old_cmd) {
+ dev_info(&dev->dev, "enabling device (%04x -> %04x)\n",
+ old_cmd, cmd);
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+ }
+ return 0;
+}
Index: work8/include/linux/pci.h
===================================================================
--- work8.orig/include/linux/pci.h 2008-03-04 09:56:45.000000000 -0700
+++ work8/include/linux/pci.h 2008-03-04 09:56:56.000000000 -0700
@@ -616,6 +616,7 @@
void pci_assign_unassigned_resources(void);
void pdev_enable_device(struct pci_dev *);
void pdev_sort_resources(struct pci_dev *, struct resource_list *);
+int pci_enable_resources(struct pci_dev *, int mask);
void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
int (*)(struct pci_dev *, u8, u8));
#define HAVE_PCI_REQ_REGIONS 2
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 02/16] alpha: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
2008-03-04 18:56 ` [patch 01/16] PCI: add generic pci_enable_resources() Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 03/16] arm: " Bjorn Helgaas
` (16 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- skips resources unless requested in "mask"
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/alpha/kernel/pci.c
===================================================================
--- work8.orig/arch/alpha/kernel/pci.c 2008-03-04 09:58:07.000000000 -0700
+++ work8/arch/alpha/kernel/pci.c 2008-03-04 09:58:54.000000000 -0700
@@ -372,28 +372,7 @@
int
pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd, oldcmd;
- int i;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- oldcmd = cmd;
-
- for (i = 0; i < PCI_NUM_RESOURCES; i++) {
- struct resource *res = &dev->resource[i];
-
- if (res->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- else if (res->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
-
- if (cmd != oldcmd) {
- printk(KERN_DEBUG "PCI: Enabling device: (%s), cmd %x\n",
- pci_name(dev), cmd);
- /* Enable the appropriate bits in the PCI command register. */
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
+ return pci_enable_resources(dev, mask);
}
/*
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 03/16] arm: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
2008-03-04 18:56 ` [patch 01/16] PCI: add generic pci_enable_resources() Bjorn Helgaas
2008-03-04 18:56 ` [patch 02/16] alpha: use " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 04/16] cris: " Bjorn Helgaas
` (15 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/arm/kernel/bios32.c
===================================================================
--- work8.orig/arch/arm/kernel/bios32.c 2008-03-04 09:59:24.000000000 -0700
+++ work8/arch/arm/kernel/bios32.c 2008-03-04 10:01:40.000000000 -0700
@@ -660,28 +660,15 @@
*/
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
+ int err;
u16 cmd, old_cmd;
- int idx;
- struct resource *r;
+
+ err = pci_enable_resources(dev, mask);
+ if (err < 0)
+ return err;
pci_read_config_word(dev, PCI_COMMAND, &cmd);
old_cmd = cmd;
- for (idx = 0; idx < 6; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1 << idx)))
- continue;
-
- r = dev->resource + idx;
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available because"
- " of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
/*
* Bridges (eg, cardbus bridges) need to be fully enabled
@@ -690,8 +677,8 @@
cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
if (cmd != old_cmd) {
- printk("PCI: enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
+ dev_info(&dev->dev, "enabling bridge device (%04x -> %04x)\n",
+ old_cmd, cmd);
pci_write_config_word(dev, PCI_COMMAND, cmd);
}
return 0;
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 04/16] cris: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (2 preceding siblings ...)
2008-03-04 18:56 ` [patch 03/16] arm: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 05/16] frv: " Bjorn Helgaas
` (14 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/cris/arch-v32/drivers/pci/bios.c
===================================================================
--- work8.orig/arch/cris/arch-v32/drivers/pci/bios.c 2008-03-04 10:02:27.000000000 -0700
+++ work8/arch/cris/arch-v32/drivers/pci/bios.c 2008-03-04 10:02:47.000000000 -0700
@@ -55,38 +55,6 @@
}
}
-int pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for(idx=0; idx<6; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1<<idx)))
- continue;
-
- r = &dev->resource[idx];
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (dev->resource[PCI_ROM_RESOURCE].start)
- cmd |= PCI_COMMAND_MEMORY;
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
int pcibios_enable_irq(struct pci_dev *dev)
{
dev->irq = EXT_INTR_VECT;
@@ -97,7 +65,7 @@
{
int err;
- if ((err = pcibios_enable_resources(dev, mask)) < 0)
+ if ((err = pci_enable_resources(dev, mask)) < 0)
return err;
if (!dev->msi_enabled)
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 05/16] frv: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (3 preceding siblings ...)
2008-03-04 18:56 ` [patch 04/16] cris: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 06/16] ia64: " Bjorn Helgaas
` (13 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/frv/mb93090-mb00/pci-frv.c
===================================================================
--- work8.orig/arch/frv/mb93090-mb00/pci-frv.c 2008-03-04 10:03:11.000000000 -0700
+++ work8/arch/frv/mb93090-mb00/pci-frv.c 2008-03-04 10:03:25.000000000 -0700
@@ -231,38 +231,6 @@
pcibios_assign_resources();
}
-int pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for(idx=0; idx<6; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1<<idx)))
- continue;
-
- r = &dev->resource[idx];
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (dev->resource[PCI_ROM_RESOURCE].start)
- cmd |= PCI_COMMAND_MEMORY;
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
/*
* If we set up a device for bus mastering, we need to check the latency
* timer as certain crappy BIOSes forget to set it properly.
Index: work8/arch/frv/mb93090-mb00/pci-frv.h
===================================================================
--- work8.orig/arch/frv/mb93090-mb00/pci-frv.h 2008-03-04 10:03:29.000000000 -0700
+++ work8/arch/frv/mb93090-mb00/pci-frv.h 2008-03-04 10:03:33.000000000 -0700
@@ -31,7 +31,6 @@
extern unsigned int pcibios_max_latency;
void pcibios_resource_survey(void);
-int pcibios_enable_resources(struct pci_dev *, int);
/* pci-vdk.c */
Index: work8/arch/frv/mb93090-mb00/pci-vdk.c
===================================================================
--- work8.orig/arch/frv/mb93090-mb00/pci-vdk.c 2008-03-04 10:03:37.000000000 -0700
+++ work8/arch/frv/mb93090-mb00/pci-vdk.c 2008-03-04 10:03:45.000000000 -0700
@@ -465,7 +465,7 @@
{
int err;
- if ((err = pcibios_enable_resources(dev, mask)) < 0)
+ if ((err = pci_enable_resources(dev, mask)) < 0)
return err;
if (!dev->msi_enabled)
pcibios_enable_irq(dev);
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 06/16] ia64: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (4 preceding siblings ...)
2008-03-04 18:56 ` [patch 05/16] frv: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 07/16] mips: " Bjorn Helgaas
` (12 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- does not check for a NULL dev pointer
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/ia64/pci/pci.c
===================================================================
--- work8.orig/arch/ia64/pci/pci.c 2008-03-04 10:04:18.000000000 -0700
+++ work8/arch/ia64/pci/pci.c 2008-03-04 10:04:35.000000000 -0700
@@ -499,54 +499,12 @@
/* ??? FIXME -- record old value for shutdown. */
}
-static inline int
-pcibios_enable_resources (struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
- unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
-
- if (!dev)
- return -EINVAL;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx=0; idx<PCI_NUM_RESOURCES; idx++) {
- /* Only set up the desired resources. */
- if (!(mask & (1 << idx)))
- continue;
-
- r = &dev->resource[idx];
- if (!(r->flags & type_mask))
- continue;
- if ((idx == PCI_ROM_RESOURCE) &&
- (!(r->flags & IORESOURCE_ROM_ENABLE)))
- continue;
- if (!r->start && r->end) {
- printk(KERN_ERR
- "PCI: Device %s not available because of resource collisions\n",
- pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
int
pcibios_enable_device (struct pci_dev *dev, int mask)
{
int ret;
- ret = pcibios_enable_resources(dev, mask);
+ ret = pci_enable_resources(dev, mask);
if (ret < 0)
return ret;
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 07/16] mips: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (5 preceding siblings ...)
2008-03-04 18:56 ` [patch 06/16] ia64: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 08/16] mn10300: " Bjorn Helgaas
` (11 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/mips/pci/pci.c
===================================================================
--- work8.orig/arch/mips/pci/pci.c 2008-03-04 10:04:51.000000000 -0700
+++ work8/arch/mips/pci/pci.c 2008-03-04 10:05:08.000000000 -0700
@@ -163,44 +163,6 @@
subsys_initcall(pcibios_init);
-static int pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1<<idx)))
- continue;
-
- r = &dev->resource[idx];
- if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
- continue;
- if ((idx == PCI_ROM_RESOURCE) &&
- (!(r->flags & IORESOURCE_ROM_ENABLE)))
- continue;
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available "
- "because of resource collisions\n",
- pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
/*
* If we set up a device for bus mastering, we need to check the latency
* timer as certain crappy BIOSes forget to set it properly.
@@ -231,7 +193,7 @@
{
int err;
- if ((err = pcibios_enable_resources(dev, mask)) < 0)
+ if ((err = pci_enable_resources(dev, mask)) < 0)
return err;
return pcibios_plat_dev_init(dev);
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 08/16] mn10300: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (6 preceding siblings ...)
2008-03-04 18:56 ` [patch 07/16] mips: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 09/16] parisc: " Bjorn Helgaas
` (10 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/mn10300/unit-asb2305/pci-asb2305.c
===================================================================
--- work8.orig/arch/mn10300/unit-asb2305/pci-asb2305.c 2008-03-04 10:05:27.000000000 -0700
+++ work8/arch/mn10300/unit-asb2305/pci-asb2305.c 2008-03-04 10:05:36.000000000 -0700
@@ -218,45 +218,6 @@
pcibios_allocate_resources(1);
}
-int pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
-
- for (idx = 0; idx < 6; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1 << idx)))
- continue;
-
- r = &dev->resource[idx];
-
- if (!r->start && r->end) {
- printk(KERN_ERR
- "PCI: Device %s not available because of"
- " resource collisions\n",
- pci_name(dev));
- return -EINVAL;
- }
-
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
-
- if (dev->resource[PCI_ROM_RESOURCE].start)
- cmd |= PCI_COMMAND_MEMORY;
-
- if (cmd != old_cmd)
- pci_write_config_word(dev, PCI_COMMAND, cmd);
-
- return 0;
-}
-
/*
* If we set up a device for bus mastering, we need to check the latency
* timer as certain crappy BIOSes forget to set it properly.
Index: work8/arch/mn10300/unit-asb2305/pci-asb2305.h
===================================================================
--- work8.orig/arch/mn10300/unit-asb2305/pci-asb2305.h 2008-03-04 10:05:41.000000000 -0700
+++ work8/arch/mn10300/unit-asb2305/pci-asb2305.h 2008-03-04 10:05:45.000000000 -0700
@@ -36,7 +36,6 @@
extern unsigned int pcibios_max_latency;
extern void pcibios_resource_survey(void);
-extern int pcibios_enable_resources(struct pci_dev *dev, int mask);
/* pci.c */
Index: work8/arch/mn10300/unit-asb2305/pci.c
===================================================================
--- work8.orig/arch/mn10300/unit-asb2305/pci.c 2008-03-04 10:05:49.000000000 -0700
+++ work8/arch/mn10300/unit-asb2305/pci.c 2008-03-04 10:05:54.000000000 -0700
@@ -440,7 +440,7 @@
{
int err;
- err = pcibios_enable_resources(dev, mask);
+ err = pci_enable_resources(dev, mask);
if (err == 0)
pcibios_enable_irq(dev);
return err;
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 09/16] parisc: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (7 preceding siblings ...)
2008-03-04 18:56 ` [patch 08/16] mn10300: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-05 16:17 ` Kyle McMartin
2008-03-04 18:56 ` [patch 10/16] powerpc: " Bjorn Helgaas
` (9 subsequent siblings)
18 siblings, 1 reply; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not DEVICE_COUNT_RESOURCE (12), resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/parisc/kernel/pci.c
===================================================================
--- work8.orig/arch/parisc/kernel/pci.c 2008-03-04 10:06:11.000000000 -0700
+++ work8/arch/parisc/kernel/pci.c 2008-03-04 10:07:54.000000000 -0700
@@ -287,23 +287,15 @@
*/
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd;
- int idx;
+ int err;
+ u16 cmd, old_cmd;
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
-
- for (idx = 0; idx < DEVICE_COUNT_RESOURCE; idx++) {
- struct resource *r = &dev->resource[idx];
+ err = pci_enable_resources(dev, mask);
+ if (err < 0)
+ return err;
- /* only setup requested resources */
- if (!(mask & (1<<idx)))
- continue;
-
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
+ pci_read_config_word(dev, PCI_COMMAND, &cmd);
+ old_cmd = cmd;
cmd |= (PCI_COMMAND_SERR | PCI_COMMAND_PARITY);
@@ -312,8 +304,12 @@
if (dev->bus->bridge_ctl & PCI_BRIDGE_CTL_FAST_BACK)
cmd |= PCI_COMMAND_FAST_BACK;
#endif
- DBGC("PCIBIOS: Enabling device %s cmd 0x%04x\n", pci_name(dev), cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
+
+ if (cmd != old_cmd) {
+ dev_info(&dev->dev, "enabling SERR and PARITY (%04x -> %04x)\n",
+ old_cmd, cmd);
+ pci_write_config_word(dev, PCI_COMMAND, cmd);
+ }
return 0;
}
--
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [patch 09/16] parisc: use generic pci_enable_resources()
2008-03-04 18:56 ` [patch 09/16] parisc: " Bjorn Helgaas
@ 2008-03-05 16:17 ` Kyle McMartin
2008-03-05 20:09 ` Greg KH
0 siblings, 1 reply; 25+ messages in thread
From: Kyle McMartin @ 2008-03-05 16:17 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, Russell King
On Tue, Mar 04, 2008 at 11:56:55AM -0700, Bjorn Helgaas wrote:
> Use the generic pci_enable_resources() instead of the arch-specific code.
>
> Unlike this arch-specific code, the generic version:
> - checks PCI_NUM_RESOURCES (11), not DEVICE_COUNT_RESOURCE (12), resources
> - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
> - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
> - checks for resource collisions with "!r->parent"
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
>
Acked-by: Kyle McMartin <kyle@mcmartin.ca>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [patch 09/16] parisc: use generic pci_enable_resources()
2008-03-05 16:17 ` Kyle McMartin
@ 2008-03-05 20:09 ` Greg KH
0 siblings, 0 replies; 25+ messages in thread
From: Greg KH @ 2008-03-05 20:09 UTC (permalink / raw)
To: Kyle McMartin
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, Russell King, Bjorn Helgaas
On Wed, Mar 05, 2008 at 11:17:10AM -0500, Kyle McMartin wrote:
> On Tue, Mar 04, 2008 at 11:56:55AM -0700, Bjorn Helgaas wrote:
> > Use the generic pci_enable_resources() instead of the arch-specific code.
> >
> > Unlike this arch-specific code, the generic version:
> > - checks PCI_NUM_RESOURCES (11), not DEVICE_COUNT_RESOURCE (12), resources
> > - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
> > - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
> > - checks for resource collisions with "!r->parent"
> >
> > Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
> >
>
> Acked-by: Kyle McMartin <kyle@mcmartin.ca>
added, thanks.
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread
* [patch 10/16] powerpc: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (8 preceding siblings ...)
2008-03-04 18:56 ` [patch 09/16] parisc: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 11/16] ppc: " Bjorn Helgaas
` (8 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
The generic version is functionally equivalent, but uses dev_printk.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/powerpc/kernel/pci-common.c
===================================================================
--- work8.orig/arch/powerpc/kernel/pci-common.c 2008-03-04 10:08:18.000000000 -0700
+++ work8/arch/powerpc/kernel/pci-common.c 2008-03-04 10:08:54.000000000 -0700
@@ -1155,41 +1155,9 @@
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
if (ppc_md.pcibios_enable_device_hook)
if (ppc_md.pcibios_enable_device_hook(dev))
return -EINVAL;
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1 << idx)))
- continue;
- r = &dev->resource[idx];
- if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
- continue;
- if ((idx == PCI_ROM_RESOURCE) &&
- (!(r->flags & IORESOURCE_ROM_ENABLE)))
- continue;
- if (r->parent == NULL) {
- printk(KERN_ERR "PCI: Device %s not available because"
- " of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
+ return pci_enable_resources(dev, mask);
}
-
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 11/16] ppc: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (9 preceding siblings ...)
2008-03-04 18:56 ` [patch 10/16] powerpc: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 12/16] sh: " Bjorn Helgaas
` (7 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent", not IORESOURCE_UNSET
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/ppc/kernel/pci.c
===================================================================
--- work8.orig/arch/ppc/kernel/pci.c 2008-03-04 10:09:13.000000000 -0700
+++ work8/arch/ppc/kernel/pci.c 2008-03-04 10:10:18.000000000 -0700
@@ -578,39 +578,6 @@
}
-int
-pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx=0; idx<6; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1<<idx)))
- continue;
-
- r = &dev->resource[idx];
- if (r->flags & IORESOURCE_UNSET) {
- printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (dev->resource[PCI_ROM_RESOURCE].start)
- cmd |= PCI_COMMAND_MEMORY;
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
static int next_controller_index;
struct pci_controller * __init
@@ -785,33 +752,11 @@
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
if (ppc_md.pcibios_enable_device_hook)
if (ppc_md.pcibios_enable_device_hook(dev, 0))
return -EINVAL;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx=0; idx<6; idx++) {
- r = &dev->resource[idx];
- if (r->flags & IORESOURCE_UNSET) {
- printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
+
+ return pci_enable_resources(dev, mask);
}
struct pci_controller*
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 12/16] sh: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (10 preceding siblings ...)
2008-03-04 18:56 ` [patch 11/16] ppc: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:56 ` [patch 13/16] sparc64: " Bjorn Helgaas
` (6 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/sh/drivers/pci/pci.c
===================================================================
--- work8.orig/arch/sh/drivers/pci/pci.c 2008-03-04 10:10:44.000000000 -0700
+++ work8/arch/sh/drivers/pci/pci.c 2008-03-04 10:11:04.000000000 -0700
@@ -133,34 +133,7 @@
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for(idx=0; idx<6; idx++) {
- if (!(mask & (1 << idx)))
- continue;
- r = &dev->resource[idx];
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available because "
- "of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (dev->resource[PCI_ROM_RESOURCE].start)
- cmd |= PCI_COMMAND_MEMORY;
- if (cmd != old_cmd) {
- printk(KERN_INFO "PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
+ return pci_enable_resources(dev, mask);
}
/*
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 13/16] sparc64: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (11 preceding siblings ...)
2008-03-04 18:56 ` [patch 12/16] sh: " Bjorn Helgaas
@ 2008-03-04 18:56 ` Bjorn Helgaas
2008-03-04 18:57 ` [patch 14/16] v850: " Bjorn Helgaas
` (5 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:56 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/sparc64/kernel/pci.c
===================================================================
--- work8.orig/arch/sparc64/kernel/pci.c 2008-03-04 10:11:25.000000000 -0700
+++ work8/arch/sparc64/kernel/pci.c 2008-03-04 10:11:45.000000000 -0700
@@ -927,32 +927,7 @@
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd, oldcmd;
- int i;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- oldcmd = cmd;
-
- for (i = 0; i < PCI_NUM_RESOURCES; i++) {
- struct resource *res = &dev->resource[i];
-
- /* Only set up the requested stuff */
- if (!(mask & (1<<i)))
- continue;
-
- if (res->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (res->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
-
- if (cmd != oldcmd) {
- printk(KERN_DEBUG "PCI: Enabling device: (%s), cmd %x\n",
- pci_name(dev), cmd);
- /* Enable the appropriate bits in the PCI command register. */
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
+ return pci_enable_resources(dev, mask);
}
void pcibios_resource_to_bus(struct pci_dev *pdev, struct pci_bus_region *region,
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 14/16] v850: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (12 preceding siblings ...)
2008-03-04 18:56 ` [patch 13/16] sparc64: " Bjorn Helgaas
@ 2008-03-04 18:57 ` Bjorn Helgaas
2008-03-04 18:57 ` [patch 15/16] x86: " Bjorn Helgaas
` (4 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:57 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/v850/kernel/rte_mb_a_pci.c
===================================================================
--- work8.orig/arch/v850/kernel/rte_mb_a_pci.c 2008-03-04 10:12:04.000000000 -0700
+++ work8/arch/v850/kernel/rte_mb_a_pci.c 2008-03-04 10:12:26.000000000 -0700
@@ -219,30 +219,7 @@
\f
int __nomods_init pcibios_enable_device (struct pci_dev *dev, int mask)
{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx = 0; idx < 6; idx++) {
- r = &dev->resource[idx];
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available because "
- "of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
+ return pci_enable_resources(dev, mask);
}
\f
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 15/16] x86: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (13 preceding siblings ...)
2008-03-04 18:57 ` [patch 14/16] v850: " Bjorn Helgaas
@ 2008-03-04 18:57 ` Bjorn Helgaas
2008-03-04 18:57 ` [patch 16/16] xtensa: " Bjorn Helgaas
` (3 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:57 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/x86/pci/common.c
===================================================================
--- work8.orig/arch/x86/pci/common.c 2008-03-04 10:12:42.000000000 -0700
+++ work8/arch/x86/pci/common.c 2008-03-04 10:12:51.000000000 -0700
@@ -527,7 +527,7 @@
{
int err;
- if ((err = pcibios_enable_resources(dev, mask)) < 0)
+ if ((err = pci_enable_resources(dev, mask)) < 0)
return err;
if (!dev->msi_enabled)
Index: work8/arch/x86/pci/i386.c
===================================================================
--- work8.orig/arch/x86/pci/i386.c 2008-03-04 10:12:56.000000000 -0700
+++ work8/arch/x86/pci/i386.c 2008-03-04 10:13:03.000000000 -0700
@@ -238,44 +238,6 @@
*/
fs_initcall(pcibios_assign_resources);
-int pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
- /* Only set up the requested stuff */
- if (!(mask & (1 << idx)))
- continue;
-
- r = &dev->resource[idx];
- if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
- continue;
- if ((idx == PCI_ROM_RESOURCE) &&
- (!(r->flags & IORESOURCE_ROM_ENABLE)))
- continue;
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available "
- "because of resource %d collisions\n",
- pci_name(dev), idx);
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
/*
* If we set up a device for bus mastering, we need to check the latency
* timer as certain crappy BIOSes forget to set it properly.
Index: work8/arch/x86/pci/pci.h
===================================================================
--- work8.orig/arch/x86/pci/pci.h 2008-03-04 10:13:08.000000000 -0700
+++ work8/arch/x86/pci/pci.h 2008-03-04 10:13:12.000000000 -0700
@@ -44,7 +44,6 @@
extern unsigned int pcibios_max_latency;
void pcibios_resource_survey(void);
-int pcibios_enable_resources(struct pci_dev *, int);
/* pci-pc.c */
--
^ permalink raw reply [flat|nested] 25+ messages in thread* [patch 16/16] xtensa: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (14 preceding siblings ...)
2008-03-04 18:57 ` [patch 15/16] x86: " Bjorn Helgaas
@ 2008-03-04 18:57 ` Bjorn Helgaas
2008-03-05 14:52 ` [patch 05/16] frv: " David Howells
` (2 subsequent siblings)
18 siblings, 0 replies; 25+ messages in thread
From: Bjorn Helgaas @ 2008-03-04 18:57 UTC (permalink / raw)
To: linux-pci, linux-arch
Cc: Chris Zankel, Grant Grundler, linux-parisc, Matthew Wilcox,
Kyle McMartin, linuxppc-dev, Paul Mackerras, linux-arm-kernel,
Russell King
Use the generic pci_enable_resources() instead of the arch-specific code.
Unlike this arch-specific code, the generic version:
- checks PCI_NUM_RESOURCES (11), not 6, resources
- skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
- skips ROM resources unless IORESOURCE_ROM_ENABLE is set
- checks for resource collisions with "!r->parent"
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work8/arch/xtensa/kernel/pci.c
===================================================================
--- work8.orig/arch/xtensa/kernel/pci.c 2008-03-04 10:17:29.000000000 -0700
+++ work8/arch/xtensa/kernel/pci.c 2008-03-04 10:18:07.000000000 -0700
@@ -91,37 +91,6 @@
}
}
-int
-pcibios_enable_resources(struct pci_dev *dev, int mask)
-{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for(idx=0; idx<6; idx++) {
- r = &dev->resource[idx];
- if (!r->start && r->end) {
- printk (KERN_ERR "PCI: Device %s not available because "
- "of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (dev->resource[PCI_ROM_RESOURCE].start)
- cmd |= PCI_COMMAND_MEMORY;
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
- return 0;
-}
-
struct pci_controller * __init pcibios_alloc_controller(void)
{
struct pci_controller *pci_ctrl;
@@ -238,31 +207,7 @@
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
- u16 cmd, old_cmd;
- int idx;
- struct resource *r;
-
- pci_read_config_word(dev, PCI_COMMAND, &cmd);
- old_cmd = cmd;
- for (idx=0; idx<6; idx++) {
- r = &dev->resource[idx];
- if (!r->start && r->end) {
- printk(KERN_ERR "PCI: Device %s not available because "
- "of resource collisions\n", pci_name(dev));
- return -EINVAL;
- }
- if (r->flags & IORESOURCE_IO)
- cmd |= PCI_COMMAND_IO;
- if (r->flags & IORESOURCE_MEM)
- cmd |= PCI_COMMAND_MEMORY;
- }
- if (cmd != old_cmd) {
- printk("PCI: Enabling device %s (%04x -> %04x)\n",
- pci_name(dev), old_cmd, cmd);
- pci_write_config_word(dev, PCI_COMMAND, cmd);
- }
-
- return 0;
+ return pci_enable_resources(dev, mask);
}
#ifdef CONFIG_PROC_FS
--
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [patch 05/16] frv: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (15 preceding siblings ...)
2008-03-04 18:57 ` [patch 16/16] xtensa: " Bjorn Helgaas
@ 2008-03-05 14:52 ` David Howells
2008-03-05 20:14 ` Greg KH
2008-03-05 14:53 ` [patch 01/16] PCI: add " David Howells
2008-03-05 15:13 ` [patch 08/16] mn10300: use " David Howells
18 siblings, 1 reply; 25+ messages in thread
From: David Howells @ 2008-03-05 14:52 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, linux-arm-kernel, Russell King
Bjorn Helgaas <bjorn.helgaas@hp.com> wrote:
> Use the generic pci_enable_resources() instead of the arch-specific code.
>
> Unlike this arch-specific code, the generic version:
> - checks PCI_NUM_RESOURCES (11), not 6, resources
> - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
> - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
> - checks for resource collisions with "!r->parent"
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [patch 05/16] frv: use generic pci_enable_resources()
2008-03-05 14:52 ` [patch 05/16] frv: " David Howells
@ 2008-03-05 20:14 ` Greg KH
0 siblings, 0 replies; 25+ messages in thread
From: Greg KH @ 2008-03-05 20:14 UTC (permalink / raw)
To: David Howells
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, linux-arm-kernel, Russell King, Bjorn Helgaas
On Wed, Mar 05, 2008 at 02:52:46PM +0000, David Howells wrote:
>
> Bjorn Helgaas <bjorn.helgaas@hp.com> wrote:
>
> > Use the generic pci_enable_resources() instead of the arch-specific code.
> >
> > Unlike this arch-specific code, the generic version:
> > - checks PCI_NUM_RESOURCES (11), not 6, resources
> > - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
> > - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
> > - checks for resource collisions with "!r->parent"
> >
> > Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
>
> Acked-by: David Howells <dhowells@redhat.com>
Added, thanks.
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [patch 01/16] PCI: add generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (16 preceding siblings ...)
2008-03-05 14:52 ` [patch 05/16] frv: " David Howells
@ 2008-03-05 14:53 ` David Howells
2008-03-05 20:14 ` Greg KH
2008-03-05 15:13 ` [patch 08/16] mn10300: use " David Howells
18 siblings, 1 reply; 25+ messages in thread
From: David Howells @ 2008-03-05 14:53 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, linux-arm-kernel, Russell King
Bjorn Helgaas <bjorn.helgaas@hp.com> wrote:
> Each architecture has its own pcibios_enable_resources() implementation.
> These differ in many minor ways that have nothing to do with actual
> architectural differences. Follow-on patches will make most arches
> use this generic version instead.
>
> This version is based on powerpc, which seemed most up-to-date. The only
> functional difference from the x86 version is that this uses "!r->parent"
> to check for resource collisions instead of "!r->start && r->end".
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [patch 01/16] PCI: add generic pci_enable_resources()
2008-03-05 14:53 ` [patch 01/16] PCI: add " David Howells
@ 2008-03-05 20:14 ` Greg KH
0 siblings, 0 replies; 25+ messages in thread
From: Greg KH @ 2008-03-05 20:14 UTC (permalink / raw)
To: David Howells
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, linux-arm-kernel, Russell King, Bjorn Helgaas
On Wed, Mar 05, 2008 at 02:53:31PM +0000, David Howells wrote:
>
> Bjorn Helgaas <bjorn.helgaas@hp.com> wrote:
>
> > Each architecture has its own pcibios_enable_resources() implementation.
> > These differ in many minor ways that have nothing to do with actual
> > architectural differences. Follow-on patches will make most arches
> > use this generic version instead.
> >
> > This version is based on powerpc, which seemed most up-to-date. The only
> > functional difference from the x86 version is that this uses "!r->parent"
> > to check for resource collisions instead of "!r->start && r->end".
> >
> > Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
>
> Acked-by: David Howells <dhowells@redhat.com>
added, thanks.
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [patch 08/16] mn10300: use generic pci_enable_resources()
2008-03-04 18:56 [patch 00/16] PCI: consolidate several pcibios_enable_resources() implementations, v3 Bjorn Helgaas
` (17 preceding siblings ...)
2008-03-05 14:53 ` [patch 01/16] PCI: add " David Howells
@ 2008-03-05 15:13 ` David Howells
2008-03-05 20:15 ` Greg KH
18 siblings, 1 reply; 25+ messages in thread
From: David Howells @ 2008-03-05 15:13 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, linux-arm-kernel, Russell King
Bjorn Helgaas <bjorn.helgaas@hp.com> wrote:
> Use the generic pci_enable_resources() instead of the arch-specific code.
>
> Unlike this arch-specific code, the generic version:
> - checks PCI_NUM_RESOURCES (11), not 6, resources
> - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
> - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
> - checks for resource collisions with "!r->parent"
>
> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: David Howells <dhowells@redhat.com>
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [patch 08/16] mn10300: use generic pci_enable_resources()
2008-03-05 15:13 ` [patch 08/16] mn10300: use " David Howells
@ 2008-03-05 20:15 ` Greg KH
0 siblings, 0 replies; 25+ messages in thread
From: Greg KH @ 2008-03-05 20:15 UTC (permalink / raw)
To: David Howells
Cc: linux-arch, Chris Zankel, Grant Grundler, linux-parisc,
Matthew Wilcox, Kyle McMartin, linuxppc-dev, Paul Mackerras,
linux-pci, linux-arm-kernel, Russell King, Bjorn Helgaas
On Wed, Mar 05, 2008 at 03:13:10PM +0000, David Howells wrote:
>
> Bjorn Helgaas <bjorn.helgaas@hp.com> wrote:
>
> > Use the generic pci_enable_resources() instead of the arch-specific code.
> >
> > Unlike this arch-specific code, the generic version:
> > - checks PCI_NUM_RESOURCES (11), not 6, resources
> > - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set
> > - skips ROM resources unless IORESOURCE_ROM_ENABLE is set
> > - checks for resource collisions with "!r->parent"
> >
> > Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
>
> Acked-by: David Howells <dhowells@redhat.com>
added, thanks.
greg k-h
^ permalink raw reply [flat|nested] 25+ messages in thread