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

ARM/PCI: Replace pci_sys_data->align_resource with global function pointer

dw_pcie_host_init() creates the PCI host bridge with pci_common_init_dev(),
an ARM-specific function that supplies the ARM-specific pci_sys_data
structure as the PCI "sysdata". To use dw_pcie_host_init() on other
architectures, we will copy the internals of pci_common_init_dev() into
pcie-designware.c instead of calling it, and dw_pcie_host_init() will
supply the DesignWare pcie_port structure as "sysdata".

Most ARM "sysdata" users are specific to non-DesignWare host bridges;
they'll be unaffected because those bridges will continue to have the ARM
pci_sys_data. Most of the rest are ARM-generic functions called by
pci_common_init_dev(); these will be unaffected because dw_pcie_host_init()
will no longer call pci_common_init().

But the ARM pcibios_align_resource() can be called by the PCI core for any
bridge, so it can't depend on sysdata since it may be either pci_sys_data
or pcie_port.

Remove the pcibios_align_resource() dependency on sysdata by replacing the
pci_sys_data->align_resource pointer with a global function pointer.

This is less general (we can no longer have per-host bridge
align_resource() methods), but the pci_sys_data->align_resource pointer was
used only by Marvell (see mvebu_pcie_enable()), so this would only be a
problem if we had a system with a combination of Marvell and other host
bridges

[bhelgaas: changelog]
Signed-off-by: Gabriele Paoloni <gabriele.paoloni@huawei.com>
Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>

authored by

Gabriele Paoloni and committed by
Bjorn Helgaas
b3a72384 0021d22b

+8 -10
-6
arch/arm/include/asm/mach/pci.h
··· 52 52 u8 (*swizzle)(struct pci_dev *, u8 *); 53 53 /* IRQ mapping */ 54 54 int (*map_irq)(const struct pci_dev *, u8, u8); 55 - /* Resource alignement requirements */ 56 - resource_size_t (*align_resource)(struct pci_dev *dev, 57 - const struct resource *res, 58 - resource_size_t start, 59 - resource_size_t size, 60 - resource_size_t align); 61 55 void *private_data; /* platform controller private data */ 62 56 }; 63 57
+8 -4
arch/arm/kernel/bios32.c
··· 17 17 #include <asm/mach/pci.h> 18 18 19 19 static int debug_pci; 20 + static resource_size_t (*align_resource)(struct pci_dev *dev, 21 + const struct resource *res, 22 + resource_size_t start, 23 + resource_size_t size, 24 + resource_size_t align) = NULL; 20 25 21 26 /* 22 27 * We can't use pci_get_device() here since we are ··· 461 456 sys->busnr = busnr; 462 457 sys->swizzle = hw->swizzle; 463 458 sys->map_irq = hw->map_irq; 464 - sys->align_resource = hw->align_resource; 459 + align_resource = hw->align_resource; 465 460 INIT_LIST_HEAD(&sys->resources); 466 461 467 462 if (hw->private_data) ··· 577 572 resource_size_t size, resource_size_t align) 578 573 { 579 574 struct pci_dev *dev = data; 580 - struct pci_sys_data *sys = dev->sysdata; 581 575 resource_size_t start = res->start; 582 576 583 577 if (res->flags & IORESOURCE_IO && start & 0x300) ··· 584 580 585 581 start = (start + align - 1) & ~(align - 1); 586 582 587 - if (sys->align_resource) 588 - return sys->align_resource(dev, res, start, size, align); 583 + if (align_resource) 584 + return align_resource(dev, res, start, size, align); 589 585 590 586 return start; 591 587 }