diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2015-11-23 03:26:06 -0500 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2015-12-16 10:29:44 -0500 |
commit | 2145ac9310b60c1c11294b7bea10fe154009be1d (patch) | |
tree | 8f38f1ae3609004675fbfd55a721d3969f67e670 | |
parent | b2eba39bcab9d60a6c3b80c7fc2f3dacb77eeaae (diff) |
genirq/msi: Add msi_domain_populate_irqs
To be able to allocate interrupts from the MSI layer down,
add a new msi_domain_populate_irqs entry point.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | include/linux/msi.h | 2 | ||||
-rw-r--r-- | kernel/irq/msi.c | 40 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/linux/msi.h b/include/linux/msi.h index 1c0bb2c0b211..cee102b1916d 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h | |||
@@ -283,6 +283,8 @@ void platform_msi_domain_free_irqs(struct device *dev); | |||
283 | /* When an MSI domain is used as an intermediate domain */ | 283 | /* When an MSI domain is used as an intermediate domain */ |
284 | int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev, | 284 | int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev, |
285 | int nvec, msi_alloc_info_t *args); | 285 | int nvec, msi_alloc_info_t *args); |
286 | int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, | ||
287 | int virq, int nvec, msi_alloc_info_t *args); | ||
286 | #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ | 288 | #endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ |
287 | 289 | ||
288 | #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN | 290 | #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN |
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 9a85613d4227..15b249e7c673 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c | |||
@@ -266,6 +266,46 @@ int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev, | |||
266 | return ret; | 266 | return ret; |
267 | } | 267 | } |
268 | 268 | ||
269 | int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, | ||
270 | int virq, int nvec, msi_alloc_info_t *arg) | ||
271 | { | ||
272 | struct msi_domain_info *info = domain->host_data; | ||
273 | struct msi_domain_ops *ops = info->ops; | ||
274 | struct msi_desc *desc; | ||
275 | int ret = 0; | ||
276 | |||
277 | for_each_msi_entry(desc, dev) { | ||
278 | /* Don't even try the multi-MSI brain damage. */ | ||
279 | if (WARN_ON(!desc->irq || desc->nvec_used != 1)) { | ||
280 | ret = -EINVAL; | ||
281 | break; | ||
282 | } | ||
283 | |||
284 | if (!(desc->irq >= virq && desc->irq < (virq + nvec))) | ||
285 | continue; | ||
286 | |||
287 | ops->set_desc(arg, desc); | ||
288 | /* Assumes the domain mutex is held! */ | ||
289 | ret = irq_domain_alloc_irqs_recursive(domain, virq, 1, arg); | ||
290 | if (ret) | ||
291 | break; | ||
292 | |||
293 | irq_set_msi_desc_off(virq, 0, desc); | ||
294 | } | ||
295 | |||
296 | if (ret) { | ||
297 | /* Mop up the damage */ | ||
298 | for_each_msi_entry(desc, dev) { | ||
299 | if (!(desc->irq >= virq && desc->irq < (virq + nvec))) | ||
300 | continue; | ||
301 | |||
302 | irq_domain_free_irqs_common(domain, desc->irq, 1); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | return ret; | ||
307 | } | ||
308 | |||
269 | /** | 309 | /** |
270 | * msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain | 310 | * msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain |
271 | * @domain: The domain to allocate from | 311 | * @domain: The domain to allocate from |