PCI: consolidate several pcibios_enable_resources() implementations, v3
Subsystems (10)
cover PCI: consolidate several pcibios_enable_resources() implementations, v3
This series replaces most of the arch-specific pcibios_enable_resources() implementations with a single generic pci_enable_resources().
I think this is ready for -mm, but of course, I'm still interested in any other comments.
Changes between v2 and v3:
- Renamed the generic version to pci_enable_resources(), to keep pcibios_* names for arch-specific code (suggested by Kyle, thanks).
- I reorganized this series into a single PCI patch that adds the new generic version, followed by a bunch of patches that individually convert each arch over to use it.
Bjorn
PATCH 1/16 PCI: add generic pci_enable_resources()
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".
drivers/pci/setup-res.c +43 -0
@@ -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 ; +}
include/linux/pci.h +1 -0
@@ -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
Re: [patch 01/16] PCI: add generic pci_enable_resources()
Quoted 10 lines · Bjorn Helgaas
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 <[email protected]>
Re: [patch 01/16] PCI: add generic pci_enable_resources()
Quoted 8 lines · David Howells
Quoted 5 lines · Bjorn Helgaas
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.
Quoted 7 lines
Quoted 5 lines
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 <[email protected]>Acked-by David Howells <[email protected]>
added, thanks.
greg k-h
PATCH 2/16 alpha: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/alpha/kernel/pci.c +1 -22
@@ -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); }/*
PATCH 3/16 arm: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/arm/kernel/bios32.c +7 -20
@@ -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 ;
PATCH 4/16 cris: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/cris/arch-v32/drivers/pci/bios.c +1 -33
@@ -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)
PATCH 5/16 frv: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/frv/mb93090-mb00/pci-frv.c +0 -32
@@ -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.
arch/frv/mb93090-mb00/pci-frv.h +0 -1
@@ -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 */
arch/frv/mb93090-mb00/pci-vdk.c +1 -1
@@ -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);
Re: [patch 05/16] frv: use generic pci_enable_resources()
Quoted 9 lines · Bjorn Helgaas
Use the generic
pci_enable_resources()instead of the arch-specific code.Unlike this arch-specific code, the generic version:
- checksPCI_NUM_RESOURCES(11), not 6, resources
- skips resources that have neitherIORESOURCE_IOnorIORESOURCE_MEMset
- skips ROM resources unlessIORESOURCE_ROM_ENABLEis set
- checks for resource collisions with "!r->parent"Signed-off-by Bjorn Helgaas <[email protected]>
Re: [patch 05/16] frv: use generic pci_enable_resources()
Quoted 11 lines · David Howells
Quoted 8 lines · Bjorn Helgaas
Use the generic
pci_enable_resources()instead of the arch-specific code.Unlike this arch-specific code, the generic version:
- checksPCI_NUM_RESOURCES(11), not 6, resources
- skips resources that have neitherIORESOURCE_IOnorIORESOURCE_MEMset
- skips ROM resources unlessIORESOURCE_ROM_ENABLEis set
- checks for resource collisions with "!r->parent"
Quoted 3 lines
Quoted 1 line
Signed-off-by Bjorn Helgaas <[email protected]>Acked-by David Howells <[email protected]>
Added, thanks.
greg k-h
PATCH 6/16 ia64: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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
arch/ia64/pci/pci.c +1 -43
@@ -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;
PATCH 7/16 mips: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/mips/pci/pci.c +1 -39
@@ -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);
PATCH 8/16 mn10300: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/mn10300/unit-asb2305/pci-asb2305.c +0 -39
@@ -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.
arch/mn10300/unit-asb2305/pci-asb2305.h +0 -1
@@ -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 */
arch/mn10300/unit-asb2305/pci.c +1 -1
@@ -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;
Re: [patch 08/16] mn10300: use generic pci_enable_resources()
Quoted 9 lines · Bjorn Helgaas
Use the generic
pci_enable_resources()instead of the arch-specific code.Unlike this arch-specific code, the generic version:
- checksPCI_NUM_RESOURCES(11), not 6, resources
- skips resources that have neitherIORESOURCE_IOnorIORESOURCE_MEMset
- skips ROM resources unlessIORESOURCE_ROM_ENABLEis set
- checks for resource collisions with "!r->parent"Signed-off-by Bjorn Helgaas <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [patch 08/16] mn10300: use generic pci_enable_resources()
Quoted 11 lines · David Howells
Quoted 8 lines · Bjorn Helgaas
Use the generic
pci_enable_resources()instead of the arch-specific code.Unlike this arch-specific code, the generic version:
- checksPCI_NUM_RESOURCES(11), not 6, resources
- skips resources that have neitherIORESOURCE_IOnorIORESOURCE_MEMset
- skips ROM resources unlessIORESOURCE_ROM_ENABLEis set
- checks for resource collisions with "!r->parent"
Quoted 3 lines
Quoted 1 line
Signed-off-by Bjorn Helgaas <[email protected]>Acked-by David Howells <[email protected]>
added, thanks.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/16 parisc: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/parisc/kernel/pci.c +13 -17
@@ -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 ; }
A message that is not in the archive (sent off-list or not yet received): [email protected]
Kyle McMartin
Acked-byRe: [patch 09/16] parisc: use generic pci_enable_resources()
Quoted 10 lines · Bjorn Helgaas
Use the generic
pci_enable_resources()instead of the arch-specific code.Unlike this arch-specific code, the generic version:
- checksPCI_NUM_RESOURCES(11), notDEVICE_COUNT_RESOURCE(12), resources
- skips resources that have neitherIORESOURCE_IOnorIORESOURCE_MEMset
- skips ROM resources unlessIORESOURCE_ROM_ENABLEis set
- checks for resource collisions with "!r->parent"Signed-off-by Bjorn Helgaas <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20080305161709.GA3354-EK4dZfYtfFRW/gs8oUvUg/d9D2ou9A/[email protected]
Re: [patch 09/16] parisc: use generic pci_enable_resources()
Quoted 9 lines · Kyle McMartin
Quoted 8 lines · Bjorn Helgaas
Use the generic
pci_enable_resources()instead of the arch-specific code.Unlike this arch-specific code, the generic version:
- checksPCI_NUM_RESOURCES(11), notDEVICE_COUNT_RESOURCE(12), resources
- skips resources that have neitherIORESOURCE_IOnorIORESOURCE_MEMset
- skips ROM resources unlessIORESOURCE_ROM_ENABLEis set
- checks for resource collisions with "!r->parent"
Quoted 4 lines
Quoted 2 lines
Signed-off-by Bjorn Helgaas <[email protected]>
added, thanks.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/16 powerpc: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse the generic pci_enable_resources() instead of the arch-specific code. The generic version is functionally equivalent, but uses dev_printk.
arch/powerpc/kernel/pci-common.c +1 -33
@@ -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); } -
PATCH 11/16 ppc: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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
arch/ppc/kernel/pci.c +2 -57
@@ -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*
PATCH 12/16 sh: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/sh/drivers/pci/pci.c +1 -28
@@ -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); }/*
PATCH 13/16 sparc64: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/sparc64/kernel/pci.c +1 -26
@@ -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,
PATCH 14/16 v850: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/v850/kernel/rte_mb_a_pci.c +1 -24
@@ -219,30 +219,7 @@ 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); }
PATCH 15/16 x86: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/x86/pci/common.c +1 -1
@@ -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)
arch/x86/pci/i386.c +0 -38
@@ -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.
arch/x86/pci/pci.h +0 -1
@@ -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 */
PATCH 16/16 xtensa: use generic pci_enable_resources()
In reply to Bjorn HelgaasUse 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"
arch/xtensa/kernel/pci.c +1 -56
@@ -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