Commit 9e66645d authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'irq-irqdomain-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull irq domain updates from Thomas Gleixner:
 "The real interesting irq updates:

   - Support for hierarchical irq domains:

     For complex interrupt routing scenarios where more than one
     interrupt related chip is involved we had no proper representation
     in the generic interrupt infrastructure so far.  That made people
     implement rather ugly constructs in their nested irq chip
     implementations.  The main offenders are x86 and arm/gic.

     To distangle that mess we have now hierarchical irqdomains which
     seperate the various interrupt chips and connect them via the
     hierarchical domains.  That keeps the domain specific details
     internal to the particular hierarchy level and removes the
     criss/cross referencing of chip internals.  The resulting hierarchy
     for a complex x86 system will look like this:

        vector          mapped: 74
          msi-0         mapped: 2
          dmar-ir-1     mapped: 69
            ioapic-1    mapped: 4
            ioapic-0    mapped: 20
            pci-msi-2   mapped: 45
          dmar-ir-0     mapped: 3
            ioapic-2    mapped: 1
            pci-msi-1   mapped: 2
          htirq         mapped: 0

     Neither ioapic nor pci-msi know about the dmar interrupt remapping
     between themself and the vector domain.  If interrupt remapping is
     disabled ioapic and pci-msi become direct childs of the vector
     domain.

     In hindsight we should have done that years ago, but in hindsight
     we always know better :)

   - Support for generic MSI interrupt domain handling

     We have more and more non PCI related MSI interrupts, so providing
     a generic infrastructure for this is better than having all
     affected architectures implementing their own private hacks.

   - Support for PCI-MSI interrupt domain handling, based on the generic
     MSI support.

     This part carries the pci/msi branch from Bjorn Helgaas pci tree to
     avoid a massive conflict.  The PCI/MSI parts are acked by Bjorn.

  I have two more branches on top of this.  The full conversion of x86
  to hierarchical domains and a partial conversion of arm/gic"

* 'irq-irqdomain-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (41 commits)
  genirq: Move irq_chip_write_msi_msg() helper to core
  PCI/MSI: Allow an msi_controller to be associated to an irq domain
  PCI/MSI: Provide mechanism to alloc/free MSI/MSIX interrupt from irqdomain
  PCI/MSI: Enhance core to support hierarchy irqdomain
  PCI/MSI: Move cached entry functions to irq core
  genirq: Provide default callbacks for msi_domain_ops
  genirq: Introduce msi_domain_alloc/free_irqs()
  asm-generic: Add msi.h
  genirq: Add generic msi irq domain support
  genirq: Introduce callback irq_chip.irq_write_msi_msg
  genirq: Work around __irq_set_handler vs stacked domains ordering issues
  irqdomain: Introduce helper function irq_domain_add_hierarchy()
  irqdomain: Implement a method to automatically call parent domains alloc/free
  genirq: Introduce helper irq_domain_set_info() to reduce duplicated code
  genirq: Split out flow handler typedefs into seperate header file
  genirq: Add IRQ_SET_MASK_OK_DONE to support stacked irqchip
  genirq: Introduce irq_chip.irq_compose_msi_msg() to support stacked irqchip
  genirq: Add more helper functions to support stacked irq_chip
  genirq: Introduce helper functions to support stacked irq_chip
  irqdomain: Do irq_find_mapping and set_type for hierarchy irqdomain in case OF
  ...
parents ecb50f0a 74faaf7a
...@@ -151,3 +151,74 @@ used and no descriptor gets allocated it is very important to make sure ...@@ -151,3 +151,74 @@ used and no descriptor gets allocated it is very important to make sure
that the driver using the simple domain call irq_create_mapping() that the driver using the simple domain call irq_create_mapping()
before any irq_find_mapping() since the latter will actually work before any irq_find_mapping() since the latter will actually work
for the static IRQ assignment case. for the static IRQ assignment case.
==== Hierarchy IRQ domain ====
On some architectures, there may be multiple interrupt controllers
involved in delivering an interrupt from the device to the target CPU.
Let's look at a typical interrupt delivering path on x86 platforms:
Device --> IOAPIC -> Interrupt remapping Controller -> Local APIC -> CPU
There are three interrupt controllers involved:
1) IOAPIC controller
2) Interrupt remapping controller
3) Local APIC controller
To support such a hardware topology and make software architecture match
hardware architecture, an irq_domain data structure is built for each
interrupt controller and those irq_domains are organized into hierarchy.
When building irq_domain hierarchy, the irq_domain near to the device is
child and the irq_domain near to CPU is parent. So a hierarchy structure
as below will be built for the example above.
CPU Vector irq_domain (root irq_domain to manage CPU vectors)
^
|
Interrupt Remapping irq_domain (manage irq_remapping entries)
^
|
IOAPIC irq_domain (manage IOAPIC delivery entries/pins)
There are four major interfaces to use hierarchy irq_domain:
1) irq_domain_alloc_irqs(): allocate IRQ descriptors and interrupt
controller related resources to deliver these interrupts.
2) irq_domain_free_irqs(): free IRQ descriptors and interrupt controller
related resources associated with these interrupts.
3) irq_domain_activate_irq(): activate interrupt controller hardware to
deliver the interrupt.
3) irq_domain_deactivate_irq(): deactivate interrupt controller hardware
to stop delivering the interrupt.
Following changes are needed to support hierarchy irq_domain.
1) a new field 'parent' is added to struct irq_domain; it's used to
maintain irq_domain hierarchy information.
2) a new field 'parent_data' is added to struct irq_data; it's used to
build hierarchy irq_data to match hierarchy irq_domains. The irq_data
is used to store irq_domain pointer and hardware irq number.
3) new callbacks are added to struct irq_domain_ops to support hierarchy
irq_domain operations.
With support of hierarchy irq_domain and hierarchy irq_data ready, an
irq_domain structure is built for each interrupt controller, and an
irq_data structure is allocated for each irq_domain associated with an
IRQ. Now we could go one step further to support stacked(hierarchy)
irq_chip. That is, an irq_chip is associated with each irq_data along
the hierarchy. A child irq_chip may implement a required action by
itself or by cooperating with its parent irq_chip.
With stacked irq_chip, interrupt controller driver only needs to deal
with the hardware managed by itself and may ask for services from its
parent irq_chip when needed. So we could achieve a much cleaner
software architecture.
For an interrupt controller driver to support hierarchy irq_domain, it
needs to:
1) Implement irq_domain_ops.alloc and irq_domain_ops.free
2) Optionally implement irq_domain_ops.activate and
irq_domain_ops.deactivate.
3) Optionally implement an irq_chip to manage the interrupt controller
hardware.
4) No need to implement irq_domain_ops.map and irq_domain_ops.unmap,
they are unused with hierarchy irq_domain.
Hierarchy irq_domain may also be used to support other architectures,
such as ARM, ARM64 etc.
...@@ -21,6 +21,9 @@ struct device; ...@@ -21,6 +21,9 @@ struct device;
struct hw_pci { struct hw_pci {
#ifdef CONFIG_PCI_DOMAINS #ifdef CONFIG_PCI_DOMAINS
int domain; int domain;
#endif
#ifdef CONFIG_PCI_MSI
struct msi_controller *msi_ctrl;
#endif #endif
struct pci_ops *ops; struct pci_ops *ops;
int nr_controllers; int nr_controllers;
...@@ -36,8 +39,6 @@ struct hw_pci { ...@@ -36,8 +39,6 @@ struct hw_pci {
resource_size_t start, resource_size_t start,
resource_size_t size, resource_size_t size,
resource_size_t align); resource_size_t align);
void (*add_bus)(struct pci_bus *bus);
void (*remove_bus)(struct pci_bus *bus);
}; };
/* /*
...@@ -46,6 +47,9 @@ struct hw_pci { ...@@ -46,6 +47,9 @@ struct hw_pci {
struct pci_sys_data { struct pci_sys_data {
#ifdef CONFIG_PCI_DOMAINS #ifdef CONFIG_PCI_DOMAINS
int domain; int domain;
#endif
#ifdef CONFIG_PCI_MSI
struct msi_controller *msi_ctrl;
#endif #endif
struct list_head node; struct list_head node;
int busnr; /* primary bus number */ int busnr; /* primary bus number */
...@@ -65,8 +69,6 @@ struct pci_sys_data { ...@@ -65,8 +69,6 @@ struct pci_sys_data {
resource_size_t start, resource_size_t start,
resource_size_t size, resource_size_t size,
resource_size_t align); resource_size_t align);
void (*add_bus)(struct pci_bus *bus);
void (*remove_bus)(struct pci_bus *bus);
void *private_data; /* platform controller private data */ void *private_data; /* platform controller private data */
}; };
......
...@@ -18,6 +18,15 @@ ...@@ -18,6 +18,15 @@
static int debug_pci; static int debug_pci;
#ifdef CONFIG_PCI_MSI
struct msi_controller *pcibios_msi_controller(struct pci_dev *dev)
{
struct pci_sys_data *sysdata = dev->bus->sysdata;
return sysdata->msi_ctrl;
}
#endif
/* /*
* We can't use pci_get_device() here since we are * We can't use pci_get_device() here since we are
* called from interrupt context. * called from interrupt context.
...@@ -360,20 +369,6 @@ void pcibios_fixup_bus(struct pci_bus *bus) ...@@ -360,20 +369,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
} }
EXPORT_SYMBOL(pcibios_fixup_bus); EXPORT_SYMBOL(pcibios_fixup_bus);
void pcibios_add_bus(struct pci_bus *bus)
{
struct pci_sys_data *sys = bus->sysdata;
if (sys->add_bus)
sys->add_bus(bus);
}
void pcibios_remove_bus(struct pci_bus *bus)
{
struct pci_sys_data *sys = bus->sysdata;
if (sys->remove_bus)
sys->remove_bus(bus);
}
/* /*
* Swizzle the device pin each time we cross a bridge. If a platform does * Swizzle the device pin each time we cross a bridge. If a platform does
* not provide a swizzle function, we perform the standard PCI swizzling. * not provide a swizzle function, we perform the standard PCI swizzling.
...@@ -470,13 +465,14 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, ...@@ -470,13 +465,14 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
#ifdef CONFIG_PCI_DOMAINS #ifdef CONFIG_PCI_DOMAINS
sys->domain = hw->domain; sys->domain = hw->domain;
#endif
#ifdef CONFIG_PCI_MSI
sys->msi_ctrl = hw->msi_ctrl;
#endif #endif
sys->busnr = busnr; sys->busnr = busnr;
sys->swizzle = hw->swizzle; sys->swizzle = hw->swizzle;
sys->map_irq = hw->map_irq; sys->map_irq = hw->map_irq;
sys->align_resource = hw->align_resource; sys->align_resource = hw->align_resource;
sys->add_bus = hw->add_bus;
sys->remove_bus = hw->remove_bus;
INIT_LIST_HEAD(&sys->resources); INIT_LIST_HEAD(&sys->resources);
if (hw->private_data) if (hw->private_data)
......
...@@ -126,10 +126,10 @@ static void iop13xx_msi_nop(struct irq_data *d) ...@@ -126,10 +126,10 @@ static void iop13xx_msi_nop(struct irq_data *d)
static struct irq_chip iop13xx_msi_chip = { static struct irq_chip iop13xx_msi_chip = {
.name = "PCI-MSI", .name = "PCI-MSI",
.irq_ack = iop13xx_msi_nop, .irq_ack = iop13xx_msi_nop,
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
...@@ -153,7 +153,7 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) ...@@ -153,7 +153,7 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
id = iop13xx_cpu_id(); id = iop13xx_cpu_id();
msg.data = (id << IOP13XX_MU_MIMR_CORE_SELECT) | (irq & 0x7f); msg.data = (id << IOP13XX_MU_MIMR_CORE_SELECT) | (irq & 0x7f);
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
irq_set_chip_and_handler(irq, &iop13xx_msi_chip, handle_simple_irq); irq_set_chip_and_handler(irq, &iop13xx_msi_chip, handle_simple_irq);
return 0; return 0;
......
...@@ -35,7 +35,7 @@ static int ia64_set_msi_irq_affinity(struct irq_data *idata, ...@@ -35,7 +35,7 @@ static int ia64_set_msi_irq_affinity(struct irq_data *idata,
data |= MSI_DATA_VECTOR(irq_to_vector(irq)); data |= MSI_DATA_VECTOR(irq_to_vector(irq));
msg.data = data; msg.data = data;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
cpumask_copy(idata->affinity, cpumask_of(cpu)); cpumask_copy(idata->affinity, cpumask_of(cpu));
return 0; return 0;
...@@ -71,7 +71,7 @@ int ia64_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) ...@@ -71,7 +71,7 @@ int ia64_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
MSI_DATA_DELIVERY_FIXED | MSI_DATA_DELIVERY_FIXED |
MSI_DATA_VECTOR(vector); MSI_DATA_VECTOR(vector);
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
irq_set_chip_and_handler(irq, &ia64_msi_chip, handle_edge_irq); irq_set_chip_and_handler(irq, &ia64_msi_chip, handle_edge_irq);
return 0; return 0;
...@@ -102,8 +102,8 @@ static int ia64_msi_retrigger_irq(struct irq_data *data) ...@@ -102,8 +102,8 @@ static int ia64_msi_retrigger_irq(struct irq_data *data)
*/ */
static struct irq_chip ia64_msi_chip = { static struct irq_chip ia64_msi_chip = {
.name = "PCI-MSI", .name = "PCI-MSI",
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_ack = ia64_ack_msi_irq, .irq_ack = ia64_ack_msi_irq,
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
.irq_set_affinity = ia64_set_msi_irq_affinity, .irq_set_affinity = ia64_set_msi_irq_affinity,
......
...@@ -145,7 +145,7 @@ int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry) ...@@ -145,7 +145,7 @@ int sn_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *entry)
msg.data = 0x100 + irq; msg.data = 0x100 + irq;
irq_set_msi_desc(irq, entry); irq_set_msi_desc(irq, entry);
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
irq_set_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq); irq_set_chip_and_handler(irq, &sn_msi_chip, handle_edge_irq);
return 0; return 0;
...@@ -205,7 +205,7 @@ static int sn_set_msi_irq_affinity(struct irq_data *data, ...@@ -205,7 +205,7 @@ static int sn_set_msi_irq_affinity(struct irq_data *data,
msg.address_hi = (u32)(bus_addr >> 32); msg.address_hi = (u32)(bus_addr >> 32);
msg.address_lo = (u32)(bus_addr & 0x00000000ffffffff); msg.address_lo = (u32)(bus_addr & 0x00000000ffffffff);
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
cpumask_copy(data->affinity, cpu_mask); cpumask_copy(data->affinity, cpu_mask);
return 0; return 0;
...@@ -228,8 +228,8 @@ static int sn_msi_retrigger_irq(struct irq_data *data) ...@@ -228,8 +228,8 @@ static int sn_msi_retrigger_irq(struct irq_data *data)
static struct irq_chip sn_msi_chip = { static struct irq_chip sn_msi_chip = {
.name = "PCI-MSI", .name = "PCI-MSI",
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_ack = sn_ack_msi_irq, .irq_ack = sn_ack_msi_irq,
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
.irq_set_affinity = sn_set_msi_irq_affinity, .irq_set_affinity = sn_set_msi_irq_affinity,
......
...@@ -178,7 +178,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) ...@@ -178,7 +178,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control); pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control);
irq_set_msi_desc(irq, desc); irq_set_msi_desc(irq, desc);
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
return 0; return 0;
} }
......
...@@ -217,7 +217,7 @@ static void xlp_msix_mask_ack(struct irq_data *d) ...@@ -217,7 +217,7 @@ static void xlp_msix_mask_ack(struct irq_data *d)
msixvec = nlm_irq_msixvec(d->irq); msixvec = nlm_irq_msixvec(d->irq);
link = nlm_irq_msixlink(msixvec); link = nlm_irq_msixlink(msixvec);
mask_msi_irq(d); pci_msi_mask_irq(d);
md = irq_data_get_irq_handler_data(d); md = irq_data_get_irq_handler_data(d);
/* Ack MSI on bridge */ /* Ack MSI on bridge */
...@@ -239,10 +239,10 @@ static void xlp_msix_mask_ack(struct irq_data *d) ...@@ -239,10 +239,10 @@ static void xlp_msix_mask_ack(struct irq_data *d)
static struct irq_chip xlp_msix_chip = { static struct irq_chip xlp_msix_chip = {
.name = "XLP-MSIX", .name = "XLP-MSIX",
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask_ack = xlp_msix_mask_ack, .irq_mask_ack = xlp_msix_mask_ack,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
void arch_teardown_msi_irq(unsigned int irq) void arch_teardown_msi_irq(unsigned int irq)
...@@ -345,7 +345,7 @@ static int xlp_setup_msi(uint64_t lnkbase, int node, int link, ...@@ -345,7 +345,7 @@ static int xlp_setup_msi(uint64_t lnkbase, int node, int link,
if (ret < 0) if (ret < 0)
return ret; return ret;
write_msi_msg(xirq, &msg); pci_write_msi_msg(xirq, &msg);
return 0; return 0;
} }
...@@ -446,7 +446,7 @@ static int xlp_setup_msix(uint64_t lnkbase, int node, int link, ...@@ -446,7 +446,7 @@ static int xlp_setup_msix(uint64_t lnkbase, int node, int link,
if (ret < 0) if (ret < 0)
return ret; return ret;
write_msi_msg(xirq, &msg); pci_write_msi_msg(xirq, &msg);
return 0; return 0;
} }
......
...@@ -260,7 +260,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) ...@@ -260,7 +260,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
if (ret < 0) if (ret < 0)
return ret; return ret;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
return 0; return 0;
} }
#endif #endif
......
...@@ -279,7 +279,7 @@ static int axon_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -279,7 +279,7 @@ static int axon_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
irq_set_msi_desc(virq, entry); irq_set_msi_desc(virq, entry);
msg.data = virq; msg.data = virq;
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
} }
return 0; return 0;
...@@ -301,9 +301,9 @@ static void axon_msi_teardown_msi_irqs(struct pci_dev *dev) ...@@ -301,9 +301,9 @@ static void axon_msi_teardown_msi_irqs(struct pci_dev *dev)
} }
static struct irq_chip msic_irq_chip = { static struct irq_chip msic_irq_chip = {
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_shutdown = mask_msi_irq, .irq_shutdown = pci_msi_mask_irq,
.name = "AXON-MSI", .name = "AXON-MSI",
}; };
......
...@@ -90,7 +90,7 @@ static int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -90,7 +90,7 @@ static int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
return rc; return rc;
} }
irq_set_msi_desc(virq, entry); irq_set_msi_desc(virq, entry);
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
} }
return 0; return 0;
} }
......
...@@ -476,7 +476,7 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) ...@@ -476,7 +476,7 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
irq_set_msi_desc(virq, entry); irq_set_msi_desc(virq, entry);
/* Read config space back so we can restore after reset */ /* Read config space back so we can restore after reset */
__read_msi_msg(entry, &msg); __pci_read_msi_msg(entry, &msg);
entry->msg = msg; entry->msg = msg;
} }
......
...@@ -82,8 +82,8 @@ static void fsl_msi_print_chip(struct irq_data *irqd, struct seq_file *p) ...@@ -82,8 +82,8 @@ static void fsl_msi_print_chip(struct irq_data *irqd, struct seq_file *p)
static struct irq_chip fsl_msi_chip = { static struct irq_chip fsl_msi_chip = {
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_ack = fsl_msi_end_irq, .irq_ack = fsl_msi_end_irq,
.irq_print_chip = fsl_msi_print_chip, .irq_print_chip = fsl_msi_print_chip,
}; };
...@@ -242,7 +242,7 @@ static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -242,7 +242,7 @@ static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
irq_set_msi_desc(virq, entry); irq_set_msi_desc(virq, entry);
fsl_compose_msi_msg(pdev, hwirq, &msg, msi_data); fsl_compose_msi_msg(pdev, hwirq, &msg, msi_data);
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
} }
return 0; return 0;
......
...@@ -42,7 +42,7 @@ static struct mpic *msi_mpic; ...@@ -42,7 +42,7 @@ static struct mpic *msi_mpic;
static void mpic_pasemi_msi_mask_irq(struct irq_data *data) static void mpic_pasemi_msi_mask_irq(struct irq_data *data)
{ {
pr_debug("mpic_pasemi_msi_mask_irq %d\n", data->irq); pr_debug("mpic_pasemi_msi_mask_irq %d\n", data->irq);
mask_msi_irq(data); pci_msi_mask_irq(data);
mpic_mask_irq(data); mpic_mask_irq(data);
} }
...@@ -50,7 +50,7 @@ static void mpic_pasemi_msi_unmask_irq(struct irq_data *data) ...@@ -50,7 +50,7 @@ static void mpic_pasemi_msi_unmask_irq(struct irq_data *data)
{ {
pr_debug("mpic_pasemi_msi_unmask_irq %d\n", data->irq); pr_debug("mpic_pasemi_msi_unmask_irq %d\n", data->irq);
mpic_unmask_irq(data); mpic_unmask_irq(data);
unmask_msi_irq(data); pci_msi_unmask_irq(data);
} }
static struct irq_chip mpic_pasemi_msi_chip = { static struct irq_chip mpic_pasemi_msi_chip = {
...@@ -136,7 +136,7 @@ static int pasemi_msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -136,7 +136,7 @@ static int pasemi_msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
* register to generate MSI [512...1023] * register to generate MSI [512...1023]
*/ */
msg.data = hwirq-0x200; msg.data = hwirq-0x200;
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
} }
return 0; return 0;
......
...@@ -25,14 +25,14 @@ static struct mpic *msi_mpic; ...@@ -25,14 +25,14 @@ static struct mpic *msi_mpic;
static void mpic_u3msi_mask_irq(struct irq_data *data) static void mpic_u3msi_mask_irq(struct irq_data *data)
{ {
mask_msi_irq(data); pci_msi_mask_irq(data);
mpic_mask_irq(data); mpic_mask_irq(data);
} }
static void mpic_u3msi_unmask_irq(struct irq_data *data) static void mpic_u3msi_unmask_irq(struct irq_data *data)
{ {
mpic_unmask_irq(data); mpic_unmask_irq(data);
unmask_msi_irq(data); pci_msi_unmask_irq(data);
} }
static struct irq_chip mpic_u3msi_chip = { static struct irq_chip mpic_u3msi_chip = {
...@@ -171,7 +171,7 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -171,7 +171,7 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
printk("u3msi: allocated virq 0x%x (hw 0x%x) addr 0x%lx\n", printk("u3msi: allocated virq 0x%x (hw 0x%x) addr 0x%lx\n",
virq, hwirq, (unsigned long)addr); virq, hwirq, (unsigned long)addr);
msg.data = hwirq; msg.data = hwirq;
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
hwirq++; hwirq++;
} }
......
...@@ -85,7 +85,7 @@ static int hsta_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -85,7 +85,7 @@ static int hsta_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
msi_bitmap_free_hwirqs(&ppc4xx_hsta_msi.bmp, irq, 1); msi_bitmap_free_hwirqs(&ppc4xx_hsta_msi.bmp, irq, 1);
return -EINVAL; return -EINVAL;
} }
write_msi_msg(hwirq, &msg); pci_write_msi_msg(hwirq, &msg);
} }
return 0; return 0;
......
...@@ -116,7 +116,7 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -116,7 +116,7 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
irq_set_msi_desc(virq, entry); irq_set_msi_desc(virq, entry);
msg.data = int_no; msg.data = int_no;
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
} }
return 0; return 0;
} }
......
...@@ -73,7 +73,7 @@ static unsigned int ics_opal_startup(struct irq_data *d) ...@@ -73,7 +73,7 @@ static unsigned int ics_opal_startup(struct irq_data *d)
* at that level, so we do it here by hand. * at that level, so we do it here by hand.
*/ */
if (d->msi_desc) if (d->msi_desc)
unmask_msi_irq(d); pci_msi_unmask_irq(d);
#endif #endif
/* unmask it */ /* unmask it */
......
...@@ -76,7 +76,7 @@ static unsigned int ics_rtas_startup(struct irq_data *d) ...@@ -76,7 +76,7 @@ static unsigned int ics_rtas_startup(struct irq_data *d)
* at that level, so we do it here by hand. * at that level, so we do it here by hand.
*/ */
if (d->msi_desc) if (d->msi_desc)
unmask_msi_irq(d); pci_msi_unmask_irq(d);
#endif #endif
/* unmask it */ /* unmask it */
ics_rtas_unmask_irq(d); ics_rtas_unmask_irq(d);
......
...@@ -50,8 +50,8 @@ static DEFINE_SPINLOCK(zpci_list_lock); ...@@ -50,8 +50,8 @@ static DEFINE_SPINLOCK(zpci_list_lock);
static struct irq_chip zpci_irq_chip = { static struct irq_chip zpci_irq_chip = {
.name = "zPCI", .name = "zPCI",
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
}; };
static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES); static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES);
...@@ -403,7 +403,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) ...@@ -403,7 +403,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
msg.data = hwirq; msg.data = hwirq;
msg.address_lo = zdev->msi_addr & 0xffffffff; msg.address_lo = zdev->msi_addr & 0xffffffff;
msg.address_hi = zdev->msi_addr >> 32; msg.address_hi = zdev->msi_addr >> 32;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
airq_iv_set_data(zdev->aibv, hwirq, irq); airq_iv_set_data(zdev->aibv, hwirq, irq);
hwirq++; hwirq++;
} }
...@@ -448,9 +448,9 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev) ...@@ -448,9 +448,9 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
/* Release MSI interrupts */ /* Release MSI interrupts */
list_for_each_entry(msi, &pdev->msi_list, list) { list_for_each_entry(msi, &pdev->msi_list, list) {
if (msi->msi_attrib.is_msix) if (msi->msi_attrib.is_msix)
default_msix_mask_irq(msi, 1); __pci_msix_desc_mask_irq(msi, 1);
else else
default_msi_mask_irq(msi, 1, 1); __pci_msi_desc_mask_irq(msi, 1, 1);
irq_set_msi_desc(msi->irq, NULL); irq_set_msi_desc(msi->irq, NULL);
irq_free_desc(msi->irq); irq_free_desc(msi->irq);
msi->msg.address_lo = 0; msi->msg.address_lo = 0;
......
...@@ -111,10 +111,10 @@ static void free_msi(struct pci_pbm_info *pbm, int msi_num) ...@@ -111,10 +111,10 @@ static void free_msi(struct pci_pbm_info *pbm, int msi_num)
static struct irq_chip msi_irq = { static struct irq_chip msi_irq = {
.name = "PCI-MSI", .name = "PCI-MSI",
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
/* XXX affinity XXX */ /* XXX affinity XXX */
}; };
...@@ -161,7 +161,7 @@ static int sparc64_setup_msi_irq(unsigned int *irq_p, ...@@ -161,7 +161,7 @@ static int sparc64_setup_msi_irq(unsigned int *irq_p,
msg.data = msi; msg.data = msi;
irq_set_msi_desc(*irq_p, entry); irq_set_msi_desc(*irq_p, entry);
write_msi_msg(*irq_p, &msg); pci_write_msi_msg(*irq_p, &msg);
return 0; return 0;
......
...@@ -1453,7 +1453,7 @@ static struct pci_ops tile_cfg_ops = { ...@@ -1453,7 +1453,7 @@ static struct pci_ops tile_cfg_ops = {
static unsigned int tilegx_msi_startup(struct irq_data *d) static unsigned int tilegx_msi_startup(struct irq_data *d)
{ {
if (d->msi_desc) if (d->msi_desc)
unmask_msi_irq(d); pci_msi_unmask_irq(d);
return 0; return 0;
} }
...@@ -1465,14 +1465,14 @@ static void tilegx_msi_ack(struct irq_data *d) ...@@ -1465,14 +1465,14 @@ static void tilegx_msi_ack(struct irq_data *d)
static void tilegx_msi_mask(struct irq_data *d) static void tilegx_msi_mask(struct irq_data *d)
{ {
mask_msi_irq(d); pci_msi_mask_irq(d);
__insn_mtspr(SPR_IPI_MASK_SET_K, 1UL << d->irq); __insn_mtspr(SPR_IPI_MASK_SET_K, 1UL << d->irq);
} }
static void tilegx_msi_unmask(struct irq_data *d) static void tilegx_msi_unmask(struct irq_data *d)
{ {
__insn_mtspr(SPR_IPI_MASK_RESET_K, 1UL << d->irq); __insn_mtspr(SPR_IPI_MASK_RESET_K, 1UL << d->irq);
unmask_msi_irq(d); pci_msi_unmask_irq(d);
} }
static struct irq_chip tilegx_msi_chip = { static struct irq_chip tilegx_msi_chip = {
...@@ -1590,7 +1590,7 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc) ...@@ -1590,7 +1590,7 @@ int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
msg.address_hi = msi_addr >> 32; msg.address_hi = msi_addr >> 32;
msg.address_lo = msi_addr & 0xffffffff; msg.address_lo = msi_addr & 0xffffffff;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
irq_set_chip_and_handler(irq, &tilegx_msi_chip, handle_level_irq); irq_set_chip_and_handler(irq, &tilegx_msi_chip, handle_level_irq);
irq_set_handler_data(irq, controller); irq_set_handler_data(irq, controller);
......
...@@ -172,7 +172,6 @@ struct x86_platform_ops { ...@@ -172,7 +172,6 @@ struct x86_platform_ops {
struct pci_dev; struct pci_dev;
struct msi_msg; struct msi_msg;
struct msi_desc;
struct x86_msi_ops { struct x86_msi_ops {
int (*setup_msi_irqs)(struct pci_dev *dev, int nvec, int type); int (*setup_msi_irqs)(struct pci_dev *dev, int nvec, int type);
...@@ -183,8 +182,6 @@ struct x86_msi_ops { ...@@ -183,8 +182,6 @@ struct x86_msi_ops {
void (*teardown_msi_irqs)(struct pci_dev *dev); void (*teardown_msi_irqs)(struct pci_dev *dev);
void (*restore_msi_irqs)(struct pci_dev *dev); void (*restore_msi_irqs)(struct pci_dev *dev);
int (*setup_hpet_msi)(unsigned int irq, unsigned int id); int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
u32 (*msi_mask_irq)(struct msi_desc *desc, u32 mask, u32 flag);
u32 (*msix_mask_irq)(struct msi_desc *desc, u32 flag);
}; };
struct IO_APIC_route_entry; struct IO_APIC_route_entry;
......
...@@ -3158,7 +3158,7 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force) ...@@ -3158,7 +3158,7 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
msg.address_lo |= MSI_ADDR_DEST_ID(dest); msg.address_lo |= MSI_ADDR_DEST_ID(dest);
__write_msi_msg(data->msi_desc, &msg); __pci_write_msi_msg(data->msi_desc, &msg);
return IRQ_SET_MASK_OK_NOCOPY; return IRQ_SET_MASK_OK_NOCOPY;
} }
...@@ -3169,8 +3169,8 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force) ...@@ -3169,8 +3169,8 @@ msi_set_affinity(struct irq_data *data, const struct cpumask *mask, bool force)
*/ */
static struct irq_chip msi_chip = { static struct irq_chip msi_chip = {
.name = "PCI-MSI", .name = "PCI-MSI",
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_ack = ack_apic_edge, .irq_ack = ack_apic_edge,
.irq_set_affinity = msi_set_affinity, .irq_set_affinity = msi_set_affinity,
.irq_retrigger = ioapic_retrigger_irq, .irq_retrigger = ioapic_retrigger_irq,
...@@ -3196,7 +3196,7 @@ int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, ...@@ -3196,7 +3196,7 @@ int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
* MSI message denotes a contiguous group of IRQs, written for 0th IRQ. * MSI message denotes a contiguous group of IRQs, written for 0th IRQ.
*/ */
if (!irq_offset) if (!irq_offset)
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
setup_remapped_irq(irq, irq_cfg(irq), chip); setup_remapped_irq(irq, irq_cfg(irq), chip);
......
...@@ -116,8 +116,6 @@ struct x86_msi_ops x86_msi = { ...@@ -116,8 +116,6 @@ struct x86_msi_ops x86_msi = {
.teardown_msi_irqs = default_teardown_msi_irqs, .teardown_msi_irqs = default_teardown_msi_irqs,
.restore_msi_irqs = default_restore_msi_irqs, .restore_msi_irqs = default_restore_msi_irqs,
.setup_hpet_msi = default_setup_hpet_msi, .setup_hpet_msi = default_setup_hpet_msi,
.msi_mask_irq = default_msi_mask_irq,
.msix_mask_irq = default_msix_mask_irq,
}; };
/* MSI arch specific hooks */ /* MSI arch specific hooks */
...@@ -140,14 +138,6 @@ void arch_restore_msi_irqs(struct pci_dev *dev) ...@@ -140,14 +138,6 @@ void arch_restore_msi_irqs(struct pci_dev *dev)
{ {
x86_msi.restore_msi_irqs(dev); x86_msi.restore_msi_irqs(dev);
} }
u32 arch_msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
{
return x86_msi.msi_mask_irq(desc, mask, flag);
}
u32 arch_msix_mask_irq(struct msi_desc *desc, u32 flag)
{
return x86_msi.msix_mask_irq(desc, flag);
}
#endif #endif
struct x86_io_apic_ops x86_io_apic_ops = { struct x86_io_apic_ops x86_io_apic_ops = {
......
...@@ -229,7 +229,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -229,7 +229,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
return 1; return 1;
list_for_each_entry(msidesc, &dev->msi_list, list) { list_for_each_entry(msidesc, &dev->msi_list, list) {
__read_msi_msg(msidesc, &msg); __pci_read_msi_msg(msidesc, &msg);
pirq = MSI_ADDR_EXT_DEST_ID(msg.address_hi) | pirq = MSI_ADDR_EXT_DEST_ID(msg.address_hi) |
((msg.address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff); ((msg.address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff);
if (msg.data != XEN_PIRQ_MSI_DATA || if (msg.data != XEN_PIRQ_MSI_DATA ||
...@@ -240,7 +240,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -240,7 +240,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
goto error; goto error;
} }
xen_msi_compose_msg(dev, pirq, &msg); xen_msi_compose_msg(dev, pirq, &msg);
__write_msi_msg(msidesc, &msg); __pci_write_msi_msg(msidesc, &msg);
dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq); dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq);
} else { } else {
dev_dbg(&dev->dev, dev_dbg(&dev->dev,
...@@ -394,14 +394,7 @@ static void xen_teardown_msi_irq(unsigned int irq) ...@@ -394,14 +394,7 @@ static void xen_teardown_msi_irq(unsigned int irq)
{ {
xen_destroy_irq(irq); xen_destroy_irq(irq);
} }
static u32 xen_nop_msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
{
return 0;
}
static u32 xen_nop_msix_mask_irq(struct msi_desc *desc, u32 flag)
{
return 0;
}
#endif #endif
int __init pci_xen_init(void) int __init pci_xen_init(void)
...@@ -425,8 +418,7 @@ int __init pci_xen_init(void) ...@@ -425,8 +418,7 @@ int __init pci_xen_init(void)
x86_msi.setup_msi_irqs = xen_setup_msi_irqs; x86_msi.setup_msi_irqs = xen_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq; x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs; x86_msi.teardown_msi_irqs = xen_teardown_msi_irqs;
x86_msi.msi_mask_irq = xen_nop_msi_mask_irq; pci_msi_ignore_mask = 1;
x86_msi.msix_mask_irq = xen_nop_msix_mask_irq;
#endif #endif
return 0; return 0;
} }
...@@ -506,8 +498,7 @@ int __init pci_xen_initial_domain(void) ...@@ -506,8 +498,7 @@ int __init pci_xen_initial_domain(void)
x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs; x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq; x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs; x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs;
x86_msi.msi_mask_irq = xen_nop_msi_mask_irq; pci_msi_ignore_mask = 1;
x86_msi.msix_mask_irq = xen_nop_msix_mask_irq;
#endif #endif
xen_setup_acpi_sci(); xen_setup_acpi_sci();
__acpi_register_gsi = acpi_register_gsi_xen; __acpi_register_gsi = acpi_register_gsi_xen;
......
...@@ -56,19 +56,13 @@ static int do_setup_msi_irqs(struct pci_dev *dev, int nvec) ...@@ -56,19 +56,13 @@ static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
unsigned int irq; unsigned int irq;
struct msi_desc *msidesc; struct msi_desc *msidesc;
WARN_ON(!list_is_singular(&dev->msi_list));
msidesc = list_entry(dev->msi_list.next, struct msi_desc, list); msidesc = list_entry(dev->msi_list.next, struct msi_desc, list);
WARN_ON(msidesc->irq);
WARN_ON(msidesc->msi_attrib.multiple);
WARN_ON(msidesc->nvec_used);
irq = irq_alloc_hwirqs(nvec, dev_to_node(&dev->dev)); irq = irq_alloc_hwirqs(nvec, dev_to_node(&dev->dev));
if (irq == 0) if (irq == 0)
return -ENOSPC; return -ENOSPC;
nvec_pow2 = __roundup_pow_of_two(nvec); nvec_pow2 = __roundup_pow_of_two(nvec);
msidesc->nvec_used = nvec;
msidesc->msi_attrib.multiple = ilog2(nvec_pow2);
for (sub_handle = 0; sub_handle < nvec; sub_handle++) { for (sub_handle = 0; sub_handle < nvec; sub_handle++) {
if (!sub_handle) { if (!sub_handle) {
index = msi_alloc_remapped_irq(dev, irq, nvec_pow2); index = msi_alloc_remapped_irq(dev, irq, nvec_pow2);
...@@ -96,8 +90,6 @@ static int do_setup_msi_irqs(struct pci_dev *dev, int nvec) ...@@ -96,8 +90,6 @@ static int do_setup_msi_irqs(struct pci_dev *dev, int nvec)
* IRQs from tearing down again in default_teardown_msi_irqs() * IRQs from tearing down again in default_teardown_msi_irqs()
*/ */
msidesc->irq = 0; msidesc->irq = 0;
msidesc->nvec_used = 0;
msidesc->msi_attrib.multiple = 0;
return ret; return ret;
} }
......
...@@ -132,7 +132,7 @@ static void armada_370_xp_free_msi(int hwirq) ...@@ -132,7 +132,7 @@ static void armada_370_xp_free_msi(int hwirq)
mutex_unlock(&msi_used_lock); mutex_unlock(&msi_used_lock);
} }
static int armada_370_xp_setup_msi_irq(struct msi_chip *chip, static int armada_370_xp_setup_msi_irq(struct msi_controller *chip,
struct pci_dev *pdev, struct pci_dev *pdev,
struct msi_desc *desc) struct msi_desc *desc)
{ {
...@@ -159,11 +159,11 @@ static int armada_370_xp_setup_msi_irq(struct msi_chip *chip, ...@@ -159,11 +159,11 @@ static int armada_370_xp_setup_msi_irq(struct msi_chip *chip,
msg.address_hi = 0; msg.address_hi = 0;
msg.data = 0xf00 | (hwirq + 16); msg.data = 0xf00 | (hwirq + 16);
write_msi_msg(virq, &msg); pci_write_msi_msg(virq, &msg);
return 0; return 0;
} }
static void armada_370_xp_teardown_msi_irq(struct msi_chip *chip, static void armada_370_xp_teardown_msi_irq(struct msi_controller *chip,
unsigned int irq) unsigned int irq)
{ {
struct irq_data *d = irq_get_irq_data(irq); struct irq_data *d = irq_get_irq_data(irq);
...@@ -175,10 +175,10 @@ static void armada_370_xp_teardown_msi_irq(struct msi_chip *chip, ...@@ -175,10 +175,10 @@ static void armada_370_xp_teardown_msi_irq(struct msi_chip *chip,
static struct irq_chip armada_370_xp_msi_irq_chip = { static struct irq_chip armada_370_xp_msi_irq_chip = {
.name = "armada_370_xp_msi_irq", .name = "armada_370_xp_msi_irq",
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
static int armada_370_xp_msi_map(struct irq_domain *domain, unsigned int virq, static int armada_370_xp_msi_map(struct irq_domain *domain, unsigned int virq,
...@@ -198,7 +198,7 @@ static const struct irq_domain_ops armada_370_xp_msi_irq_ops = { ...@@ -198,7 +198,7 @@ static const struct irq_domain_ops armada_370_xp_msi_irq_ops = {
static int armada_370_xp_msi_init(struct device_node *node, static int armada_370_xp_msi_init(struct device_node *node,
phys_addr_t main_int_phys_base) phys_addr_t main_int_phys_base)
{ {
struct msi_chip *msi_chip; struct msi_controller *msi_chip;
u32 reg; u32 reg;
int ret; int ret;
......
...@@ -236,7 +236,7 @@ EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources); ...@@ -236,7 +236,7 @@ EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources);
static LIST_HEAD(of_pci_msi_chip_list); static LIST_HEAD(of_pci_msi_chip_list);
static DEFINE_MUTEX(of_pci_msi_chip_mutex); static DEFINE_MUTEX(of_pci_msi_chip_mutex);
int of_pci_msi_chip_add(struct msi_chip *chip) int of_pci_msi_chip_add(struct msi_controller *chip)
{ {
if (!of_property_read_bool(chip->of_node, "msi-controller")) if (!of_property_read_bool(chip->of_node, "msi-controller"))
return -EINVAL; return -EINVAL;
...@@ -249,7 +249,7 @@ int of_pci_msi_chip_add(struct msi_chip *chip) ...@@ -249,7 +249,7 @@ int of_pci_msi_chip_add(struct msi_chip *chip)
} }
EXPORT_SYMBOL_GPL(of_pci_msi_chip_add); EXPORT_SYMBOL_GPL(of_pci_msi_chip_add);
void of_pci_msi_chip_remove(struct msi_chip *chip) void of_pci_msi_chip_remove(struct msi_controller *chip)
{ {
mutex_lock(&of_pci_msi_chip_mutex); mutex_lock(&of_pci_msi_chip_mutex);
list_del(&chip->list); list_del(&chip->list);
...@@ -257,9 +257,9 @@ void of_pci_msi_chip_remove(struct msi_chip *chip) ...@@ -257,9 +257,9 @@ void of_pci_msi_chip_remove(struct msi_chip *chip)
} }
EXPORT_SYMBOL_GPL(of_pci_msi_chip_remove); EXPORT_SYMBOL_GPL(of_pci_msi_chip_remove);
struct msi_chip *of_pci_find_msi_chip_by_node(struct device_node *of_node) struct msi_controller *of_pci_find_msi_chip_by_node(struct device_node *of_node)
{ {
struct msi_chip *c; struct msi_controller *c;
mutex_lock(&of_pci_msi_chip_mutex); mutex_lock(&of_pci_msi_chip_mutex);
list_for_each_entry(c, &of_pci_msi_chip_list, list) { list_for_each_entry(c, &of_pci_msi_chip_list, list) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
config PCI_MSI config PCI_MSI
bool "Message Signaled Interrupts (MSI and MSI-X)" bool "Message Signaled Interrupts (MSI and MSI-X)"
depends on PCI depends on PCI
select GENERIC_MSI_IRQ
help help
This allows device drivers to enable MSI (Message Signaled This allows device drivers to enable MSI (Message Signaled
Interrupts). Message Signaled Interrupts enable a device to Interrupts). Message Signaled Interrupts enable a device to
...@@ -16,6 +17,11 @@ config PCI_MSI ...@@ -16,6 +17,11 @@ config PCI_MSI
If you don't know what to do here, say Y. If you don't know what to do here, say Y.
config PCI_MSI_IRQ_DOMAIN
bool
depends on PCI_MSI
select GENERIC_MSI_IRQ_DOMAIN
config PCI_DEBUG config PCI_DEBUG
bool "PCI Debugging" bool "PCI Debugging"
depends on PCI && DEBUG_KERNEL depends on PCI && DEBUG_KERNEL
......
...@@ -155,7 +155,7 @@ static void ks_dw_pcie_msi_irq_mask(struct irq_data *d) ...@@ -155,7 +155,7 @@ static void ks_dw_pcie_msi_irq_mask(struct irq_data *d)
/* Mask the end point if PVM implemented */ /* Mask the end point if PVM implemented */
if (IS_ENABLED(CONFIG_PCI_MSI)) { if (IS_ENABLED(CONFIG_PCI_MSI)) {
if (msi->msi_attrib.maskbit) if (msi->msi_attrib.maskbit)
mask_msi_irq(d); pci_msi_mask_irq(d);
} }
ks_dw_pcie_msi_clear_irq(pp, offset); ks_dw_pcie_msi_clear_irq(pp, offset);
...@@ -177,7 +177,7 @@ static void ks_dw_pcie_msi_irq_unmask(struct irq_data *d) ...@@ -177,7 +177,7 @@ static void ks_dw_pcie_msi_irq_unmask(struct irq_data *d)
/* Mask the end point if PVM implemented */ /* Mask the end point if PVM implemented */
if (IS_ENABLED(CONFIG_PCI_MSI)) { if (IS_ENABLED(CONFIG_PCI_MSI)) {
if (msi->msi_attrib.maskbit) if (msi->msi_attrib.maskbit)
unmask_msi_irq(d); pci_msi_unmask_irq(d);
} }
ks_dw_pcie_msi_set_irq(pp, offset); ks_dw_pcie_msi_set_irq(pp, offset);
...@@ -205,7 +205,7 @@ const struct irq_domain_ops ks_dw_pcie_msi_domain_ops = { ...@@ -205,7 +205,7 @@ const struct irq_domain_ops ks_dw_pcie_msi_domain_ops = {
.map = ks_dw_pcie_msi_map, .map = ks_dw_pcie_msi_map,
}; };
int ks_dw_pcie_msi_host_init(struct pcie_port *pp, struct msi_chip *chip) int ks_dw_pcie_msi_host_init(struct pcie_port *pp, struct msi_controller *chip)
{ {
struct keystone_pcie *ks_pcie = to_keystone_pcie(pp); struct keystone_pcie *ks_pcie = to_keystone_pcie(pp);
int i; int i;
......
...@@ -55,4 +55,4 @@ void ks_dw_pcie_msi_set_irq(struct pcie_port *pp, int irq); ...@@ -55,4 +55,4 @@ void ks_dw_pcie_msi_set_irq(struct pcie_port *pp, int irq);
void ks_dw_pcie_msi_clear_irq(struct pcie_port *pp, int irq); void ks_dw_pcie_msi_clear_irq(struct pcie_port *pp, int irq);
void ks_dw_pcie_v3_65_scan_bus(struct pcie_port *pp); void ks_dw_pcie_v3_65_scan_bus(struct pcie_port *pp);
int ks_dw_pcie_msi_host_init(struct pcie_port *pp, int ks_dw_pcie_msi_host_init(struct pcie_port *pp,
struct msi_chip *chip); struct msi_controller *chip);
...@@ -99,7 +99,7 @@ struct mvebu_pcie_port; ...@@ -99,7 +99,7 @@ struct mvebu_pcie_port;
struct mvebu_pcie { struct mvebu_pcie {
struct platform_device *pdev; struct platform_device *pdev;
struct mvebu_pcie_port *ports; struct mvebu_pcie_port *ports;
struct msi_chip *msi; struct msi_controller *msi;
struct resource io; struct resource io;
char io_name[30]; char io_name[30];
struct resource realio; struct resource realio;
...@@ -774,12 +774,6 @@ static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys) ...@@ -774,12 +774,6 @@ static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
return bus; return bus;
} }
static void mvebu_pcie_add_bus(struct pci_bus *bus)
{
struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
bus->msi = pcie->msi;
}
static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
const struct resource *res, const struct resource *res,
resource_size_t start, resource_size_t start,
...@@ -816,6 +810,10 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) ...@@ -816,6 +810,10 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
memset(&hw, 0, sizeof(hw)); memset(&hw, 0, sizeof(hw));
#ifdef CONFIG_PCI_MSI
hw.msi_ctrl = pcie->msi;
#endif
hw.nr_controllers = 1; hw.nr_controllers = 1;
hw.private_data = (void **)&pcie; hw.private_data = (void **)&pcie;
hw.setup = mvebu_pcie_setup; hw.setup = mvebu_pcie_setup;
...@@ -823,7 +821,6 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) ...@@ -823,7 +821,6 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
hw.map_irq = of_irq_parse_and_map_pci; hw.map_irq = of_irq_parse_and_map_pci;
hw.ops = &mvebu_pcie_ops; hw.ops = &mvebu_pcie_ops;
hw.align_resource = mvebu_pcie_align_resource; hw.align_resource = mvebu_pcie_align_resource;
hw.add_bus = mvebu_pcie_add_bus;
pci_common_init(&hw); pci_common_init(&hw);
} }
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
) )
struct tegra_msi { struct tegra_msi {
struct msi_chip chip; struct msi_controller chip;
DECLARE_BITMAP(used, INT_PCI_MSI_NR); DECLARE_BITMAP(used, INT_PCI_MSI_NR);
struct irq_domain *domain; struct irq_domain *domain;
unsigned long pages; unsigned long pages;
...@@ -259,7 +259,7 @@ struct tegra_pcie_soc_data { ...@@ -259,7 +259,7 @@ struct tegra_pcie_soc_data {
bool has_gen2; bool has_gen2;
}; };
static inline struct tegra_msi *to_tegra_msi(struct msi_chip *chip) static inline struct tegra_msi *to_tegra_msi(struct msi_controller *chip)
{ {
return container_of(chip, struct tegra_msi, chip); return container_of(chip, struct tegra_msi, chip);
} }
...@@ -692,15 +692,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) ...@@ -692,15 +692,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
return irq; return irq;
} }
static void tegra_pcie_add_bus(struct pci_bus *bus)
{
if (IS_ENABLED(CONFIG_PCI_MSI)) {
struct tegra_pcie *pcie = sys_to_pcie(bus->sysdata);
bus->msi = &pcie->msi.chip;
}
}
static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys) static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
{ {
struct tegra_pcie *pcie = sys_to_pcie(sys); struct tegra_pcie *pcie = sys_to_pcie(sys);
...@@ -1280,8 +1271,8 @@ static irqreturn_t tegra_pcie_msi_irq(int irq, void *data) ...@@ -1280,8 +1271,8 @@ static irqreturn_t tegra_pcie_msi_irq(int irq, void *data)
return processed > 0 ? IRQ_HANDLED : IRQ_NONE; return processed > 0 ? IRQ_HANDLED : IRQ_NONE;
} }
static int tegra_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, static int tegra_msi_setup_irq(struct msi_controller *chip,
struct msi_desc *desc) struct pci_dev *pdev, struct msi_desc *desc)
{ {
struct tegra_msi *msi = to_tegra_msi(chip); struct tegra_msi *msi = to_tegra_msi(chip);
struct msi_msg msg; struct msi_msg msg;
...@@ -1305,12 +1296,13 @@ static int tegra_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, ...@@ -1305,12 +1296,13 @@ static int tegra_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
msg.address_hi = 0; msg.address_hi = 0;
msg.data = hwirq; msg.data = hwirq;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
return 0; return 0;
} }
static void tegra_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) static void tegra_msi_teardown_irq(struct msi_controller *chip,
unsigned int irq)
{ {
struct tegra_msi *msi = to_tegra_msi(chip); struct tegra_msi *msi = to_tegra_msi(chip);
struct irq_data *d = irq_get_irq_data(irq); struct irq_data *d = irq_get_irq_data(irq);
...@@ -1322,10 +1314,10 @@ static void tegra_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) ...@@ -1322,10 +1314,10 @@ static void tegra_msi_teardown_irq(struct msi_chip *chip, unsigned int irq)
static struct irq_chip tegra_msi_irq_chip = { static struct irq_chip tegra_msi_irq_chip = {
.name = "Tegra PCIe MSI", .name = "Tegra PCIe MSI",
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
static int tegra_msi_map(struct irq_domain *domain, unsigned int irq, static int tegra_msi_map(struct irq_domain *domain, unsigned int irq,
...@@ -1893,11 +1885,14 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie) ...@@ -1893,11 +1885,14 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
memset(&hw, 0, sizeof(hw)); memset(&hw, 0, sizeof(hw));
#ifdef CONFIG_PCI_MSI
hw.msi_ctrl = &pcie->msi.chip;
#endif
hw.nr_controllers = 1; hw.nr_controllers = 1;
hw.private_data = (void **)&pcie; hw.private_data = (void **)&pcie;
hw.setup = tegra_pcie_setup; hw.setup = tegra_pcie_setup;
hw.map_irq = tegra_pcie_map_irq; hw.map_irq = tegra_pcie_map_irq;
hw.add_bus = tegra_pcie_add_bus;
hw.scan = tegra_pcie_scan_bus; hw.scan = tegra_pcie_scan_bus;
hw.ops = &tegra_pcie_ops; hw.ops = &tegra_pcie_ops;
......
...@@ -152,10 +152,10 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size, ...@@ -152,10 +152,10 @@ static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
static struct irq_chip dw_msi_irq_chip = { static struct irq_chip dw_msi_irq_chip = {
.name = "PCI-MSI", .name = "PCI-MSI",
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
/* MSI int handler */ /* MSI int handler */
...@@ -276,7 +276,7 @@ static int assign_irq(int no_irqs, struct msi_desc *desc, int *pos) ...@@ -276,7 +276,7 @@ static int assign_irq(int no_irqs, struct msi_desc *desc, int *pos)
return -ENOSPC; return -ENOSPC;
} }
static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, static int dw_msi_setup_irq(struct msi_controller *chip, struct pci_dev *pdev,
struct msi_desc *desc) struct msi_desc *desc)
{ {
int irq, pos; int irq, pos;
...@@ -298,12 +298,12 @@ static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, ...@@ -298,12 +298,12 @@ static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
else else
msg.data = pos; msg.data = pos;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
return 0; return 0;
} }
static void dw_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) static void dw_msi_teardown_irq(struct msi_controller *chip, unsigned int irq)
{ {
struct irq_data *data = irq_get_irq_data(irq); struct irq_data *data = irq_get_irq_data(irq);
struct msi_desc *msi = irq_data_get_msi(data); struct msi_desc *msi = irq_data_get_msi(data);
...@@ -312,7 +312,7 @@ static void dw_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) ...@@ -312,7 +312,7 @@ static void dw_msi_teardown_irq(struct msi_chip *chip, unsigned int irq)
clear_irq_range(pp, irq, 1, data->hwirq); clear_irq_range(pp, irq, 1, data->hwirq);
} }
static struct msi_chip dw_pcie_msi_chip = { static struct msi_controller dw_pcie_msi_chip = {
.setup_irq = dw_msi_setup_irq, .setup_irq = dw_msi_setup_irq,
.teardown_irq = dw_msi_teardown_irq, .teardown_irq = dw_msi_teardown_irq,
}; };
...@@ -498,6 +498,11 @@ int __init dw_pcie_host_init(struct pcie_port *pp) ...@@ -498,6 +498,11 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
val |= PORT_LOGIC_SPEED_CHANGE; val |= PORT_LOGIC_SPEED_CHANGE;
dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val); dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
#ifdef CONFIG_PCI_MSI
dw_pcie_msi_chip.dev = pp->dev;
dw_pci.msi_ctrl = &dw_pcie_msi_chip;
#endif
dw_pci.nr_controllers = 1; dw_pci.nr_controllers = 1;
dw_pci.private_data = (void **)&pp; dw_pci.private_data = (void **)&pp;
...@@ -747,21 +752,10 @@ static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) ...@@ -747,21 +752,10 @@ static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
return irq; return irq;
} }
static void dw_pcie_add_bus(struct pci_bus *bus)
{
if (IS_ENABLED(CONFIG_PCI_MSI)) {
struct pcie_port *pp = sys_to_pcie(bus->sysdata);
dw_pcie_msi_chip.dev = pp->dev;
bus->msi = &dw_pcie_msi_chip;
}
}
static struct hw_pci dw_pci = { static struct hw_pci dw_pci = {
.setup = dw_pcie_setup, .setup = dw_pcie_setup,
.scan = dw_pcie_scan_bus, .scan = dw_pcie_scan_bus,
.map_irq = dw_pcie_map_irq, .map_irq = dw_pcie_map_irq,
.add_bus = dw_pcie_add_bus,
}; };
void dw_pcie_setup_rc(struct pcie_port *pp) void dw_pcie_setup_rc(struct pcie_port *pp)
......
...@@ -73,7 +73,7 @@ struct pcie_host_ops { ...@@ -73,7 +73,7 @@ struct pcie_host_ops {
u32 (*get_msi_addr)(struct pcie_port *pp); u32 (*get_msi_addr)(struct pcie_port *pp);
u32 (*get_msi_data)(struct pcie_port *pp, int pos); u32 (*get_msi_data)(struct pcie_port *pp, int pos);
void (*scan_bus)(struct pcie_port *pp); void (*scan_bus)(struct pcie_port *pp);
int (*msi_host_init)(struct pcie_port *pp, struct msi_chip *chip); int (*msi_host_init)(struct pcie_port *pp, struct msi_controller *chip);
}; };
int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val); int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val);
......
...@@ -111,14 +111,14 @@ ...@@ -111,14 +111,14 @@
struct rcar_msi { struct rcar_msi {
DECLARE_BITMAP(used, INT_PCI_MSI_NR); DECLARE_BITMAP(used, INT_PCI_MSI_NR);
struct irq_domain *domain; struct irq_domain *domain;
struct msi_chip chip; struct msi_controller chip;
unsigned long pages; unsigned long pages;
struct mutex lock; struct mutex lock;
int irq1; int irq1;
int irq2; int irq2;
}; };
static inline struct rcar_msi *to_rcar_msi(struct msi_chip *chip) static inline struct rcar_msi *to_rcar_msi(struct msi_controller *chip)
{ {
return container_of(chip, struct rcar_msi, chip); return container_of(chip, struct rcar_msi, chip);
} }
...@@ -380,20 +380,10 @@ static int rcar_pcie_setup(int nr, struct pci_sys_data *sys) ...@@ -380,20 +380,10 @@ static int rcar_pcie_setup(int nr, struct pci_sys_data *sys)
return 1; return 1;
} }
static void rcar_pcie_add_bus(struct pci_bus *bus)
{
if (IS_ENABLED(CONFIG_PCI_MSI)) {
struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
bus->msi = &pcie->msi.chip;
}
}
struct hw_pci rcar_pci = { struct hw_pci rcar_pci = {
.setup = rcar_pcie_setup, .setup = rcar_pcie_setup,
.map_irq = of_irq_parse_and_map_pci, .map_irq = of_irq_parse_and_map_pci,
.ops = &rcar_pcie_ops, .ops = &rcar_pcie_ops,
.add_bus = rcar_pcie_add_bus,
}; };
static void rcar_pcie_enable(struct rcar_pcie *pcie) static void rcar_pcie_enable(struct rcar_pcie *pcie)
...@@ -402,6 +392,9 @@ static void rcar_pcie_enable(struct rcar_pcie *pcie) ...@@ -402,6 +392,9 @@ static void rcar_pcie_enable(struct rcar_pcie *pcie)
rcar_pci.nr_controllers = 1; rcar_pci.nr_controllers = 1;
rcar_pci.private_data = (void **)&pcie; rcar_pci.private_data = (void **)&pcie;
#ifdef CONFIG_PCI_MSI
rcar_pci.msi_ctrl = &pcie->msi.chip;
#endif
pci_common_init_dev(&pdev->dev, &rcar_pci); pci_common_init_dev(&pdev->dev, &rcar_pci);
#ifdef CONFIG_PCI_DOMAINS #ifdef CONFIG_PCI_DOMAINS
...@@ -622,7 +615,7 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data) ...@@ -622,7 +615,7 @@ static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int rcar_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, static int rcar_msi_setup_irq(struct msi_controller *chip, struct pci_dev *pdev,
struct msi_desc *desc) struct msi_desc *desc)
{ {
struct rcar_msi *msi = to_rcar_msi(chip); struct rcar_msi *msi = to_rcar_msi(chip);
...@@ -647,12 +640,12 @@ static int rcar_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, ...@@ -647,12 +640,12 @@ static int rcar_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
msg.address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR); msg.address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR);
msg.data = hwirq; msg.data = hwirq;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
return 0; return 0;
} }
static void rcar_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) static void rcar_msi_teardown_irq(struct msi_controller *chip, unsigned int irq)
{ {
struct rcar_msi *msi = to_rcar_msi(chip); struct rcar_msi *msi = to_rcar_msi(chip);
struct irq_data *d = irq_get_irq_data(irq); struct irq_data *d = irq_get_irq_data(irq);
...@@ -662,10 +655,10 @@ static void rcar_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) ...@@ -662,10 +655,10 @@ static void rcar_msi_teardown_irq(struct msi_chip *chip, unsigned int irq)
static struct irq_chip rcar_msi_irq_chip = { static struct irq_chip rcar_msi_irq_chip = {
.name = "R-Car PCIe MSI", .name = "R-Car PCIe MSI",
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
static int rcar_msi_map(struct irq_domain *domain, unsigned int irq, static int rcar_msi_map(struct irq_domain *domain, unsigned int irq,
......
...@@ -335,7 +335,8 @@ static int xilinx_pcie_assign_msi(struct xilinx_pcie_port *port) ...@@ -335,7 +335,8 @@ static int xilinx_pcie_assign_msi(struct xilinx_pcie_port *port)
* @chip: MSI Chip descriptor * @chip: MSI Chip descriptor
* @irq: MSI IRQ to destroy * @irq: MSI IRQ to destroy
*/ */
static void xilinx_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) static void xilinx_msi_teardown_irq(struct msi_controller *chip,
unsigned int irq)
{ {
xilinx_pcie_destroy_msi(irq); xilinx_pcie_destroy_msi(irq);
} }
...@@ -348,7 +349,7 @@ static void xilinx_msi_teardown_irq(struct msi_chip *chip, unsigned int irq) ...@@ -348,7 +349,7 @@ static void xilinx_msi_teardown_irq(struct msi_chip *chip, unsigned int irq)
* *
* Return: '0' on success and error value on failure * Return: '0' on success and error value on failure
*/ */
static int xilinx_pcie_msi_setup_irq(struct msi_chip *chip, static int xilinx_pcie_msi_setup_irq(struct msi_controller *chip,
struct pci_dev *pdev, struct pci_dev *pdev,
struct msi_desc *desc) struct msi_desc *desc)
{ {
...@@ -374,13 +375,13 @@ static int xilinx_pcie_msi_setup_irq(struct msi_chip *chip, ...@@ -374,13 +375,13 @@ static int xilinx_pcie_msi_setup_irq(struct msi_chip *chip,
msg.address_lo = msg_addr; msg.address_lo = msg_addr;
msg.data = irq; msg.data = irq;
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
return 0; return 0;
} }
/* MSI Chip Descriptor */ /* MSI Chip Descriptor */
static struct msi_chip xilinx_pcie_msi_chip = { static struct msi_controller xilinx_pcie_msi_chip = {
.setup_irq = xilinx_pcie_msi_setup_irq, .setup_irq = xilinx_pcie_msi_setup_irq,
.teardown_irq = xilinx_msi_teardown_irq, .teardown_irq = xilinx_msi_teardown_irq,
}; };
...@@ -388,10 +389,10 @@ static struct msi_chip xilinx_pcie_msi_chip = { ...@@ -388,10 +389,10 @@ static struct msi_chip xilinx_pcie_msi_chip = {
/* HW Interrupt Chip Descriptor */ /* HW Interrupt Chip Descriptor */
static struct irq_chip xilinx_msi_irq_chip = { static struct irq_chip xilinx_msi_irq_chip = {
.name = "Xilinx PCIe MSI", .name = "Xilinx PCIe MSI",
.irq_enable = unmask_msi_irq, .irq_enable = pci_msi_unmask_irq,
.irq_disable = mask_msi_irq, .irq_disable = pci_msi_mask_irq,
.irq_mask = mask_msi_irq, .irq_mask = pci_msi_mask_irq,
.irq_unmask = unmask_msi_irq, .irq_unmask = pci_msi_unmask_irq,
}; };
/** /**
...@@ -431,20 +432,6 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port) ...@@ -431,20 +432,6 @@ static void xilinx_pcie_enable_msi(struct xilinx_pcie_port *port)
pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2); pcie_write(port, msg_addr, XILINX_PCIE_REG_MSIBASE2);
} }
/**
* xilinx_pcie_add_bus - Add MSI chip info to PCIe bus
* @bus: PCIe bus
*/
static void xilinx_pcie_add_bus(struct pci_bus *bus)
{
if (IS_ENABLED(CONFIG_PCI_MSI)) {
struct xilinx_pcie_port *port = sys_to_pcie(bus->sysdata);
xilinx_pcie_msi_chip.dev = port->dev;
bus->msi = &xilinx_pcie_msi_chip;
}
}
/* INTx Functions */ /* INTx Functions */
/** /**
...@@ -924,10 +911,14 @@ static int xilinx_pcie_probe(struct platform_device *pdev) ...@@ -924,10 +911,14 @@ static int xilinx_pcie_probe(struct platform_device *pdev)
.private_data = (void **)&port, .private_data = (void **)&port,
.setup = xilinx_pcie_setup, .setup = xilinx_pcie_setup,
.map_irq = of_irq_parse_and_map_pci, .map_irq = of_irq_parse_and_map_pci,
.add_bus = xilinx_pcie_add_bus,
.scan = xilinx_pcie_scan_bus, .scan = xilinx_pcie_scan_bus,
.ops = &xilinx_pcie_ops, .ops = &xilinx_pcie_ops,
}; };
#ifdef CONFIG_PCI_MSI
xilinx_pcie_msi_chip.dev = port->dev;
hw.msi_ctrl = &xilinx_pcie_msi_chip;
#endif
pci_common_init_dev(dev, &hw); pci_common_init_dev(dev, &hw);
return 0; return 0;
......
This diff is collapsed.
...@@ -560,7 +560,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, ...@@ -560,7 +560,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
struct msi_msg msg; struct msi_msg msg;
get_cached_msi_msg(irq, &msg); get_cached_msi_msg(irq, &msg);
write_msi_msg(irq, &msg); pci_write_msi_msg(irq, &msg);
} }
ret = request_irq(irq, vfio_msihandler, 0, ret = request_irq(irq, vfio_msihandler, 0,
......
#ifndef __ASM_GENERIC_MSI_H
#define __ASM_GENERIC_MSI_H
#include <linux/types.h>
#ifndef NUM_MSI_ALLOC_SCRATCHPAD_REGS
# define NUM_MSI_ALLOC_SCRATCHPAD_REGS 2
#endif
struct msi_desc;
/**
* struct msi_alloc_info - Default structure for MSI interrupt allocation.
* @desc: Pointer to msi descriptor
* @hwirq: Associated hw interrupt number in the domain
* @scratchpad: Storage for implementation specific scratch data
*
* Architectures can provide their own implementation by not including
* asm-generic/msi.h into their arch specific header file.
*/
typedef struct msi_alloc_info {
struct msi_desc *desc;
irq_hw_number_t hwirq;
union {
unsigned long ul;
void *ptr;
} scratchpad[NUM_MSI_ALLOC_SCRATCHPAD_REGS];
} msi_alloc_info_t;
#define GENERIC_MSI_DOMAIN_OPS 1
#endif
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/irqhandler.h>
#include <linux/irqreturn.h> #include <linux/irqreturn.h>
#include <linux/irqnr.h> #include <linux/irqnr.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -28,11 +29,7 @@ ...@@ -28,11 +29,7 @@
struct seq_file; struct seq_file;
struct module; struct module;
struct irq_desc; struct msi_msg;
struct irq_data;
typedef void (*irq_flow_handler_t)(unsigned int irq,
struct irq_desc *desc);
typedef void (*irq_preflow_handler_t)(struct irq_data *data);
/* /*
* IRQ line status. * IRQ line status.
...@@ -114,10 +111,14 @@ enum { ...@@ -114,10 +111,14 @@ enum {
* *
* IRQ_SET_MASK_OK - OK, core updates irq_data.affinity * IRQ_SET_MASK_OK - OK, core updates irq_data.affinity
* IRQ_SET_MASK_NOCPY - OK, chip did update irq_data.affinity * IRQ_SET_MASK_NOCPY - OK, chip did update irq_data.affinity
* IRQ_SET_MASK_OK_DONE - Same as IRQ_SET_MASK_OK for core. Special code to
* support stacked irqchips, which indicates skipping
* all descendent irqchips.
*/ */
enum { enum {
IRQ_SET_MASK_OK = 0, IRQ_SET_MASK_OK = 0,
IRQ_SET_MASK_OK_NOCOPY, IRQ_SET_MASK_OK_NOCOPY,
IRQ_SET_MASK_OK_DONE,
}; };
struct msi_desc; struct msi_desc;
...@@ -134,6 +135,8 @@ struct irq_domain; ...@@ -134,6 +135,8 @@ struct irq_domain;
* @chip: low level interrupt hardware access * @chip: low level interrupt hardware access
* @domain: Interrupt translation domain; responsible for mapping * @domain: Interrupt translation domain; responsible for mapping
* between hwirq number and linux irq number. * between hwirq number and linux irq number.
* @parent_data: pointer to parent struct irq_data to support hierarchy
* irq_domain
* @handler_data: per-IRQ data for the irq_chip methods * @handler_data: per-IRQ data for the irq_chip methods
* @chip_data: platform-specific per-chip private data for the chip * @chip_data: platform-specific per-chip private data for the chip
* methods, to allow shared chip implementations * methods, to allow shared chip implementations
...@@ -152,6 +155,9 @@ struct irq_data { ...@@ -152,6 +155,9 @@ struct irq_data {
unsigned int state_use_accessors; unsigned int state_use_accessors;
struct irq_chip *chip; struct irq_chip *chip;
struct irq_domain *domain; struct irq_domain *domain;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
struct irq_data *parent_data;
#endif
void *handler_data; void *handler_data;
void *chip_data; void *chip_data;
struct msi_desc *msi_desc; struct msi_desc *msi_desc;
...@@ -316,6 +322,8 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) ...@@ -316,6 +322,8 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
* any other callback related to this irq * any other callback related to this irq
* @irq_release_resources: optional to release resources acquired with * @irq_release_resources: optional to release resources acquired with
* irq_request_resources * irq_request_resources
* @irq_compose_msi_msg: optional to compose message content for MSI
* @irq_write_msi_msg: optional to write message content for MSI
* @flags: chip specific flags * @flags: chip specific flags
*/ */
struct irq_chip { struct irq_chip {
...@@ -352,6 +360,9 @@ struct irq_chip { ...@@ -352,6 +360,9 @@ struct irq_chip {
int (*irq_request_resources)(struct irq_data *data); int (*irq_request_resources)(struct irq_data *data);
void (*irq_release_resources)(struct irq_data *data); void (*irq_release_resources)(struct irq_data *data);
void (*irq_compose_msi_msg)(struct irq_data *data, struct msi_msg *msg);
void (*irq_write_msi_msg)(struct irq_data *data, struct msi_msg *msg);
unsigned long flags; unsigned long flags;
}; };
...@@ -439,6 +450,18 @@ extern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc); ...@@ -439,6 +450,18 @@ extern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc); extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
extern void handle_nested_irq(unsigned int irq); extern void handle_nested_irq(unsigned int irq);
extern int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg);
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
extern void irq_chip_ack_parent(struct irq_data *data);
extern int irq_chip_retrigger_hierarchy(struct irq_data *data);
extern void irq_chip_mask_parent(struct irq_data *data);
extern void irq_chip_unmask_parent(struct irq_data *data);
extern void irq_chip_eoi_parent(struct irq_data *data);
extern int irq_chip_set_affinity_parent(struct irq_data *data,
const struct cpumask *dest,
bool force);
#endif
/* Handling of unhandled and spurious interrupts: */ /* Handling of unhandled and spurious interrupts: */
extern void note_interrupt(unsigned int irq, struct irq_desc *desc, extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
irqreturn_t action_ret); irqreturn_t action_ret);
......
...@@ -33,11 +33,14 @@ ...@@ -33,11 +33,14 @@
#define _LINUX_IRQDOMAIN_H #define _LINUX_IRQDOMAIN_H
#include <linux/types.h> #include <linux/types.h>
#include <linux/irqhandler.h>
#include <linux/radix-tree.h> #include <linux/radix-tree.h>
struct device_node; struct device_node;
struct irq_domain; struct irq_domain;
struct of_device_id; struct of_device_id;
struct irq_chip;
struct irq_data;
/* Number of irqs reserved for a legacy isa controller */ /* Number of irqs reserved for a legacy isa controller */
#define NUM_ISA_INTERRUPTS 16 #define NUM_ISA_INTERRUPTS 16
...@@ -64,6 +67,16 @@ struct irq_domain_ops { ...@@ -64,6 +67,16 @@ struct irq_domain_ops {
int (*xlate)(struct irq_domain *d, struct device_node *node, int (*xlate)(struct irq_domain *d, struct device_node *node,
const u32 *intspec, unsigned int intsize, const u32 *intspec, unsigned int intsize,
unsigned long *out_hwirq, unsigned int *out_type); unsigned long *out_hwirq, unsigned int *out_type);
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
/* extended V2 interfaces to support hierarchy irq_domains */
int (*alloc)(struct irq_domain *d, unsigned int virq,
unsigned int nr_irqs, void *arg);
void (*free)(struct irq_domain *d, unsigned int virq,
unsigned int nr_irqs);
void (*activate)(struct irq_domain *d, struct irq_data *irq_data);
void (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
#endif
}; };
extern struct irq_domain_ops irq_generic_chip_ops; extern struct irq_domain_ops irq_generic_chip_ops;
...@@ -77,6 +90,7 @@ struct irq_domain_chip_generic; ...@@ -77,6 +90,7 @@ struct irq_domain_chip_generic;
* @ops: pointer to irq_domain methods * @ops: pointer to irq_domain methods
* @host_data: private data pointer for use by owner. Not touched by irq_domain * @host_data: private data pointer for use by owner. Not touched by irq_domain
* core code. * core code.
* @flags: host per irq_domain flags
* *
* Optional elements * Optional elements
* @of_node: Pointer to device tree nodes associated with the irq_domain. Used * @of_node: Pointer to device tree nodes associated with the irq_domain. Used
...@@ -84,6 +98,7 @@ struct irq_domain_chip_generic; ...@@ -84,6 +98,7 @@ struct irq_domain_chip_generic;
* @gc: Pointer to a list of generic chips. There is a helper function for * @gc: Pointer to a list of generic chips. There is a helper function for
* setting up one or more generic chips for interrupt controllers * setting up one or more generic chips for interrupt controllers
* drivers using the generic chip library which uses this pointer. * drivers using the generic chip library which uses this pointer.
* @parent: Pointer to parent irq_domain to support hierarchy irq_domains
* *
* Revmap data, used internally by irq_domain * Revmap data, used internally by irq_domain
* @revmap_direct_max_irq: The largest hwirq that can be set for controllers that * @revmap_direct_max_irq: The largest hwirq that can be set for controllers that
...@@ -97,10 +112,14 @@ struct irq_domain { ...@@ -97,10 +112,14 @@ struct irq_domain {
const char *name; const char *name;
const struct irq_domain_ops *ops; const struct irq_domain_ops *ops;
void *host_data; void *host_data;
unsigned int flags;
/* Optional data */ /* Optional data */
struct device_node *of_node; struct device_node *of_node;
struct irq_domain_chip_generic *gc; struct irq_domain_chip_generic *gc;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
struct irq_domain *parent;
#endif
/* reverse map data. The linear map gets appended to the irq_domain */ /* reverse map data. The linear map gets appended to the irq_domain */
irq_hw_number_t hwirq_max; irq_hw_number_t hwirq_max;
...@@ -110,6 +129,22 @@ struct irq_domain { ...@@ -110,6 +129,22 @@ struct irq_domain {
unsigned int linear_revmap[]; unsigned int linear_revmap[];
}; };
/* Irq domain flags */
enum {
/* Irq domain is hierarchical */
IRQ_DOMAIN_FLAG_HIERARCHY = (1 << 0),
/* Core calls alloc/free recursive through the domain hierarchy. */
IRQ_DOMAIN_FLAG_AUTO_RECURSIVE = (1 << 1),
/*
* Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved
* for implementation specific purposes and ignored by the
* core code.
*/
IRQ_DOMAIN_FLAG_NONCORE = (1 << 16),
};
#ifdef CONFIG_IRQ_DOMAIN #ifdef CONFIG_IRQ_DOMAIN
struct irq_domain *__irq_domain_add(struct device_node *of_node, int size, struct irq_domain *__irq_domain_add(struct device_node *of_node, int size,
irq_hw_number_t hwirq_max, int direct_max, irq_hw_number_t hwirq_max, int direct_max,
...@@ -220,8 +255,74 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr, ...@@ -220,8 +255,74 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
const u32 *intspec, unsigned int intsize, const u32 *intspec, unsigned int intsize,
irq_hw_number_t *out_hwirq, unsigned int *out_type); irq_hw_number_t *out_hwirq, unsigned int *out_type);
/* V2 interfaces to support hierarchy IRQ domains. */
extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
unsigned int virq);
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
extern struct irq_domain *irq_domain_add_hierarchy(struct irq_domain *parent,
unsigned int flags, unsigned int size,
struct device_node *node,
const struct irq_domain_ops *ops, void *host_data);
extern int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
unsigned int nr_irqs, int node, void *arg,
bool realloc);
extern void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs);
extern void irq_domain_activate_irq(struct irq_data *irq_data);
extern void irq_domain_deactivate_irq(struct irq_data *irq_data);
static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
unsigned int nr_irqs, int node, void *arg)
{
return __irq_domain_alloc_irqs(domain, -1, nr_irqs, node, arg, false);
}
extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
unsigned int virq,
irq_hw_number_t hwirq,
struct irq_chip *chip,
void *chip_data);
extern void irq_domain_set_info(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq, struct irq_chip *chip,
void *chip_data, irq_flow_handler_t handler,
void *handler_data, const char *handler_name);
extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
extern void irq_domain_free_irqs_common(struct irq_domain *domain,
unsigned int virq,
unsigned int nr_irqs);
extern void irq_domain_free_irqs_top(struct irq_domain *domain,
unsigned int virq, unsigned int nr_irqs);
extern int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
unsigned int irq_base,
unsigned int nr_irqs, void *arg);
extern void irq_domain_free_irqs_parent(struct irq_domain *domain,
unsigned int irq_base,
unsigned int nr_irqs);
static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
{
return domain->flags & IRQ_DOMAIN_FLAG_HIERARCHY;
}
#else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
static inline void irq_domain_activate_irq(struct irq_data *data) { }
static inline void irq_domain_deactivate_irq(struct irq_data *data) { }
static inline int irq_domain_alloc_irqs(struct irq_domain *domain,
unsigned int nr_irqs, int node, void *arg)
{
return -1;
}
static inline bool irq_domain_is_hierarchy(struct irq_domain *domain)
{
return false;
}
#endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
#else /* CONFIG_IRQ_DOMAIN */ #else /* CONFIG_IRQ_DOMAIN */
static inline void irq_dispose_mapping(unsigned int virq) { } static inline void irq_dispose_mapping(unsigned int virq) { }
static inline void irq_domain_activate_irq(struct irq_data *data) { }
static inline void irq_domain_deactivate_irq(struct irq_data *data) { }
#endif /* !CONFIG_IRQ_DOMAIN */ #endif /* !CONFIG_IRQ_DOMAIN */
#endif /* _LINUX_IRQDOMAIN_H */ #endif /* _LINUX_IRQDOMAIN_H */
#ifndef _LINUX_IRQHANDLER_H
#define _LINUX_IRQHANDLER_H
/*
* Interrupt flow handler typedefs are defined here to avoid circular
* include dependencies.
*/
struct irq_desc;
struct irq_data;
typedef void (*irq_flow_handler_t)(unsigned int irq, struct irq_desc *desc);
typedef void (*irq_preflow_handler_t)(struct irq_data *data);
#endif
...@@ -10,17 +10,12 @@ struct msi_msg { ...@@ -10,17 +10,12 @@ struct msi_msg {
u32 data; /* 16 bits of msi message data */ u32 data; /* 16 bits of msi message data */
}; };
extern int pci_msi_ignore_mask;
/* Helper functions */ /* Helper functions */
struct irq_data; struct irq_data;
struct msi_desc; struct msi_desc;
void mask_msi_irq(struct irq_data *data);
void unmask_msi_irq(struct irq_data *data);
void __read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg); void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void read_msi_msg(unsigned int irq, struct msi_msg *msg);
void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg); void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg);
void write_msi_msg(unsigned int irq, struct msi_msg *msg);
struct msi_desc { struct msi_desc {
struct { struct {
...@@ -48,6 +43,52 @@ struct msi_desc { ...@@ -48,6 +43,52 @@ struct msi_desc {
struct msi_msg msg; struct msi_msg msg;
}; };
/* Helpers to hide struct msi_desc implementation details */
#define msi_desc_to_dev(desc) (&(desc)->dev.dev)
#define dev_to_msi_list(dev) (&to_pci_dev((dev))->msi_list)
#define first_msi_entry(dev) \
list_first_entry(dev_to_msi_list((dev)), struct msi_desc, list)
#define for_each_msi_entry(desc, dev) \
list_for_each_entry((desc), dev_to_msi_list((dev)), list)
#ifdef CONFIG_PCI_MSI
#define first_pci_msi_entry(pdev) first_msi_entry(&(pdev)->dev)
#define for_each_pci_msi_entry(desc, pdev) \
for_each_msi_entry((desc), &(pdev)->dev)
static inline struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc)
{
return desc->dev;
}
#endif /* CONFIG_PCI_MSI */
void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg);
u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag);
u32 __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag);
void pci_msi_mask_irq(struct irq_data *data);
void pci_msi_unmask_irq(struct irq_data *data);
/* Conversion helpers. Should be removed after merging */
static inline void __write_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
{
__pci_write_msi_msg(entry, msg);
}
static inline void write_msi_msg(int irq, struct msi_msg *msg)
{
pci_write_msi_msg(irq, msg);
}
static inline void mask_msi_irq(struct irq_data *data)
{
pci_msi_mask_irq(data);
}
static inline void unmask_msi_irq(struct irq_data *data)
{
pci_msi_unmask_irq(data);
}
/* /*
* The arch hooks to setup up msi irqs. Those functions are * The arch hooks to setup up msi irqs. Those functions are
* implemented as weak symbols so that they /can/ be overriden by * implemented as weak symbols so that they /can/ be overriden by
...@@ -61,18 +102,142 @@ void arch_restore_msi_irqs(struct pci_dev *dev); ...@@ -61,18 +102,142 @@ void arch_restore_msi_irqs(struct pci_dev *dev);
void default_teardown_msi_irqs(struct pci_dev *dev); void default_teardown_msi_irqs(struct pci_dev *dev);
void default_restore_msi_irqs(struct pci_dev *dev); void default_restore_msi_irqs(struct pci_dev *dev);
u32 default_msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag);
u32 default_msix_mask_irq(struct msi_desc *desc, u32 flag);
struct msi_chip { struct msi_controller {
struct module *owner; struct module *owner;
struct device *dev; struct device *dev;
struct device_node *of_node; struct device_node *of_node;
struct list_head list; struct list_head list;
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
struct irq_domain *domain;
#endif
int (*setup_irq)(struct msi_chip *chip, struct pci_dev *dev, int (*setup_irq)(struct msi_controller *chip, struct pci_dev *dev,
struct msi_desc *desc);
void (*teardown_irq)(struct msi_controller *chip, unsigned int irq);
};
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
#include <linux/irqhandler.h>
#include <asm/msi.h>
struct irq_domain;
struct irq_chip;
struct device_node;
struct msi_domain_info;
/**
* struct msi_domain_ops - MSI interrupt domain callbacks
* @get_hwirq: Retrieve the resulting hw irq number
* @msi_init: Domain specific init function for MSI interrupts
* @msi_free: Domain specific function to free a MSI interrupts
* @msi_check: Callback for verification of the domain/info/dev data
* @msi_prepare: Prepare the allocation of the interrupts in the domain
* @msi_finish: Optional callbacl to finalize the allocation
* @set_desc: Set the msi descriptor for an interrupt
* @handle_error: Optional error handler if the allocation fails
*
* @get_hwirq, @msi_init and @msi_free are callbacks used by
* msi_create_irq_domain() and related interfaces
*
* @msi_check, @msi_prepare, @msi_finish, @set_desc and @handle_error
* are callbacks used by msi_irq_domain_alloc_irqs() and related
* interfaces which are based on msi_desc.
*/
struct msi_domain_ops {
irq_hw_number_t (*get_hwirq)(struct msi_domain_info *info,
msi_alloc_info_t *arg);
int (*msi_init)(struct irq_domain *domain,
struct msi_domain_info *info,
unsigned int virq, irq_hw_number_t hwirq,
msi_alloc_info_t *arg);
void (*msi_free)(struct irq_domain *domain,
struct msi_domain_info *info,
unsigned int virq);
int (*msi_check)(struct irq_domain *domain,
struct msi_domain_info *info,
struct device *dev);
int (*msi_prepare)(struct irq_domain *domain,
struct device *dev, int nvec,
msi_alloc_info_t *arg);
void (*msi_finish)(msi_alloc_info_t *arg, int retval);
void (*set_desc)(msi_alloc_info_t *arg,
struct msi_desc *desc); struct msi_desc *desc);
void (*teardown_irq)(struct msi_chip *chip, unsigned int irq); int (*handle_error)(struct irq_domain *domain,
struct msi_desc *desc, int error);
}; };
/**
* struct msi_domain_info - MSI interrupt domain data
* @flags: Flags to decribe features and capabilities
* @ops: The callback data structure
* @chip: Optional: associated interrupt chip
* @chip_data: Optional: associated interrupt chip data
* @handler: Optional: associated interrupt flow handler
* @handler_data: Optional: associated interrupt flow handler data
* @handler_name: Optional: associated interrupt flow handler name
* @data: Optional: domain specific data
*/
struct msi_domain_info {
u32 flags;
struct msi_domain_ops *ops;
struct irq_chip *chip;
void *chip_data;
irq_flow_handler_t handler;
void *handler_data;
const char *handler_name;
void *data;
};
/* Flags for msi_domain_info */
enum {
/*
* Init non implemented ops callbacks with default MSI domain
* callbacks.
*/
MSI_FLAG_USE_DEF_DOM_OPS = (1 << 0),
/*
* Init non implemented chip callbacks with default MSI chip
* callbacks.
*/
MSI_FLAG_USE_DEF_CHIP_OPS = (1 << 1),
/* Build identity map between hwirq and irq */
MSI_FLAG_IDENTITY_MAP = (1 << 2),
/* Support multiple PCI MSI interrupts */
MSI_FLAG_MULTI_PCI_MSI = (1 << 3),
/* Support PCI MSIX interrupts */
MSI_FLAG_PCI_MSIX = (1 << 4),
};
int msi_domain_set_affinity(struct irq_data *data, const struct cpumask *mask,
bool force);
struct irq_domain *msi_create_irq_domain(struct device_node *of_node,
struct msi_domain_info *info,
struct irq_domain *parent);
int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
int nvec);
void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev);
struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain);
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
void pci_msi_domain_write_msg(struct irq_data *irq_data, struct msi_msg *msg);
struct irq_domain *pci_msi_create_irq_domain(struct device_node *node,
struct msi_domain_info *info,
struct irq_domain *parent);
int pci_msi_domain_alloc_irqs(struct irq_domain *domain, struct pci_dev *dev,
int nvec, int type);
void pci_msi_domain_free_irqs(struct irq_domain *domain, struct pci_dev *dev);
struct irq_domain *pci_msi_create_default_irq_domain(struct device_node *node,
struct msi_domain_info *info, struct irq_domain *parent);
irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
struct msi_desc *desc);
int pci_msi_domain_check_cap(struct irq_domain *domain,
struct msi_domain_info *info, struct device *dev);
#endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */
#endif /* LINUX_MSI_H */ #endif /* LINUX_MSI_H */
...@@ -59,13 +59,13 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, ...@@ -59,13 +59,13 @@ int of_pci_get_host_bridge_resources(struct device_node *dev,
#endif #endif
#if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI) #if defined(CONFIG_OF) && defined(CONFIG_PCI_MSI)
int of_pci_msi_chip_add(struct msi_chip *chip); int of_pci_msi_chip_add(struct msi_controller *chip);
void of_pci_msi_chip_remove(struct msi_chip *chip); void of_pci_msi_chip_remove(struct msi_controller *chip);
struct msi_chip *of_pci_find_msi_chip_by_node(struct device_node *of_node); struct msi_controller *of_pci_find_msi_chip_by_node(struct device_node *of_node);
#else #else
static inline int of_pci_msi_chip_add(struct msi_chip *chip) { return -EINVAL; } static inline int of_pci_msi_chip_add(struct msi_controller *chip) { return -EINVAL; }
static inline void of_pci_msi_chip_remove(struct msi_chip *chip) { } static inline void of_pci_msi_chip_remove(struct msi_controller *chip) { }
static inline struct msi_chip * static inline struct msi_controller *
of_pci_find_msi_chip_by_node(struct device_node *of_node) { return NULL; } of_pci_find_msi_chip_by_node(struct device_node *of_node) { return NULL; }
#endif #endif
......
...@@ -450,7 +450,7 @@ struct pci_bus { ...@@ -450,7 +450,7 @@ struct pci_bus {
struct resource busn_res; /* bus numbers routed to this bus */ struct resource busn_res; /* bus numbers routed to this bus */
struct pci_ops *ops; /* configuration access functions */ struct pci_ops *ops; /* configuration access functions */
struct msi_chip *msi; /* MSI controller */ struct msi_controller *msi; /* MSI controller */
void *sysdata; /* hook for sys-specific extension */ void *sysdata; /* hook for sys-specific extension */
struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
......
...@@ -55,6 +55,21 @@ config GENERIC_IRQ_CHIP ...@@ -55,6 +55,21 @@ config GENERIC_IRQ_CHIP
config IRQ_DOMAIN config IRQ_DOMAIN
bool bool
# Support for hierarchical irq domains
config IRQ_DOMAIN_HIERARCHY
bool
select IRQ_DOMAIN
# Generic MSI interrupt support
config GENERIC_MSI_IRQ
bool
# Generic MSI hierarchical interrupt domain support
config GENERIC_MSI_IRQ_DOMAIN
bool
select IRQ_DOMAIN_HIERARCHY
select GENERIC_MSI_IRQ
config HANDLE_DOMAIN_IRQ config HANDLE_DOMAIN_IRQ
bool bool
......
...@@ -6,3 +6,4 @@ obj-$(CONFIG_IRQ_DOMAIN) += irqdomain.o ...@@ -6,3 +6,4 @@ obj-$(CONFIG_IRQ_DOMAIN) += irqdomain.o
obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o
obj-$(CONFIG_PM_SLEEP) += pm.o obj-$(CONFIG_PM_SLEEP) += pm.o
obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/kernel_stat.h> #include <linux/kernel_stat.h>
#include <linux/irqdomain.h>
#include <trace/events/irq.h> #include <trace/events/irq.h>
...@@ -178,6 +179,7 @@ int irq_startup(struct irq_desc *desc, bool resend) ...@@ -178,6 +179,7 @@ int irq_startup(struct irq_desc *desc, bool resend)
irq_state_clr_disabled(desc); irq_state_clr_disabled(desc);
desc->depth = 0; desc->depth = 0;
irq_domain_activate_irq(&desc->irq_data);
if (desc->irq_data.chip->irq_startup) { if (desc->irq_data.chip->irq_startup) {
ret = desc->irq_data.chip->irq_startup(&desc->irq_data); ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
irq_state_clr_masked(desc); irq_state_clr_masked(desc);
...@@ -199,6 +201,7 @@ void irq_shutdown(struct irq_desc *desc) ...@@ -199,6 +201,7 @@ void irq_shutdown(struct irq_desc *desc)
desc->irq_data.chip->irq_disable(&desc->irq_data); desc->irq_data.chip->irq_disable(&desc->irq_data);
else else
desc->irq_data.chip->irq_mask(&desc->irq_data); desc->irq_data.chip->irq_mask(&desc->irq_data);
irq_domain_deactivate_irq(&desc->irq_data);
irq_state_set_masked(desc); irq_state_set_masked(desc);
} }
...@@ -728,7 +731,30 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, ...@@ -728,7 +731,30 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
if (!handle) { if (!handle) {
handle = handle_bad_irq; handle = handle_bad_irq;
} else { } else {
if (WARN_ON(desc->irq_data.chip == &no_irq_chip)) struct irq_data *irq_data = &desc->irq_data;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
/*
* With hierarchical domains we might run into a
* situation where the outermost chip is not yet set
* up, but the inner chips are there. Instead of
* bailing we install the handler, but obviously we
* cannot enable/startup the interrupt at this point.
*/
while (irq_data) {
if (irq_data->chip != &no_irq_chip)
break;
/*
* Bail out if the outer chip is not set up
* and the interrrupt supposed to be started
* right away.
*/
if (WARN_ON(is_chained))
goto out;
/* Try the parent */
irq_data = irq_data->parent_data;
}
#endif
if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip))
goto out; goto out;
} }
...@@ -847,3 +873,105 @@ void irq_cpu_offline(void) ...@@ -847,3 +873,105 @@ void irq_cpu_offline(void)
raw_spin_unlock_irqrestore(&desc->lock, flags); raw_spin_unlock_irqrestore(&desc->lock, flags);
} }
} }
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
/**
* irq_chip_ack_parent - Acknowledge the parent interrupt
* @data: Pointer to interrupt specific data
*/
void irq_chip_ack_parent(struct irq_data *data)
{
data = data->parent_data;
data->chip->irq_ack(data);
}
/**
* irq_chip_mask_parent - Mask the parent interrupt
* @data: Pointer to interrupt specific data
*/
void irq_chip_mask_parent(struct irq_data *data)
{
data = data->parent_data;
data->chip->irq_mask(data);
}
/**
* irq_chip_unmask_parent - Unmask the parent interrupt
* @data: Pointer to interrupt specific data
*/
void irq_chip_unmask_parent(struct irq_data *data)
{
data = data->parent_data;
data->chip->irq_unmask(data);
}
/**
* irq_chip_eoi_parent - Invoke EOI on the parent interrupt
* @data: Pointer to interrupt specific data
*/
void irq_chip_eoi_parent(struct irq_data *data)
{
data = data->parent_data;
data->chip->irq_eoi(data);
}
/**
* irq_chip_set_affinity_parent - Set affinity on the parent interrupt
* @data: Pointer to interrupt specific data
* @dest: The affinity mask to set
* @force: Flag to enforce setting (disable online checks)
*
* Conditinal, as the underlying parent chip might not implement it.
*/
int irq_chip_set_affinity_parent(struct irq_data *data,
const struct cpumask *dest, bool force)
{
data = data->parent_data;
if (data->chip->irq_set_affinity)
return data->chip->irq_set_affinity(data, dest, force);
return -ENOSYS;
}
/**
* irq_chip_retrigger_hierarchy - Retrigger an interrupt in hardware
* @data: Pointer to interrupt specific data
*
* Iterate through the domain hierarchy of the interrupt and check
* whether a hw retrigger function exists. If yes, invoke it.
*/
int irq_chip_retrigger_hierarchy(struct irq_data *data)
{
for (data = data->parent_data; data; data = data->parent_data)
if (data->chip && data->chip->irq_retrigger)
return data->chip->irq_retrigger(data);
return -ENOSYS;
}
#endif
/**
* irq_chip_compose_msi_msg - Componse msi message for a irq chip
* @data: Pointer to interrupt specific data
* @msg: Pointer to the MSI message
*
* For hierarchical domains we find the first chip in the hierarchy
* which implements the irq_compose_msi_msg callback. For non
* hierarchical we use the top level chip.
*/
int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
{
struct irq_data *pos = NULL;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
for (; data; data = data->parent_data)
#endif
if (data->chip && data->chip->irq_compose_msi_msg)
pos = data;
if (!pos)
return -ENOSYS;
pos->chip->irq_compose_msi_msg(pos, msg);
return 0;
}
This diff is collapsed.
...@@ -183,6 +183,7 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask, ...@@ -183,6 +183,7 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
ret = chip->irq_set_affinity(data, mask, force); ret = chip->irq_set_affinity(data, mask, force);
switch (ret) { switch (ret) {
case IRQ_SET_MASK_OK: case IRQ_SET_MASK_OK:
case IRQ_SET_MASK_OK_DONE:
cpumask_copy(data->affinity, mask); cpumask_copy(data->affinity, mask);
case IRQ_SET_MASK_OK_NOCOPY: case IRQ_SET_MASK_OK_NOCOPY:
irq_set_thread_affinity(desc); irq_set_thread_affinity(desc);
...@@ -600,6 +601,7 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq, ...@@ -600,6 +601,7 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
switch (ret) { switch (ret) {
case IRQ_SET_MASK_OK: case IRQ_SET_MASK_OK:
case IRQ_SET_MASK_OK_DONE:
irqd_clear(&desc->irq_data, IRQD_TRIGGER_MASK); irqd_clear(&desc->irq_data, IRQD_TRIGGER_MASK);
irqd_set(&desc->irq_data, flags); irqd_set(&desc->irq_data, flags);
......
/*
* linux/kernel/irq/msi.c
*
* Copyright (C) 2014 Intel Corp.
* Author: Jiang Liu <jiang.liu@linux.intel.com>
*
* This file is licensed under GPLv2.
*
* This file contains common code to support Message Signalled Interrupt for
* PCI compatible and non PCI compatible devices.
*/
#include <linux/types.h>
#include <linux/device.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/msi.h>
/* Temparory solution for building, will be removed later */
#include <linux/pci.h>
void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
{
*msg = entry->msg;
}
void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg)
{
struct msi_desc *entry = irq_get_msi_desc(irq);
__get_cached_msi_msg(entry, msg);
}
EXPORT_SYMBOL_GPL(get_cached_msi_msg);
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
static inline void irq_chip_write_msi_msg(struct irq_data *data,
struct msi_msg *msg)
{
data->chip->irq_write_msi_msg(data, msg);
}
/**
* msi_domain_set_affinity - Generic affinity setter function for MSI domains
* @irq_data: The irq data associated to the interrupt
* @mask: The affinity mask to set
* @force: Flag to enforce setting (disable online checks)
*
* Intended to be used by MSI interrupt controllers which are
* implemented with hierarchical domains.
*/
int msi_domain_set_affinity(struct irq_data *irq_data,
const struct cpumask *mask, bool force)
{
struct irq_data *parent = irq_data->parent_data;
struct msi_msg msg;
int ret;
ret = parent->chip->irq_set_affinity(parent, mask, force);
if (ret >= 0 && ret != IRQ_SET_MASK_OK_DONE) {
BUG_ON(irq_chip_compose_msi_msg(irq_data, &msg));
irq_chip_write_msi_msg(irq_data, &msg);
}
return ret;
}
static void msi_domain_activate(struct irq_domain *domain,
struct irq_data *irq_data)
{
struct msi_msg msg;
BUG_ON(irq_chip_compose_msi_msg(irq_data, &msg));
irq_chip_write_msi_msg(irq_data, &msg);
}
static void msi_domain_deactivate(struct irq_domain *domain,
struct irq_data *irq_data)
{
struct msi_msg msg;
memset(&msg, 0, sizeof(msg));
irq_chip_write_msi_msg(irq_data, &msg);
}
static int msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *arg)
{
struct msi_domain_info *info = domain->host_data;
struct msi_domain_ops *ops = info->ops;
irq_hw_number_t hwirq = ops->get_hwirq(info, arg);
int i, ret;
if (irq_find_mapping(domain, hwirq) > 0)
return -EEXIST;
ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg);
if (ret < 0)
return ret;
for (i = 0; i < nr_irqs; i++) {
ret = ops->msi_init(domain, info, virq + i, hwirq + i, arg);
if (ret < 0) {
if (ops->msi_free) {
for (i--; i > 0; i--)
ops->msi_free(domain, info, virq + i);
}
irq_domain_free_irqs_top(domain, virq, nr_irqs);
return ret;
}
}
return 0;
}
static void msi_domain_free(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs)
{
struct msi_domain_info *info = domain->host_data;
int i;
if (info->ops->msi_free) {
for (i = 0; i < nr_irqs; i++)
info->ops->msi_free(domain, info, virq + i);
}
irq_domain_free_irqs_top(domain, virq, nr_irqs);
}
static struct irq_domain_ops msi_domain_ops = {
.alloc = msi_domain_alloc,
.free = msi_domain_free,
.activate = msi_domain_activate,
.deactivate = msi_domain_deactivate,
};
#ifdef GENERIC_MSI_DOMAIN_OPS
static irq_hw_number_t msi_domain_ops_get_hwirq(struct msi_domain_info *info,
msi_alloc_info_t *arg)
{
return arg->hwirq;
}
static int msi_domain_ops_prepare(struct irq_domain *domain, struct device *dev,
int nvec, msi_alloc_info_t *arg)
{
memset(arg, 0, sizeof(*arg));
return 0;
}
static void msi_domain_ops_set_desc(msi_alloc_info_t *arg,
struct msi_desc *desc)
{
arg->desc = desc;
}
#else
#define msi_domain_ops_get_hwirq NULL
#define msi_domain_ops_prepare NULL
#define msi_domain_ops_set_desc NULL
#endif /* !GENERIC_MSI_DOMAIN_OPS */
static int msi_domain_ops_init(struct irq_domain *domain,
struct msi_domain_info *info,
unsigned int virq, irq_hw_number_t hwirq,
msi_alloc_info_t *arg)
{
irq_domain_set_hwirq_and_chip(domain, virq, hwirq, info->chip,
info->chip_data);
if (info->handler && info->handler_name) {
__irq_set_handler(virq, info->handler, 0, info->handler_name);
if (info->handler_data)
irq_set_handler_data(virq, info->handler_data);
}
return 0;
}
static int msi_domain_ops_check(struct irq_domain *domain,
struct msi_domain_info *info,
struct device *dev)
{
return 0;
}
static struct msi_domain_ops msi_domain_ops_default = {
.get_hwirq = msi_domain_ops_get_hwirq,
.msi_init = msi_domain_ops_init,
.msi_check = msi_domain_ops_check,
.msi_prepare = msi_domain_ops_prepare,
.set_desc = msi_domain_ops_set_desc,
};
static void msi_domain_update_dom_ops(struct msi_domain_info *info)
{
struct msi_domain_ops *ops = info->ops;
if (ops == NULL) {
info->ops = &msi_domain_ops_default;
return;
}
if (ops->get_hwirq == NULL)
ops->get_hwirq = msi_domain_ops_default.get_hwirq;
if (ops->msi_init == NULL)
ops->msi_init = msi_domain_ops_default.msi_init;
if (ops->msi_check == NULL)
ops->msi_check = msi_domain_ops_default.msi_check;
if (ops->msi_prepare == NULL)
ops->msi_prepare = msi_domain_ops_default.msi_prepare;
if (ops->set_desc == NULL)
ops->set_desc = msi_domain_ops_default.set_desc;
}
static void msi_domain_update_chip_ops(struct msi_domain_info *info)
{
struct irq_chip *chip = info->chip;
BUG_ON(!chip);
if (!chip->irq_mask)
chip->irq_mask = pci_msi_mask_irq;
if (!chip->irq_unmask)
chip->irq_unmask = pci_msi_unmask_irq;
if (!chip->irq_set_affinity)
chip->irq_set_affinity = msi_domain_set_affinity;
}
/**
* msi_create_irq_domain - Create a MSI interrupt domain
* @of_node: Optional device-tree node of the interrupt controller
* @info: MSI domain info
* @parent: Parent irq domain
*/
struct irq_domain *msi_create_irq_domain(struct device_node *node,
struct msi_domain_info *info,
struct irq_domain *parent)
{
if (info->flags & MSI_FLAG_USE_DEF_DOM_OPS)
msi_domain_update_dom_ops(info);
if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS)
msi_domain_update_chip_ops(info);
return irq_domain_add_hierarchy(parent, 0, 0, node, &msi_domain_ops,
info);
}
/**
* msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
* @domain: The domain to allocate from
* @dev: Pointer to device struct of the device for which the interrupts
* are allocated
* @nvec: The number of interrupts to allocate
*
* Returns 0 on success or an error code.
*/
int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
int nvec)
{
struct msi_domain_info *info = domain->host_data;
struct msi_domain_ops *ops = info->ops;
msi_alloc_info_t arg;
struct msi_desc *desc;
int i, ret, virq = -1;
ret = ops->msi_check(domain, info, dev);
if (ret == 0)
ret = ops->msi_prepare(domain, dev, nvec, &arg);
if (ret)
return ret;
for_each_msi_entry(desc, dev) {
ops->set_desc(&arg, desc);
if (info->flags & MSI_FLAG_IDENTITY_MAP)
virq = (int)ops->get_hwirq(info, &arg);
else
virq = -1;
virq = __irq_domain_alloc_irqs(domain, virq, desc->nvec_used,
dev_to_node(dev), &arg, false);
if (virq < 0) {
ret = -ENOSPC;
if (ops->handle_error)
ret = ops->handle_error(domain, desc, ret);
if (ops->msi_finish)
ops->msi_finish(&arg, ret);
return ret;
}
for (i = 0; i < desc->nvec_used; i++)
irq_set_msi_desc_off(virq, i, desc);
}
if (ops->msi_finish)
ops->msi_finish(&arg, 0);
for_each_msi_entry(desc, dev) {
if (desc->nvec_used == 1)
dev_dbg(dev, "irq %d for MSI\n", virq);
else
dev_dbg(dev, "irq [%d-%d] for MSI\n",
virq, virq + desc->nvec_used - 1);
}
return 0;
}
/**
* msi_domain_free_irqs - Free interrupts from a MSI interrupt @domain associated tp @dev
* @domain: The domain to managing the interrupts
* @dev: Pointer to device struct of the device for which the interrupts
* are free
*/
void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)
{
struct msi_desc *desc;
for_each_msi_entry(desc, dev) {
irq_domain_free_irqs(desc->irq, desc->nvec_used);
desc->irq = 0;
}
}
/**
* msi_get_domain_info - Get the MSI interrupt domain info for @domain
* @domain: The interrupt domain to retrieve data from
*
* Returns the pointer to the msi_domain_info stored in
* @domain->host_data.
*/
struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain)
{
return (struct msi_domain_info *)domain->host_data;
}
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment