Skip to content

Commit 8190cc5

Browse files
smaeulMarc Zyngier
authored andcommitted
irqchip/mips-gic: Only register IPI domain when SMP is enabled
The MIPS GIC irqchip driver may be selected in a uniprocessor configuration, but it unconditionally registers an IPI domain. Limit the part of the driver dealing with IPIs to only be compiled when GENERIC_IRQ_IPI is enabled, which corresponds to an SMP configuration. Reported-by: kernel test robot <[email protected]> Signed-off-by: Samuel Holland <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a111daf commit 8190cc5

File tree

2 files changed

+56
-27
lines changed

2 files changed

+56
-27
lines changed

drivers/irqchip/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ config KEYSTONE_IRQ
322322

323323
config MIPS_GIC
324324
bool
325-
select GENERIC_IRQ_IPI
325+
select GENERIC_IRQ_IPI if SMP
326+
select IRQ_DOMAIN_HIERARCHY
326327
select MIPS_CM
327328

328329
config INGENIC_IRQ

drivers/irqchip/irq-mips-gic.c

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ static DEFINE_PER_CPU_READ_MOSTLY(unsigned long[GIC_MAX_LONGS], pcpu_masks);
5252

5353
static DEFINE_SPINLOCK(gic_lock);
5454
static struct irq_domain *gic_irq_domain;
55-
static struct irq_domain *gic_ipi_domain;
5655
static int gic_shared_intrs;
5756
static unsigned int gic_cpu_pin;
5857
static unsigned int timer_cpu_pin;
5958
static struct irq_chip gic_level_irq_controller, gic_edge_irq_controller;
59+
60+
#ifdef CONFIG_GENERIC_IRQ_IPI
6061
static DECLARE_BITMAP(ipi_resrv, GIC_MAX_INTRS);
6162
static DECLARE_BITMAP(ipi_available, GIC_MAX_INTRS);
63+
#endif /* CONFIG_GENERIC_IRQ_IPI */
6264

6365
static struct gic_all_vpes_chip_data {
6466
u32 map;
@@ -472,9 +474,11 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
472474
u32 map;
473475

474476
if (hwirq >= GIC_SHARED_HWIRQ_BASE) {
477+
#ifdef CONFIG_GENERIC_IRQ_IPI
475478
/* verify that shared irqs don't conflict with an IPI irq */
476479
if (test_bit(GIC_HWIRQ_TO_SHARED(hwirq), ipi_resrv))
477480
return -EBUSY;
481+
#endif /* CONFIG_GENERIC_IRQ_IPI */
478482

479483
err = irq_domain_set_hwirq_and_chip(d, virq, hwirq,
480484
&gic_level_irq_controller,
@@ -567,6 +571,8 @@ static const struct irq_domain_ops gic_irq_domain_ops = {
567571
.map = gic_irq_domain_map,
568572
};
569573

574+
#ifdef CONFIG_GENERIC_IRQ_IPI
575+
570576
static int gic_ipi_domain_xlate(struct irq_domain *d, struct device_node *ctrlr,
571577
const u32 *intspec, unsigned int intsize,
572578
irq_hw_number_t *out_hwirq,
@@ -670,6 +676,48 @@ static const struct irq_domain_ops gic_ipi_domain_ops = {
670676
.match = gic_ipi_domain_match,
671677
};
672678

679+
static int gic_register_ipi_domain(struct device_node *node)
680+
{
681+
struct irq_domain *gic_ipi_domain;
682+
unsigned int v[2], num_ipis;
683+
684+
gic_ipi_domain = irq_domain_add_hierarchy(gic_irq_domain,
685+
IRQ_DOMAIN_FLAG_IPI_PER_CPU,
686+
GIC_NUM_LOCAL_INTRS + gic_shared_intrs,
687+
node, &gic_ipi_domain_ops, NULL);
688+
if (!gic_ipi_domain) {
689+
pr_err("Failed to add IPI domain");
690+
return -ENXIO;
691+
}
692+
693+
irq_domain_update_bus_token(gic_ipi_domain, DOMAIN_BUS_IPI);
694+
695+
if (node &&
696+
!of_property_read_u32_array(node, "mti,reserved-ipi-vectors", v, 2)) {
697+
bitmap_set(ipi_resrv, v[0], v[1]);
698+
} else {
699+
/*
700+
* Reserve 2 interrupts per possible CPU/VP for use as IPIs,
701+
* meeting the requirements of arch/mips SMP.
702+
*/
703+
num_ipis = 2 * num_possible_cpus();
704+
bitmap_set(ipi_resrv, gic_shared_intrs - num_ipis, num_ipis);
705+
}
706+
707+
bitmap_copy(ipi_available, ipi_resrv, GIC_MAX_INTRS);
708+
709+
return 0;
710+
}
711+
712+
#else /* !CONFIG_GENERIC_IRQ_IPI */
713+
714+
static inline int gic_register_ipi_domain(struct device_node *node)
715+
{
716+
return 0;
717+
}
718+
719+
#endif /* !CONFIG_GENERIC_IRQ_IPI */
720+
673721
static int gic_cpu_startup(unsigned int cpu)
674722
{
675723
/* Enable or disable EIC */
@@ -688,11 +736,12 @@ static int gic_cpu_startup(unsigned int cpu)
688736
static int __init gic_of_init(struct device_node *node,
689737
struct device_node *parent)
690738
{
691-
unsigned int cpu_vec, i, gicconfig, v[2], num_ipis;
739+
unsigned int cpu_vec, i, gicconfig;
692740
unsigned long reserved;
693741
phys_addr_t gic_base;
694742
struct resource res;
695743
size_t gic_len;
744+
int ret;
696745

697746
/* Find the first available CPU vector. */
698747
i = 0;
@@ -780,30 +829,9 @@ static int __init gic_of_init(struct device_node *node,
780829
return -ENXIO;
781830
}
782831

783-
gic_ipi_domain = irq_domain_add_hierarchy(gic_irq_domain,
784-
IRQ_DOMAIN_FLAG_IPI_PER_CPU,
785-
GIC_NUM_LOCAL_INTRS + gic_shared_intrs,
786-
node, &gic_ipi_domain_ops, NULL);
787-
if (!gic_ipi_domain) {
788-
pr_err("Failed to add IPI domain");
789-
return -ENXIO;
790-
}
791-
792-
irq_domain_update_bus_token(gic_ipi_domain, DOMAIN_BUS_IPI);
793-
794-
if (node &&
795-
!of_property_read_u32_array(node, "mti,reserved-ipi-vectors", v, 2)) {
796-
bitmap_set(ipi_resrv, v[0], v[1]);
797-
} else {
798-
/*
799-
* Reserve 2 interrupts per possible CPU/VP for use as IPIs,
800-
* meeting the requirements of arch/mips SMP.
801-
*/
802-
num_ipis = 2 * num_possible_cpus();
803-
bitmap_set(ipi_resrv, gic_shared_intrs - num_ipis, num_ipis);
804-
}
805-
806-
bitmap_copy(ipi_available, ipi_resrv, GIC_MAX_INTRS);
832+
ret = gic_register_ipi_domain(node);
833+
if (ret)
834+
return ret;
807835

808836
board_bind_eic_interrupt = &gic_bind_eic_interrupt;
809837

0 commit comments

Comments
 (0)