Skip to content

Commit 2145ac9

Browse files
author
Marc Zyngier
committed
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>
1 parent b2eba39 commit 2145ac9

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎include/linux/msi.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ void platform_msi_domain_free_irqs(struct device *dev);
283283
/* When an MSI domain is used as an intermediate domain */
284284
int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
285285
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);
286288
#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */
287289

288290
#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN

‎kernel/irq/msi.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,46 @@ int msi_domain_prepare_irqs(struct irq_domain *domain, struct device *dev,
266266
return ret;
267267
}
268268

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+
269309
/**
270310
* msi_domain_alloc_irqs - Allocate interrupts from a MSI interrupt domain
271311
* @domain: The domain to allocate from

0 commit comments

Comments
 (0)