Skip to content

Commit cbc06f0

Browse files
legoatermpe
authored andcommitted
powerpc/xive: Do not skip CPU-less nodes when creating the IPIs
On PowerVM, CPU-less nodes can be populated with hot-plugged CPUs at runtime. Today, the IPI is not created for such nodes, and hot-plugged CPUs use a bogus IPI, which leads to soft lockups. We can not directly allocate and request the IPI on demand because bringup_up() is called under the IRQ sparse lock. The alternative is to allocate the IPIs for all possible nodes at startup and to request the mapping on demand when the first CPU of a node is brought up. Fixes: 7dcc37b ("powerpc/xive: Map one IPI interrupt per node") Cc: [email protected] # v5.13 Reported-by: Geetika Moolchandani <[email protected]> Signed-off-by: Cédric Le Goater <[email protected]> Tested-by: Srikar Dronamraju <[email protected]> Tested-by: Laurent Vivier <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 01fcac8 commit cbc06f0

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

arch/powerpc/sysdev/xive/common.c

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static struct irq_domain *xive_irq_domain;
6767
static struct xive_ipi_desc {
6868
unsigned int irq;
6969
char name[16];
70+
atomic_t started;
7071
} *xive_ipis;
7172

7273
/*
@@ -1120,7 +1121,7 @@ static const struct irq_domain_ops xive_ipi_irq_domain_ops = {
11201121
.alloc = xive_ipi_irq_domain_alloc,
11211122
};
11221123

1123-
static int __init xive_request_ipi(void)
1124+
static int __init xive_init_ipis(void)
11241125
{
11251126
struct fwnode_handle *fwnode;
11261127
struct irq_domain *ipi_domain;
@@ -1144,10 +1145,6 @@ static int __init xive_request_ipi(void)
11441145
struct xive_ipi_desc *xid = &xive_ipis[node];
11451146
struct xive_ipi_alloc_info info = { node };
11461147

1147-
/* Skip nodes without CPUs */
1148-
if (cpumask_empty(cpumask_of_node(node)))
1149-
continue;
1150-
11511148
/*
11521149
* Map one IPI interrupt per node for all cpus of that node.
11531150
* Since the HW interrupt number doesn't have any meaning,
@@ -1159,11 +1156,6 @@ static int __init xive_request_ipi(void)
11591156
xid->irq = ret;
11601157

11611158
snprintf(xid->name, sizeof(xid->name), "IPI-%d", node);
1162-
1163-
ret = request_irq(xid->irq, xive_muxed_ipi_action,
1164-
IRQF_PERCPU | IRQF_NO_THREAD, xid->name, NULL);
1165-
1166-
WARN(ret < 0, "Failed to request IPI %d: %d\n", xid->irq, ret);
11671159
}
11681160

11691161
return ret;
@@ -1178,6 +1170,22 @@ static int __init xive_request_ipi(void)
11781170
return ret;
11791171
}
11801172

1173+
static int __init xive_request_ipi(unsigned int cpu)
1174+
{
1175+
struct xive_ipi_desc *xid = &xive_ipis[early_cpu_to_node(cpu)];
1176+
int ret;
1177+
1178+
if (atomic_inc_return(&xid->started) > 1)
1179+
return 0;
1180+
1181+
ret = request_irq(xid->irq, xive_muxed_ipi_action,
1182+
IRQF_PERCPU | IRQF_NO_THREAD,
1183+
xid->name, NULL);
1184+
1185+
WARN(ret < 0, "Failed to request IPI %d: %d\n", xid->irq, ret);
1186+
return ret;
1187+
}
1188+
11811189
static int xive_setup_cpu_ipi(unsigned int cpu)
11821190
{
11831191
unsigned int xive_ipi_irq = xive_ipi_cpu_to_irq(cpu);
@@ -1192,6 +1200,9 @@ static int xive_setup_cpu_ipi(unsigned int cpu)
11921200
if (xc->hw_ipi != XIVE_BAD_IRQ)
11931201
return 0;
11941202

1203+
/* Register the IPI */
1204+
xive_request_ipi(cpu);
1205+
11951206
/* Grab an IPI from the backend, this will populate xc->hw_ipi */
11961207
if (xive_ops->get_ipi(cpu, xc))
11971208
return -EIO;
@@ -1231,6 +1242,8 @@ static void xive_cleanup_cpu_ipi(unsigned int cpu, struct xive_cpu *xc)
12311242
if (xc->hw_ipi == XIVE_BAD_IRQ)
12321243
return;
12331244

1245+
/* TODO: clear IPI mapping */
1246+
12341247
/* Mask the IPI */
12351248
xive_do_source_set_mask(&xc->ipi_data, true);
12361249

@@ -1253,7 +1266,7 @@ void __init xive_smp_probe(void)
12531266
smp_ops->cause_ipi = xive_cause_ipi;
12541267

12551268
/* Register the IPI */
1256-
xive_request_ipi();
1269+
xive_init_ipis();
12571270

12581271
/* Allocate and setup IPI for the boot CPU */
12591272
xive_setup_cpu_ipi(smp_processor_id());

0 commit comments

Comments
 (0)