Skip to content

Commit b3a7238

Browse files
g00308965bjorn-helgaas
authored andcommitted
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 <[email protected]> Signed-off-by: Zhou Wang <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Acked-by: Pratyush Anand <[email protected]>
1 parent 0021d22 commit b3a7238

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

arch/arm/include/asm/mach/pci.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ struct pci_sys_data {
5252
u8 (*swizzle)(struct pci_dev *, u8 *);
5353
/* IRQ mapping */
5454
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);
6155
void *private_data; /* platform controller private data */
6256
};
6357

arch/arm/kernel/bios32.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include <asm/mach/pci.h>
1818

1919
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;
2025

2126
/*
2227
* We can't use pci_get_device() here since we are
@@ -456,7 +461,7 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
456461
sys->busnr = busnr;
457462
sys->swizzle = hw->swizzle;
458463
sys->map_irq = hw->map_irq;
459-
sys->align_resource = hw->align_resource;
464+
align_resource = hw->align_resource;
460465
INIT_LIST_HEAD(&sys->resources);
461466

462467
if (hw->private_data)
@@ -572,16 +577,15 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
572577
resource_size_t size, resource_size_t align)
573578
{
574579
struct pci_dev *dev = data;
575-
struct pci_sys_data *sys = dev->sysdata;
576580
resource_size_t start = res->start;
577581

578582
if (res->flags & IORESOURCE_IO && start & 0x300)
579583
start = (start + 0x3ff) & ~0x3ff;
580584

581585
start = (start + align - 1) & ~(align - 1);
582586

583-
if (sys->align_resource)
584-
return sys->align_resource(dev, res, start, size, align);
587+
if (align_resource)
588+
return align_resource(dev, res, start, size, align);
585589

586590
return start;
587591
}

0 commit comments

Comments
 (0)