Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Add a generic weak pcibios_align_resource()

Multiple architectures define this as a trivial function, and I'm adding
another one as part of the RISC-V port. Add a __weak version of
pcibios_align_resource() and delete the now-obselete ones in a handful of
ports.

The only functional change should be that a handful of ports used to export
pcibios_fixup_bus(). Only some architectures export this, so I just
dropped it.

Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Palmer Dabbelt and committed by
Bjorn Helgaas
ecf677c8 bccf90d6

+13 -69
-9
arch/arc/kernel/pcibios.c
··· 7 7 */ 8 8 9 9 #include <linux/pci.h> 10 - 11 - /* 12 - * We don't have to worry about legacy ISA devices, so nothing to do here 13 - */ 14 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 15 - resource_size_t size, resource_size_t align) 16 - { 17 - return res->start; 18 - }
-9
arch/arm64/kernel/pci.c
··· 22 22 #include <linux/pci-ecam.h> 23 23 #include <linux/slab.h> 24 24 25 - /* 26 - * We don't have to worry about legacy ISA devices, so nothing to do here 27 - */ 28 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 29 - resource_size_t size, resource_size_t align) 30 - { 31 - return res->start; 32 - } 33 - 34 25 #ifdef CONFIG_ACPI 35 26 /* 36 27 * Try to assign the IRQ number when probing a new device
-7
arch/ia64/pci/pci.c
··· 411 411 acpi_pci_irq_disable(dev); 412 412 } 413 413 414 - resource_size_t 415 - pcibios_align_resource (void *data, const struct resource *res, 416 - resource_size_t size, resource_size_t align) 417 - { 418 - return res->start; 419 - } 420 - 421 414 /** 422 415 * ia64_pci_get_legacy_mem - generic legacy mem routine 423 416 * @bus: bus to get legacy memory base address for
-7
arch/microblaze/pci/pci-common.c
··· 823 823 * but we want to try to avoid allocating at 0x2900-0x2bff 824 824 * which might have be mirrored at 0x0100-0x03ff.. 825 825 */ 826 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 827 - resource_size_t size, resource_size_t align) 828 - { 829 - return res->start; 830 - } 831 - EXPORT_SYMBOL(pcibios_align_resource); 832 - 833 826 int pcibios_add_device(struct pci_dev *dev) 834 827 { 835 828 dev->irq = of_irq_parse_and_map_pci(dev, 0, 0);
-6
arch/sparc/kernel/leon_pci.c
··· 94 94 } 95 95 } 96 96 } 97 - 98 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 99 - resource_size_t size, resource_size_t align) 100 - { 101 - return res->start; 102 - }
-6
arch/sparc/kernel/pci.c
··· 690 690 return bus; 691 691 } 692 692 693 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 694 - resource_size_t size, resource_size_t align) 695 - { 696 - return res->start; 697 - } 698 - 699 693 int pcibios_enable_device(struct pci_dev *dev, int mask) 700 694 { 701 695 u16 cmd, oldcmd;
-6
arch/sparc/kernel/pcic.c
··· 746 746 } 747 747 #endif 748 748 749 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 750 - resource_size_t size, resource_size_t align) 751 - { 752 - return res->start; 753 - } 754 - 755 749 int pcibios_enable_device(struct pci_dev *pdev, int mask) 756 750 { 757 751 return 0;
-10
arch/tile/kernel/pci.c
··· 67 67 68 68 69 69 /* 70 - * We don't need to worry about the alignment of resources. 71 - */ 72 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 73 - resource_size_t size, resource_size_t align) 74 - { 75 - return res->start; 76 - } 77 - EXPORT_SYMBOL(pcibios_align_resource); 78 - 79 - /* 80 70 * Open a FD to the hypervisor PCI device. 81 71 * 82 72 * controller_id is the controller number, config type is 0 or 1 for
-9
arch/tile/kernel/pci_gx.c
··· 108 108 /* Mask of CPUs that should receive PCIe interrupts. */ 109 109 static struct cpumask intr_cpus_map; 110 110 111 - /* We don't need to worry about the alignment of resources. */ 112 - resource_size_t pcibios_align_resource(void *data, const struct resource *res, 113 - resource_size_t size, 114 - resource_size_t align) 115 - { 116 - return res->start; 117 - } 118 - EXPORT_SYMBOL(pcibios_align_resource); 119 - 120 111 /* 121 112 * Pick a CPU to receive and handle the PCIe interrupts, based on the IRQ #. 122 113 * For now, we simply send interrupts to non-dataplane CPUs.
+13
drivers/pci/setup-res.c
··· 234 234 return 0; 235 235 } 236 236 237 + /* 238 + * We don't have to worry about legacy ISA devices, so nothing to do here. 239 + * This is marked as __weak because multiple architectures define it; it should 240 + * eventually go away. 241 + */ 242 + resource_size_t __weak pcibios_align_resource(void *data, 243 + const struct resource *res, 244 + resource_size_t size, 245 + resource_size_t align) 246 + { 247 + return res->start; 248 + } 249 + 237 250 static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev, 238 251 int resno, resource_size_t size, resource_size_t align) 239 252 {