Pull irq fixes from Ingo Molnar: "Fix a recent IRQ affinities regression, add in a missing debugfs printout that helps the debugging of IRQ affinity logic bugs, and fix a memory leak" * tag 'irq-urgent-2020-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: genirq/debugfs: Add missing irqchip flags genirq/affinity: Make affinity setting if activated opt-in irqdomain/treewide: Free firmware node after domain removal
Unified · Split
| @@ -728,6 +728,7 @@ err_free_resource: · 727 unmodified lines | |||
| 728 | pci_free_resource_list(&host->windows); | 728 | pci_free_resource_list(&host->windows); |
| 729 | err_remove_domain: | 729 | err_remove_domain: |
| 730 | irq_domain_remove(domain); | 730 | irq_domain_remove(domain); |
| 731 | irq_domain_free_fwnode(fn); | ||
| 731 | return err; | 732 | return err; |
| 732 | } | 733 | } |
| 733 | 734 | ||
| @@ -735,8 +736,10 @@ static int bridge_remove(struct platform_device *pdev) · 1 unmodified line | |||
| 735 | { | 736 | { |
| 736 | struct pci_bus *bus = platform_get_drvdata(pdev); | 737 | struct pci_bus *bus = platform_get_drvdata(pdev); |
| 737 | struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); | 738 | struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); |
| 739 | struct fwnode_handle *fn = bc->domain->fwnode; | ||
| 738 | 740 | ||
| 739 | irq_domain_remove(bc->domain); | 741 | irq_domain_remove(bc->domain); |
| 742 | irq_domain_free_fwnode(fn); | ||
| 740 | pci_lock_rescan_remove(); | 743 | pci_lock_rescan_remove(); |
| 741 | pci_stop_root_bus(bus); | 744 | pci_stop_root_bus(bus); |
| 742 | pci_remove_root_bus(bus); | 745 | pci_remove_root_bus(bus); |
| @@ -2335,8 +2335,13 @@ static int mp_irqdomain_create(int ioapic) · 2334 unmodified lines | |||
| 2335 | 2335 | ||
| 2336 | static void ioapic_destroy_irqdomain(int idx) | 2336 | static void ioapic_destroy_irqdomain(int idx) |
| 2337 | { | 2337 | { |
| 2338 | struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg; | ||
| 2339 | struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode; | ||
| 2340 | |||
| 2338 | if (ioapics[idx].irqdomain) { | 2341 | if (ioapics[idx].irqdomain) { |
| 2339 | irq_domain_remove(ioapics[idx].irqdomain); | 2342 | irq_domain_remove(ioapics[idx].irqdomain); |
| 2343 | if (!cfg->dev) | ||
| 2344 | irq_domain_free_fwnode(fn); | ||
| 2340 | ioapics[idx].irqdomain = NULL; | 2345 | ioapics[idx].irqdomain = NULL; |
| 2341 | } | 2346 | } |
| 2342 | } | 2347 | } |
| @@ -560,6 +560,10 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq, · 559 unmodified lines | |||
| 560 | * as that can corrupt the affinity move state. | 560 | * as that can corrupt the affinity move state. |
| 561 | */ | 561 | */ |
| 562 | irqd_set_handle_enforce_irqctx(irqd); | 562 | irqd_set_handle_enforce_irqctx(irqd); |
| 563 | |||
| 564 | /* Don't invoke affinity setter on deactivated interrupts */ | ||
| 565 | irqd_set_affinity_on_activate(irqd); | ||
| 566 | |||
| 563 | /* | 567 | /* |
| 564 | * Legacy vectors are already assigned when the IOAPIC | 568 | * Legacy vectors are already assigned when the IOAPIC |
| 565 | * takes them over. They stay on the same vector. This is | 569 | * takes them over. They stay on the same vector. This is |
| @@ -628,13 +628,21 @@ out_free_table: · 627 unmodified lines | |||
| 628 | 628 | ||
| 629 | static void intel_teardown_irq_remapping(struct intel_iommu *iommu) | 629 | static void intel_teardown_irq_remapping(struct intel_iommu *iommu) |
| 630 | { | 630 | { |
| 631 | struct fwnode_handle *fn; | ||
| 632 | |||
| 631 | if (iommu && iommu->ir_table) { | 633 | if (iommu && iommu->ir_table) { |
| 632 | if (iommu->ir_msi_domain) { | 634 | if (iommu->ir_msi_domain) { |
| 635 | fn = iommu->ir_msi_domain->fwnode; | ||
| 636 | |||
| 633 | irq_domain_remove(iommu->ir_msi_domain); | 637 | irq_domain_remove(iommu->ir_msi_domain); |
| 638 | irq_domain_free_fwnode(fn); | ||
| 634 | iommu->ir_msi_domain = NULL; | 639 | iommu->ir_msi_domain = NULL; |
| 635 | } | 640 | } |
| 636 | if (iommu->ir_domain) { | 641 | if (iommu->ir_domain) { |
| 642 | fn = iommu->ir_domain->fwnode; | ||
| 643 | |||
| 637 | irq_domain_remove(iommu->ir_domain); | 644 | irq_domain_remove(iommu->ir_domain); |
| 645 | irq_domain_free_fwnode(fn); | ||
| 638 | iommu->ir_domain = NULL; | 646 | iommu->ir_domain = NULL; |
| 639 | } | 647 | } |
| 640 | free_pages((unsigned long)iommu->ir_table->base, | 648 | free_pages((unsigned long)iommu->ir_table->base, |
| @@ -3523,6 +3523,7 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, · 3522 unmodified lines | |||
| 3523 | msi_alloc_info_t *info = args; | 3523 | msi_alloc_info_t *info = args; |
| 3524 | struct its_device *its_dev = info->scratchpad[0].ptr; | 3524 | struct its_device *its_dev = info->scratchpad[0].ptr; |
| 3525 | struct its_node *its = its_dev->its; | 3525 | struct its_node *its = its_dev->its; |
| 3526 | struct irq_data *irqd; | ||
| 3526 | irq_hw_number_t hwirq; | 3527 | irq_hw_number_t hwirq; |
| 3527 | int err; | 3528 | int err; |
| 3528 | int i; | 3529 | int i; |
| @@ -3542,7 +3543,9 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, · 13 unmodified lines | |||
| 3542 | 3543 | ||
| 3543 | irq_domain_set_hwirq_and_chip(domain, virq + i, | 3544 | irq_domain_set_hwirq_and_chip(domain, virq + i, |
| 3544 | hwirq + i, &its_irq_chip, its_dev); | 3545 | hwirq + i, &its_irq_chip, its_dev); |
| 3545 | irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq + i))); | 3546 | irqd = irq_get_irq_data(virq + i); |
| 3547 | irqd_set_single_target(irqd); | ||
| 3548 | irqd_set_affinity_on_activate(irqd); | ||
| 3546 | pr_debug("ID:%d pID:%d vID:%d\n", | 3549 | pr_debug("ID:%d pID:%d vID:%d\n", |
| 3547 | (int)(hwirq + i - its_dev->event_map.lpi_base), | 3550 | (int)(hwirq + i - its_dev->event_map.lpi_base), |
| 3548 | (int)(hwirq + i), virq + i); | 3551 | (int)(hwirq + i), virq + i); |
| @@ -616,7 +616,10 @@ static int ioc3_mfd_probe(struct pci_dev *pdev, · 615 unmodified lines | |||
| 616 | /* Remove all already added MFD devices */ | 616 | /* Remove all already added MFD devices */ |
| 617 | mfd_remove_devices(&ipd->pdev->dev); | 617 | mfd_remove_devices(&ipd->pdev->dev); |
| 618 | if (ipd->domain) { | 618 | if (ipd->domain) { |
| 619 | struct fwnode_handle *fn = ipd->domain->fwnode; | ||
| 620 | |||
| 619 | irq_domain_remove(ipd->domain); | 621 | irq_domain_remove(ipd->domain); |
| 622 | irq_domain_free_fwnode(fn); | ||
| 620 | free_irq(ipd->domain_irq, (void *)ipd); | 623 | free_irq(ipd->domain_irq, (void *)ipd); |
| 621 | } | 624 | } |
| 622 | pci_iounmap(pdev, regs); | 625 | pci_iounmap(pdev, regs); |
| @@ -643,7 +646,10 @@ static void ioc3_mfd_remove(struct pci_dev *pdev) · 20 unmodified lines | |||
| 643 | /* Release resources */ | 646 | /* Release resources */ |
| 644 | mfd_remove_devices(&ipd->pdev->dev); | 647 | mfd_remove_devices(&ipd->pdev->dev); |
| 645 | if (ipd->domain) { | 648 | if (ipd->domain) { |
| 649 | struct fwnode_handle *fn = ipd->domain->fwnode; | ||
| 650 | |||
| 646 | irq_domain_remove(ipd->domain); | 651 | irq_domain_remove(ipd->domain); |
| 652 | irq_domain_free_fwnode(fn); | ||
| 647 | free_irq(ipd->domain_irq, (void *)ipd); | 653 | free_irq(ipd->domain_irq, (void *)ipd); |
| 648 | } | 654 | } |
| 649 | pci_iounmap(pdev, ipd->regs); | 655 | pci_iounmap(pdev, ipd->regs); |
| @@ -560,6 +560,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) · 559 unmodified lines | |||
| 560 | if (!vmd->bus) { | 560 | if (!vmd->bus) { |
| 561 | pci_free_resource_list(&resources); | 561 | pci_free_resource_list(&resources); |
| 562 | irq_domain_remove(vmd->irq_domain); | 562 | irq_domain_remove(vmd->irq_domain); |
| 563 | irq_domain_free_fwnode(fn); | ||
| 563 | return -ENODEV; | 564 | return -ENODEV; |
| 564 | } | 565 | } |
| 565 | 566 | ||
| @@ -673,6 +674,7 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd) · 107 unmodified lines | |||
| 673 | static void vmd_remove(struct pci_dev *dev) | 674 | static void vmd_remove(struct pci_dev *dev) |
| 674 | { | 675 | { |
| 675 | struct vmd_dev *vmd = pci_get_drvdata(dev); | 676 | struct vmd_dev *vmd = pci_get_drvdata(dev); |
| 677 | struct fwnode_handle *fn = vmd->irq_domain->fwnode; | ||
| 676 | 678 | ||
| 677 | sysfs_remove_link(&vmd->dev->dev.kobj, "domain"); | 679 | sysfs_remove_link(&vmd->dev->dev.kobj, "domain"); |
| 678 | pci_stop_root_bus(vmd->bus); | 680 | pci_stop_root_bus(vmd->bus); |
| @@ -680,6 +682,7 @@ static void vmd_remove(struct pci_dev *dev) · 1 unmodified line | |||
| 680 | vmd_cleanup_srcu(vmd); | 682 | vmd_cleanup_srcu(vmd); |
| 681 | vmd_detach_resources(vmd); | 683 | vmd_detach_resources(vmd); |
| 682 | irq_domain_remove(vmd->irq_domain); | 684 | irq_domain_remove(vmd->irq_domain); |
| 685 | irq_domain_free_fwnode(fn); | ||
| 683 | } | 686 | } |
| 684 | 687 | ||
| 685 | #ifdef CONFIG_PM_SLEEP | 688 | #ifdef CONFIG_PM_SLEEP |
| @@ -213,6 +213,8 @@ struct irq_data { · 212 unmodified lines | |||
| 213 | * required | 213 | * required |
| 214 | * IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked | 214 | * IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked |
| 215 | * from actual interrupt context. | 215 | * from actual interrupt context. |
| 216 | * IRQD_AFFINITY_ON_ACTIVATE - Affinity is set on activation. Don't call | ||
| 217 | * irq_chip::irq_set_affinity() when deactivated. | ||
| 216 | */ | 218 | */ |
| 217 | enum { | 219 | enum { |
| 218 | IRQD_TRIGGER_MASK = 0xf, | 220 | IRQD_TRIGGER_MASK = 0xf, |
| @@ -237,6 +239,7 @@ enum { · 18 unmodified lines | |||
| 237 | IRQD_CAN_RESERVE = (1 << 26), | 239 | IRQD_CAN_RESERVE = (1 << 26), |
| 238 | IRQD_MSI_NOMASK_QUIRK = (1 << 27), | 240 | IRQD_MSI_NOMASK_QUIRK = (1 << 27), |
| 239 | IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28), | 241 | IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28), |
| 242 | IRQD_AFFINITY_ON_ACTIVATE = (1 << 29), | ||
| 240 | }; | 243 | }; |
| 241 | 244 | ||
| 242 | #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) | 245 | #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) |
| @@ -421,6 +424,16 @@ static inline bool irqd_msi_nomask_quirk(struct irq_data *d) · 178 unmodified lines | |||
| 421 | return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK; | 424 | return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK; |
| 422 | } | 425 | } |
| 423 | 426 | ||
| 427 | static inline void irqd_set_affinity_on_activate(struct irq_data *d) | ||
| 428 | { | ||
| 429 | __irqd_to_state(d) |= IRQD_AFFINITY_ON_ACTIVATE; | ||
| 430 | } | ||
| 431 | |||
| 432 | static inline bool irqd_affinity_on_activate(struct irq_data *d) | ||
| 433 | { | ||
| 434 | return __irqd_to_state(d) & IRQD_AFFINITY_ON_ACTIVATE; | ||
| 435 | } | ||
| 436 | |||
| 424 | #undef __irqd_to_state | 437 | #undef __irqd_to_state |
| 425 | 438 | ||
| 426 | static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) | 439 | static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) |
| @@ -112,6 +112,7 @@ static const struct irq_bit_descr irqdata_states[] = { · 111 unmodified lines | |||
| 112 | BIT_MASK_DESCR(IRQD_AFFINITY_SET), | 112 | BIT_MASK_DESCR(IRQD_AFFINITY_SET), |
| 113 | BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING), | 113 | BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING), |
| 114 | BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED), | 114 | BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED), |
| 115 | BIT_MASK_DESCR(IRQD_AFFINITY_ON_ACTIVATE), | ||
| 115 | BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN), | 116 | BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN), |
| 116 | BIT_MASK_DESCR(IRQD_CAN_RESERVE), | 117 | BIT_MASK_DESCR(IRQD_CAN_RESERVE), |
| 117 | BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK), | 118 | BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK), |
| @@ -120,6 +121,10 @@ static const struct irq_bit_descr irqdata_states[] = { · 2 unmodified lines | |||
| 120 | 121 | ||
| 121 | BIT_MASK_DESCR(IRQD_WAKEUP_STATE), | 122 | BIT_MASK_DESCR(IRQD_WAKEUP_STATE), |
| 122 | BIT_MASK_DESCR(IRQD_WAKEUP_ARMED), | 123 | BIT_MASK_DESCR(IRQD_WAKEUP_ARMED), |
| 124 | |||
| 125 | BIT_MASK_DESCR(IRQD_DEFAULT_TRIGGER_SET), | ||
| 126 | |||
| 127 | BIT_MASK_DESCR(IRQD_HANDLE_ENFORCE_IRQCTX), | ||
| 123 | }; | 128 | }; |
| 124 | 129 | ||
| 125 | static const struct irq_bit_descr irqdesc_states[] = { | 130 | static const struct irq_bit_descr irqdesc_states[] = { |
| @@ -320,12 +320,16 @@ static bool irq_set_affinity_deactivated(struct irq_data *data, · 319 unmodified lines | |||
| 320 | struct irq_desc *desc = irq_data_to_desc(data); | 320 | struct irq_desc *desc = irq_data_to_desc(data); |
| 321 | 321 | ||
| 322 | /* | 322 | /* |
| 323 | * Handle irq chips which can handle affinity only in activated | ||
| 324 | * state correctly | ||
| 325 | * | ||
| 323 | * If the interrupt is not yet activated, just store the affinity | 326 | * If the interrupt is not yet activated, just store the affinity |
| 324 | * mask and do not call the chip driver at all. On activation the | 327 | * mask and do not call the chip driver at all. On activation the |
| 325 | * driver has to make sure anyway that the interrupt is in a | 328 | * driver has to make sure anyway that the interrupt is in a |
| 326 | * useable state so startup works. | 329 | * useable state so startup works. |
| 327 | */ | 330 | */ |
| 328 | if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) || irqd_is_activated(data)) | 331 | if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) || |
| 332 | irqd_is_activated(data) || !irqd_affinity_on_activate(data)) | ||
| 329 | return false; | 333 | return false; |
| 330 | 334 | ||
| 331 | cpumask_copy(desc->irq_common_data.affinity, mask); | 335 | cpumask_copy(desc->irq_common_data.affinity, mask); |