@@ -345,7 +345,7 @@ const struct irq_domain_ops ioapic_irq_domain_ops = {
static void __init ioapic_add_ofnode(struct device_node *np)
{
struct resource r;
- int i, ret;
+ int i, irq, ret;
ret = of_address_to_resource(np, 0, &r);
if (ret) {
@@ -357,13 +357,22 @@ static void __init ioapic_add_ofnode(struct device_node *np)
for (i = 0; i < nr_ioapics; i++) {
if (r.start == mpc_ioapic_addr(i)) {
struct irq_domain *id;
- struct mp_ioapic_gsi *gsi_cfg;
-
- gsi_cfg = mp_ioapic_gsi_routing(i);
-
- id = irq_domain_add_legacy(np, 32, gsi_cfg->gsi_base, 0,
- &ioapic_irq_domain_ops,
- (void*)i);
+ struct mp_ioapic_gsi *cfg;
+
+ cfg = mp_ioapic_gsi_routing(i);
+
+ /*
+ * Preallocate irq_descs so that the legacy mapping
+ * works, but don't set them up.
+ * io_apic_setup_irq_pin_once() will finish the set up.
+ */
+ for (irq = cfg->gsi_base; irq <= cfg->gsi_end; irq++)
+ irq_alloc_desc_at(irq, cpu_to_node(0));
+
+ id = irq_domain_add_legacy(np,
+ cfg->gsi_end - cfg->gsi_base + 1,
+ cfg->gsi_base, 0,
+ &ioapic_irq_domain_ops, (void*)i);
BUG_ON(!id);
return;
}