Skip to content

Commit

Permalink
powerpc: Add MSI operations to pci_controller_ops struct
Browse files Browse the repository at this point in the history
Add MSI setup and teardown functions to pci_controller_ops.

Patch the callsites (arch_{setup,teardown}_msi_irqs) to prefer the
controller ops version if it's available.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Daniel Axtens authored and Michael Ellerman committed May 22, 2015
1 parent 81f2f7c commit e059b10
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions arch/powerpc/include/asm/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ struct pci_controller_ops {
/* Called during PCI resource reassignment */
resource_size_t (*window_alignment)(struct pci_bus *, unsigned long type);
void (*reset_secondary_bus)(struct pci_dev *dev);

#ifdef CONFIG_PCI_MSI
int (*setup_msi_irqs)(struct pci_dev *dev,
int nvec, int type);
void (*teardown_msi_irqs)(struct pci_dev *dev);
#endif
};

/*
Expand Down
18 changes: 15 additions & 3 deletions arch/powerpc/kernel/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
if (!ppc_md.setup_msi_irqs || !ppc_md.teardown_msi_irqs) {
struct pci_controller *phb = pci_bus_to_host(dev->bus);

if ((!phb->controller_ops.setup_msi_irqs ||
!phb->controller_ops.teardown_msi_irqs) &&
(!ppc_md.setup_msi_irqs || !ppc_md.teardown_msi_irqs)) {
pr_debug("msi: Platform doesn't provide MSI callbacks.\n");
return -ENOSYS;
}
Expand All @@ -24,10 +28,18 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
if (type == PCI_CAP_ID_MSI && nvec > 1)
return 1;

return ppc_md.setup_msi_irqs(dev, nvec, type);
if (phb->controller_ops.setup_msi_irqs)
return phb->controller_ops.setup_msi_irqs(dev, nvec, type);
else
return ppc_md.setup_msi_irqs(dev, nvec, type);
}

void arch_teardown_msi_irqs(struct pci_dev *dev)
{
ppc_md.teardown_msi_irqs(dev);
struct pci_controller *phb = pci_bus_to_host(dev->bus);

if (phb->controller_ops.teardown_msi_irqs)
phb->controller_ops.teardown_msi_irqs(dev);
else
ppc_md.teardown_msi_irqs(dev);
}

0 comments on commit e059b10

Please sign in to comment.