@@ -1441,40 +1441,12 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
1441
1441
return domain->ops->alloc(domain, irq_base, nr_irqs, arg);
1442
1442
}
1443
1443
1444
- /**
1445
- * __irq_domain_alloc_irqs - Allocate IRQs from domain
1446
- * @domain: domain to allocate from
1447
- * @irq_base: allocate specified IRQ number if irq_base >= 0
1448
- * @nr_irqs: number of IRQs to allocate
1449
- * @node: NUMA node id for memory allocation
1450
- * @arg: domain specific argument
1451
- * @realloc: IRQ descriptors have already been allocated if true
1452
- * @affinity: Optional irq affinity mask for multiqueue devices
1453
- *
1454
- * Allocate IRQ numbers and initialized all data structures to support
1455
- * hierarchy IRQ domains.
1456
- * Parameter @realloc is mainly to support legacy IRQs.
1457
- * Returns error code or allocated IRQ number
1458
- *
1459
- * The whole process to setup an IRQ has been split into two steps.
1460
- * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
1461
- * descriptor and required hardware resources. The second step,
1462
- * irq_domain_activate_irq(), is to program the hardware with preallocated
1463
- * resources. In this way, it's easier to rollback when failing to
1464
- * allocate resources.
1465
- */
1466
- int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
1467
- unsigned int nr_irqs, int node, void *arg,
1468
- bool realloc, const struct irq_affinity_desc *affinity)
1444
+ static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base,
1445
+ unsigned int nr_irqs, int node, void *arg,
1446
+ bool realloc, const struct irq_affinity_desc *affinity)
1469
1447
{
1470
1448
int i, ret, virq;
1471
1449
1472
- if (domain == NULL) {
1473
- domain = irq_default_domain;
1474
- if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
1475
- return -EINVAL;
1476
- }
1477
-
1478
1450
if (realloc && irq_base >= 0) {
1479
1451
virq = irq_base;
1480
1452
} else {
@@ -1493,24 +1465,18 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
1493
1465
goto out_free_desc;
1494
1466
}
1495
1467
1496
- mutex_lock(&irq_domain_mutex);
1497
1468
ret = irq_domain_alloc_irqs_hierarchy(domain, virq, nr_irqs, arg);
1498
- if (ret < 0) {
1499
- mutex_unlock(&irq_domain_mutex);
1469
+ if (ret < 0)
1500
1470
goto out_free_irq_data;
1501
- }
1502
1471
1503
1472
for (i = 0; i < nr_irqs; i++) {
1504
1473
ret = irq_domain_trim_hierarchy(virq + i);
1505
- if (ret) {
1506
- mutex_unlock(&irq_domain_mutex);
1474
+ if (ret)
1507
1475
goto out_free_irq_data;
1508
- }
1509
1476
}
1510
-
1477
+
1511
1478
for (i = 0; i < nr_irqs; i++)
1512
1479
irq_domain_insert_irq(virq + i);
1513
- mutex_unlock(&irq_domain_mutex);
1514
1480
1515
1481
return virq;
1516
1482
@@ -1520,6 +1486,48 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
1520
1486
irq_free_descs(virq, nr_irqs);
1521
1487
return ret;
1522
1488
}
1489
+
1490
+ /**
1491
+ * __irq_domain_alloc_irqs - Allocate IRQs from domain
1492
+ * @domain: domain to allocate from
1493
+ * @irq_base: allocate specified IRQ number if irq_base >= 0
1494
+ * @nr_irqs: number of IRQs to allocate
1495
+ * @node: NUMA node id for memory allocation
1496
+ * @arg: domain specific argument
1497
+ * @realloc: IRQ descriptors have already been allocated if true
1498
+ * @affinity: Optional irq affinity mask for multiqueue devices
1499
+ *
1500
+ * Allocate IRQ numbers and initialized all data structures to support
1501
+ * hierarchy IRQ domains.
1502
+ * Parameter @realloc is mainly to support legacy IRQs.
1503
+ * Returns error code or allocated IRQ number
1504
+ *
1505
+ * The whole process to setup an IRQ has been split into two steps.
1506
+ * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
1507
+ * descriptor and required hardware resources. The second step,
1508
+ * irq_domain_activate_irq(), is to program the hardware with preallocated
1509
+ * resources. In this way, it's easier to rollback when failing to
1510
+ * allocate resources.
1511
+ */
1512
+ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
1513
+ unsigned int nr_irqs, int node, void *arg,
1514
+ bool realloc, const struct irq_affinity_desc *affinity)
1515
+ {
1516
+ int ret;
1517
+
1518
+ if (domain == NULL) {
1519
+ domain = irq_default_domain;
1520
+ if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
1521
+ return -EINVAL;
1522
+ }
1523
+
1524
+ mutex_lock(&irq_domain_mutex);
1525
+ ret = irq_domain_alloc_irqs_locked(domain, irq_base, nr_irqs, node, arg,
1526
+ realloc, affinity);
1527
+ mutex_unlock(&irq_domain_mutex);
1528
+
1529
+ return ret;
1530
+ }
1523
1531
EXPORT_SYMBOL_GPL(__irq_domain_alloc_irqs);
1524
1532
1525
1533
/* The irq_data was moved, fix the revmap to refer to the new location */
0 commit comments