Merge tag 'irqchip-fixes-6.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/urgent

Pull irqchip fixes from Marc Zyngier:

- MIPS GIC fixes for issues that could result in either
loss of state in the interrupt controller, or a deadlock

- Workaround for Mediatek Chromebooks that only save/restore
partial state when turning the GIC redistributors off,
resulting if fireworks if Linux uses interrupt priorities
for pseudo-NMIs

- Fix the MBIGEN error handling on init

- Mark meson-gpio OF data structures as __maybe_unused,
avoiding compilation warnings on non-OF setups

Link: https://lore.kernel.org/lkml/20230521101812.2520740-1-maz@kernel.org

Changed files
+69 -31
Documentation
devicetree
bindings
interrupt-controller
drivers
+6
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.yaml
··· 166 166 resets: 167 167 maxItems: 1 168 168 169 + mediatek,broken-save-restore-fw: 170 + type: boolean 171 + description: 172 + Asserts that the firmware on this device has issues saving and restoring 173 + GICR registers when the GIC redistributors are powered off. 174 + 169 175 dependencies: 170 176 mbi-ranges: [ msi-controller ] 171 177 msi-controller: [ mbi-ranges ]
+6 -2
drivers/irqchip/irq-gic-common.c
··· 16 16 const struct gic_quirk *quirks, void *data) 17 17 { 18 18 for (; quirks->desc; quirks++) { 19 - if (!of_device_is_compatible(np, quirks->compatible)) 19 + if (quirks->compatible && 20 + !of_device_is_compatible(np, quirks->compatible)) 21 + continue; 22 + if (quirks->property && 23 + !of_property_read_bool(np, quirks->property)) 20 24 continue; 21 25 if (quirks->init(data)) 22 26 pr_info("GIC: enabling workaround for %s\n", ··· 32 28 void *data) 33 29 { 34 30 for (; quirks->desc; quirks++) { 35 - if (quirks->compatible) 31 + if (quirks->compatible || quirks->property) 36 32 continue; 37 33 if (quirks->iidr != (quirks->mask & iidr)) 38 34 continue;
+1
drivers/irqchip/irq-gic-common.h
··· 13 13 struct gic_quirk { 14 14 const char *desc; 15 15 const char *compatible; 16 + const char *property; 16 17 bool (*init)(void *data); 17 18 u32 iidr; 18 19 u32 mask;
+20
drivers/irqchip/irq-gic-v3.c
··· 39 39 40 40 #define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0) 41 41 #define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) 42 + #define FLAGS_WORKAROUND_MTK_GICR_SAVE (1ULL << 2) 42 43 43 44 #define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1) 44 45 ··· 1721 1720 return true; 1722 1721 } 1723 1722 1723 + static bool gic_enable_quirk_mtk_gicr(void *data) 1724 + { 1725 + struct gic_chip_data *d = data; 1726 + 1727 + d->flags |= FLAGS_WORKAROUND_MTK_GICR_SAVE; 1728 + 1729 + return true; 1730 + } 1731 + 1724 1732 static bool gic_enable_quirk_cavium_38539(void *data) 1725 1733 { 1726 1734 struct gic_chip_data *d = data; ··· 1803 1793 .init = gic_enable_quirk_msm8996, 1804 1794 }, 1805 1795 { 1796 + .desc = "GICv3: Mediatek Chromebook GICR save problem", 1797 + .property = "mediatek,broken-save-restore-fw", 1798 + .init = gic_enable_quirk_mtk_gicr, 1799 + }, 1800 + { 1806 1801 .desc = "GICv3: HIP06 erratum 161010803", 1807 1802 .iidr = 0x0204043b, 1808 1803 .mask = 0xffffffff, ··· 1848 1833 1849 1834 if (!gic_prio_masking_enabled()) 1850 1835 return; 1836 + 1837 + if (gic_data.flags & FLAGS_WORKAROUND_MTK_GICR_SAVE) { 1838 + pr_warn("Skipping NMI enable due to firmware issues\n"); 1839 + return; 1840 + } 1851 1841 1852 1842 ppi_nmi_refs = kcalloc(gic_data.ppi_nr, sizeof(*ppi_nmi_refs), GFP_KERNEL); 1853 1843 if (!ppi_nmi_refs)
+18 -13
drivers/irqchip/irq-mbigen.c
··· 240 240 struct irq_domain *domain; 241 241 struct device_node *np; 242 242 u32 num_pins; 243 + int ret = 0; 244 + 245 + parent = bus_get_dev_root(&platform_bus_type); 246 + if (!parent) 247 + return -ENODEV; 243 248 244 249 for_each_child_of_node(pdev->dev.of_node, np) { 245 250 if (!of_property_read_bool(np, "interrupt-controller")) 246 251 continue; 247 252 248 - parent = bus_get_dev_root(&platform_bus_type); 249 - if (parent) { 250 - child = of_platform_device_create(np, NULL, parent); 251 - put_device(parent); 252 - if (!child) { 253 - of_node_put(np); 254 - return -ENOMEM; 255 - } 253 + child = of_platform_device_create(np, NULL, parent); 254 + if (!child) { 255 + ret = -ENOMEM; 256 + break; 256 257 } 257 258 258 259 if (of_property_read_u32(child->dev.of_node, "num-pins", 259 260 &num_pins) < 0) { 260 261 dev_err(&pdev->dev, "No num-pins property\n"); 261 - of_node_put(np); 262 - return -EINVAL; 262 + ret = -EINVAL; 263 + break; 263 264 } 264 265 265 266 domain = platform_msi_create_device_domain(&child->dev, num_pins, ··· 268 267 &mbigen_domain_ops, 269 268 mgn_chip); 270 269 if (!domain) { 271 - of_node_put(np); 272 - return -ENOMEM; 270 + ret = -ENOMEM; 271 + break; 273 272 } 274 273 } 275 274 276 - return 0; 275 + put_device(parent); 276 + if (ret) 277 + of_node_put(np); 278 + 279 + return ret; 277 280 } 278 281 279 282 #ifdef CONFIG_ACPI
+1 -1
drivers/irqchip/irq-meson-gpio.c
··· 150 150 INIT_MESON_S4_COMMON_DATA(82) 151 151 }; 152 152 153 - static const struct of_device_id meson_irq_gpio_matches[] = { 153 + static const struct of_device_id meson_irq_gpio_matches[] __maybe_unused = { 154 154 { .compatible = "amlogic,meson8-gpio-intc", .data = &meson8_params }, 155 155 { .compatible = "amlogic,meson8b-gpio-intc", .data = &meson8b_params }, 156 156 { .compatible = "amlogic,meson-gxbb-gpio-intc", .data = &gxbb_params },
+17 -15
drivers/irqchip/irq-mips-gic.c
··· 50 50 51 51 static DEFINE_PER_CPU_READ_MOSTLY(unsigned long[GIC_MAX_LONGS], pcpu_masks); 52 52 53 - static DEFINE_SPINLOCK(gic_lock); 53 + static DEFINE_RAW_SPINLOCK(gic_lock); 54 54 static struct irq_domain *gic_irq_domain; 55 55 static int gic_shared_intrs; 56 56 static unsigned int gic_cpu_pin; ··· 210 210 211 211 irq = GIC_HWIRQ_TO_SHARED(d->hwirq); 212 212 213 - spin_lock_irqsave(&gic_lock, flags); 213 + raw_spin_lock_irqsave(&gic_lock, flags); 214 214 switch (type & IRQ_TYPE_SENSE_MASK) { 215 215 case IRQ_TYPE_EDGE_FALLING: 216 216 pol = GIC_POL_FALLING_EDGE; ··· 250 250 else 251 251 irq_set_chip_handler_name_locked(d, &gic_level_irq_controller, 252 252 handle_level_irq, NULL); 253 - spin_unlock_irqrestore(&gic_lock, flags); 253 + raw_spin_unlock_irqrestore(&gic_lock, flags); 254 254 255 255 return 0; 256 256 } ··· 268 268 return -EINVAL; 269 269 270 270 /* Assumption : cpumask refers to a single CPU */ 271 - spin_lock_irqsave(&gic_lock, flags); 271 + raw_spin_lock_irqsave(&gic_lock, flags); 272 272 273 273 /* Re-route this IRQ */ 274 274 write_gic_map_vp(irq, BIT(mips_cm_vp_id(cpu))); ··· 279 279 set_bit(irq, per_cpu_ptr(pcpu_masks, cpu)); 280 280 281 281 irq_data_update_effective_affinity(d, cpumask_of(cpu)); 282 - spin_unlock_irqrestore(&gic_lock, flags); 282 + raw_spin_unlock_irqrestore(&gic_lock, flags); 283 283 284 284 return IRQ_SET_MASK_OK; 285 285 } ··· 357 357 cd = irq_data_get_irq_chip_data(d); 358 358 cd->mask = false; 359 359 360 - spin_lock_irqsave(&gic_lock, flags); 360 + raw_spin_lock_irqsave(&gic_lock, flags); 361 361 for_each_online_cpu(cpu) { 362 362 write_gic_vl_other(mips_cm_vp_id(cpu)); 363 363 write_gic_vo_rmask(BIT(intr)); 364 364 } 365 - spin_unlock_irqrestore(&gic_lock, flags); 365 + raw_spin_unlock_irqrestore(&gic_lock, flags); 366 366 } 367 367 368 368 static void gic_unmask_local_irq_all_vpes(struct irq_data *d) ··· 375 375 cd = irq_data_get_irq_chip_data(d); 376 376 cd->mask = true; 377 377 378 - spin_lock_irqsave(&gic_lock, flags); 378 + raw_spin_lock_irqsave(&gic_lock, flags); 379 379 for_each_online_cpu(cpu) { 380 380 write_gic_vl_other(mips_cm_vp_id(cpu)); 381 381 write_gic_vo_smask(BIT(intr)); 382 382 } 383 - spin_unlock_irqrestore(&gic_lock, flags); 383 + raw_spin_unlock_irqrestore(&gic_lock, flags); 384 384 } 385 385 386 386 static void gic_all_vpes_irq_cpu_online(void) ··· 393 393 unsigned long flags; 394 394 int i; 395 395 396 - spin_lock_irqsave(&gic_lock, flags); 396 + raw_spin_lock_irqsave(&gic_lock, flags); 397 397 398 398 for (i = 0; i < ARRAY_SIZE(local_intrs); i++) { 399 399 unsigned int intr = local_intrs[i]; 400 400 struct gic_all_vpes_chip_data *cd; 401 401 402 + if (!gic_local_irq_is_routable(intr)) 403 + continue; 402 404 cd = &gic_all_vpes_chip_data[intr]; 403 405 write_gic_vl_map(mips_gic_vx_map_reg(intr), cd->map); 404 406 if (cd->mask) 405 407 write_gic_vl_smask(BIT(intr)); 406 408 } 407 409 408 - spin_unlock_irqrestore(&gic_lock, flags); 410 + raw_spin_unlock_irqrestore(&gic_lock, flags); 409 411 } 410 412 411 413 static struct irq_chip gic_all_vpes_local_irq_controller = { ··· 437 435 438 436 data = irq_get_irq_data(virq); 439 437 440 - spin_lock_irqsave(&gic_lock, flags); 438 + raw_spin_lock_irqsave(&gic_lock, flags); 441 439 write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); 442 440 write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu))); 443 441 irq_data_update_effective_affinity(data, cpumask_of(cpu)); 444 - spin_unlock_irqrestore(&gic_lock, flags); 442 + raw_spin_unlock_irqrestore(&gic_lock, flags); 445 443 446 444 return 0; 447 445 } ··· 533 531 if (!gic_local_irq_is_routable(intr)) 534 532 return -EPERM; 535 533 536 - spin_lock_irqsave(&gic_lock, flags); 534 + raw_spin_lock_irqsave(&gic_lock, flags); 537 535 for_each_online_cpu(cpu) { 538 536 write_gic_vl_other(mips_cm_vp_id(cpu)); 539 537 write_gic_vo_map(mips_gic_vx_map_reg(intr), map); 540 538 } 541 - spin_unlock_irqrestore(&gic_lock, flags); 539 + raw_spin_unlock_irqrestore(&gic_lock, flags); 542 540 543 541 return 0; 544 542 }