mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 02:19:51 +00:00
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. Signed-off-by: Ingo Molnar <mingo@kernel.org> -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAl8nEn8RHG1pbmdvQGtl cm5lbC5vcmcACgkQEnMQ0APhK1ipYA/+KOWjDuRp1YBZeZ4/55RjGzimsW5jkLIY 0Na3WGjN/QBKCzmRJNnMyW1UjRgpHpBhOsphTcHVdhJo9jg5+DX+XdVTwKGTqAI+ 7DqzP4dzifSgUwdcxIbKwtZquBRzKk1K0Z25b6Jc0WJwkGRx3LWhhRDERPUEHtXg Sl07XxiuqFLcQZz9o3hisKzEfA2llB4bfXOjLCJlLK3HUZKccoBjWKbTrI3ymCiz f0iV9a7kNzo4fJNddKOBTtDWFEhpj6NgEVtLNdAaDti7MSSjPbB1BsiK64UInGMQ 4881ItYAOHGuCHe8yYnjlWA5kmwX14KjN6c3RAXK3n4+wvf+17RJC+FLH1PbkFIx hZ8k9x2Y5Dpt8vD8fGkoqi2nr2JYbIiOm79AjrD+Li+wWKG3iw4AGEoBHBJzKHUb naEGiUDJpn7pdpPWMACoctAIhy7/gDA1pPyb5F7Bf/RwoskIyu4i/d/xz05zBg3H HZMC2Lqcgh7LTS91NnmCx8XELdgL14mN19LK5enH3QTIPtdxmZ5x4quKw6ajMAAQ jwRpExqy6E1TQkIG5T5hjT0EMuj4uA6OzaoeOroFzKuzo+jiEDl49WAx+9Im9oBb i7hT4PM/wR7BcfmTMVhmmns4Dp0LkW7dRxHIjo7Fzft5iF8UkO7o7A4VUoAIxrSm xDFlBO/mo3w= =oKU9 -----END PGP SIGNATURE----- Merge tag 'irq-urgent-2020-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 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
This commit is contained in:
commit
3b4b84b2ea
10 changed files with 56 additions and 2 deletions
|
@ -728,6 +728,7 @@ static int bridge_probe(struct platform_device *pdev)
|
||||||
pci_free_resource_list(&host->windows);
|
pci_free_resource_list(&host->windows);
|
||||||
err_remove_domain:
|
err_remove_domain:
|
||||||
irq_domain_remove(domain);
|
irq_domain_remove(domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,8 +736,10 @@ static int bridge_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct pci_bus *bus = platform_get_drvdata(pdev);
|
struct pci_bus *bus = platform_get_drvdata(pdev);
|
||||||
struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
|
struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
|
||||||
|
struct fwnode_handle *fn = bc->domain->fwnode;
|
||||||
|
|
||||||
irq_domain_remove(bc->domain);
|
irq_domain_remove(bc->domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
pci_lock_rescan_remove();
|
pci_lock_rescan_remove();
|
||||||
pci_stop_root_bus(bus);
|
pci_stop_root_bus(bus);
|
||||||
pci_remove_root_bus(bus);
|
pci_remove_root_bus(bus);
|
||||||
|
|
|
@ -2335,8 +2335,13 @@ static int mp_irqdomain_create(int ioapic)
|
||||||
|
|
||||||
static void ioapic_destroy_irqdomain(int idx)
|
static void ioapic_destroy_irqdomain(int idx)
|
||||||
{
|
{
|
||||||
|
struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg;
|
||||||
|
struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
|
||||||
|
|
||||||
if (ioapics[idx].irqdomain) {
|
if (ioapics[idx].irqdomain) {
|
||||||
irq_domain_remove(ioapics[idx].irqdomain);
|
irq_domain_remove(ioapics[idx].irqdomain);
|
||||||
|
if (!cfg->dev)
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
ioapics[idx].irqdomain = NULL;
|
ioapics[idx].irqdomain = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,6 +560,10 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq,
|
||||||
* as that can corrupt the affinity move state.
|
* as that can corrupt the affinity move state.
|
||||||
*/
|
*/
|
||||||
irqd_set_handle_enforce_irqctx(irqd);
|
irqd_set_handle_enforce_irqctx(irqd);
|
||||||
|
|
||||||
|
/* Don't invoke affinity setter on deactivated interrupts */
|
||||||
|
irqd_set_affinity_on_activate(irqd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Legacy vectors are already assigned when the IOAPIC
|
* Legacy vectors are already assigned when the IOAPIC
|
||||||
* takes them over. They stay on the same vector. This is
|
* takes them over. They stay on the same vector. This is
|
||||||
|
|
|
@ -628,13 +628,21 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
|
||||||
|
|
||||||
static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
|
static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
|
||||||
{
|
{
|
||||||
|
struct fwnode_handle *fn;
|
||||||
|
|
||||||
if (iommu && iommu->ir_table) {
|
if (iommu && iommu->ir_table) {
|
||||||
if (iommu->ir_msi_domain) {
|
if (iommu->ir_msi_domain) {
|
||||||
|
fn = iommu->ir_msi_domain->fwnode;
|
||||||
|
|
||||||
irq_domain_remove(iommu->ir_msi_domain);
|
irq_domain_remove(iommu->ir_msi_domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
iommu->ir_msi_domain = NULL;
|
iommu->ir_msi_domain = NULL;
|
||||||
}
|
}
|
||||||
if (iommu->ir_domain) {
|
if (iommu->ir_domain) {
|
||||||
|
fn = iommu->ir_domain->fwnode;
|
||||||
|
|
||||||
irq_domain_remove(iommu->ir_domain);
|
irq_domain_remove(iommu->ir_domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
iommu->ir_domain = NULL;
|
iommu->ir_domain = NULL;
|
||||||
}
|
}
|
||||||
free_pages((unsigned long)iommu->ir_table->base,
|
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,
|
||||||
msi_alloc_info_t *info = args;
|
msi_alloc_info_t *info = args;
|
||||||
struct its_device *its_dev = info->scratchpad[0].ptr;
|
struct its_device *its_dev = info->scratchpad[0].ptr;
|
||||||
struct its_node *its = its_dev->its;
|
struct its_node *its = its_dev->its;
|
||||||
|
struct irq_data *irqd;
|
||||||
irq_hw_number_t hwirq;
|
irq_hw_number_t hwirq;
|
||||||
int err;
|
int err;
|
||||||
int i;
|
int i;
|
||||||
|
@ -3542,7 +3543,9 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
|
||||||
|
|
||||||
irq_domain_set_hwirq_and_chip(domain, virq + i,
|
irq_domain_set_hwirq_and_chip(domain, virq + i,
|
||||||
hwirq + i, &its_irq_chip, its_dev);
|
hwirq + i, &its_irq_chip, its_dev);
|
||||||
irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq + i)));
|
irqd = irq_get_irq_data(virq + i);
|
||||||
|
irqd_set_single_target(irqd);
|
||||||
|
irqd_set_affinity_on_activate(irqd);
|
||||||
pr_debug("ID:%d pID:%d vID:%d\n",
|
pr_debug("ID:%d pID:%d vID:%d\n",
|
||||||
(int)(hwirq + i - its_dev->event_map.lpi_base),
|
(int)(hwirq + i - its_dev->event_map.lpi_base),
|
||||||
(int)(hwirq + i), virq + i);
|
(int)(hwirq + i), virq + i);
|
||||||
|
|
|
@ -616,7 +616,10 @@ static int ioc3_mfd_probe(struct pci_dev *pdev,
|
||||||
/* Remove all already added MFD devices */
|
/* Remove all already added MFD devices */
|
||||||
mfd_remove_devices(&ipd->pdev->dev);
|
mfd_remove_devices(&ipd->pdev->dev);
|
||||||
if (ipd->domain) {
|
if (ipd->domain) {
|
||||||
|
struct fwnode_handle *fn = ipd->domain->fwnode;
|
||||||
|
|
||||||
irq_domain_remove(ipd->domain);
|
irq_domain_remove(ipd->domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
free_irq(ipd->domain_irq, (void *)ipd);
|
free_irq(ipd->domain_irq, (void *)ipd);
|
||||||
}
|
}
|
||||||
pci_iounmap(pdev, regs);
|
pci_iounmap(pdev, regs);
|
||||||
|
@ -643,7 +646,10 @@ static void ioc3_mfd_remove(struct pci_dev *pdev)
|
||||||
/* Release resources */
|
/* Release resources */
|
||||||
mfd_remove_devices(&ipd->pdev->dev);
|
mfd_remove_devices(&ipd->pdev->dev);
|
||||||
if (ipd->domain) {
|
if (ipd->domain) {
|
||||||
|
struct fwnode_handle *fn = ipd->domain->fwnode;
|
||||||
|
|
||||||
irq_domain_remove(ipd->domain);
|
irq_domain_remove(ipd->domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
free_irq(ipd->domain_irq, (void *)ipd);
|
free_irq(ipd->domain_irq, (void *)ipd);
|
||||||
}
|
}
|
||||||
pci_iounmap(pdev, ipd->regs);
|
pci_iounmap(pdev, ipd->regs);
|
||||||
|
|
|
@ -560,6 +560,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
|
||||||
if (!vmd->bus) {
|
if (!vmd->bus) {
|
||||||
pci_free_resource_list(&resources);
|
pci_free_resource_list(&resources);
|
||||||
irq_domain_remove(vmd->irq_domain);
|
irq_domain_remove(vmd->irq_domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,6 +674,7 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd)
|
||||||
static void vmd_remove(struct pci_dev *dev)
|
static void vmd_remove(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
struct vmd_dev *vmd = pci_get_drvdata(dev);
|
struct vmd_dev *vmd = pci_get_drvdata(dev);
|
||||||
|
struct fwnode_handle *fn = vmd->irq_domain->fwnode;
|
||||||
|
|
||||||
sysfs_remove_link(&vmd->dev->dev.kobj, "domain");
|
sysfs_remove_link(&vmd->dev->dev.kobj, "domain");
|
||||||
pci_stop_root_bus(vmd->bus);
|
pci_stop_root_bus(vmd->bus);
|
||||||
|
@ -680,6 +682,7 @@ static void vmd_remove(struct pci_dev *dev)
|
||||||
vmd_cleanup_srcu(vmd);
|
vmd_cleanup_srcu(vmd);
|
||||||
vmd_detach_resources(vmd);
|
vmd_detach_resources(vmd);
|
||||||
irq_domain_remove(vmd->irq_domain);
|
irq_domain_remove(vmd->irq_domain);
|
||||||
|
irq_domain_free_fwnode(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
|
|
@ -213,6 +213,8 @@ struct irq_data {
|
||||||
* required
|
* required
|
||||||
* IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked
|
* IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked
|
||||||
* from actual interrupt context.
|
* from actual interrupt context.
|
||||||
|
* IRQD_AFFINITY_ON_ACTIVATE - Affinity is set on activation. Don't call
|
||||||
|
* irq_chip::irq_set_affinity() when deactivated.
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
IRQD_TRIGGER_MASK = 0xf,
|
IRQD_TRIGGER_MASK = 0xf,
|
||||||
|
@ -237,6 +239,7 @@ enum {
|
||||||
IRQD_CAN_RESERVE = (1 << 26),
|
IRQD_CAN_RESERVE = (1 << 26),
|
||||||
IRQD_MSI_NOMASK_QUIRK = (1 << 27),
|
IRQD_MSI_NOMASK_QUIRK = (1 << 27),
|
||||||
IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28),
|
IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28),
|
||||||
|
IRQD_AFFINITY_ON_ACTIVATE = (1 << 29),
|
||||||
};
|
};
|
||||||
|
|
||||||
#define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors)
|
#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)
|
||||||
return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK;
|
return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void irqd_set_affinity_on_activate(struct irq_data *d)
|
||||||
|
{
|
||||||
|
__irqd_to_state(d) |= IRQD_AFFINITY_ON_ACTIVATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool irqd_affinity_on_activate(struct irq_data *d)
|
||||||
|
{
|
||||||
|
return __irqd_to_state(d) & IRQD_AFFINITY_ON_ACTIVATE;
|
||||||
|
}
|
||||||
|
|
||||||
#undef __irqd_to_state
|
#undef __irqd_to_state
|
||||||
|
|
||||||
static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
|
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[] = {
|
||||||
BIT_MASK_DESCR(IRQD_AFFINITY_SET),
|
BIT_MASK_DESCR(IRQD_AFFINITY_SET),
|
||||||
BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING),
|
BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING),
|
||||||
BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED),
|
BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED),
|
||||||
|
BIT_MASK_DESCR(IRQD_AFFINITY_ON_ACTIVATE),
|
||||||
BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN),
|
BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN),
|
||||||
BIT_MASK_DESCR(IRQD_CAN_RESERVE),
|
BIT_MASK_DESCR(IRQD_CAN_RESERVE),
|
||||||
BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK),
|
BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK),
|
||||||
|
@ -120,6 +121,10 @@ static const struct irq_bit_descr irqdata_states[] = {
|
||||||
|
|
||||||
BIT_MASK_DESCR(IRQD_WAKEUP_STATE),
|
BIT_MASK_DESCR(IRQD_WAKEUP_STATE),
|
||||||
BIT_MASK_DESCR(IRQD_WAKEUP_ARMED),
|
BIT_MASK_DESCR(IRQD_WAKEUP_ARMED),
|
||||||
|
|
||||||
|
BIT_MASK_DESCR(IRQD_DEFAULT_TRIGGER_SET),
|
||||||
|
|
||||||
|
BIT_MASK_DESCR(IRQD_HANDLE_ENFORCE_IRQCTX),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct irq_bit_descr irqdesc_states[] = {
|
static const struct irq_bit_descr irqdesc_states[] = {
|
||||||
|
|
|
@ -320,12 +320,16 @@ static bool irq_set_affinity_deactivated(struct irq_data *data,
|
||||||
struct irq_desc *desc = irq_data_to_desc(data);
|
struct irq_desc *desc = irq_data_to_desc(data);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Handle irq chips which can handle affinity only in activated
|
||||||
|
* state correctly
|
||||||
|
*
|
||||||
* If the interrupt is not yet activated, just store the affinity
|
* If the interrupt is not yet activated, just store the affinity
|
||||||
* mask and do not call the chip driver at all. On activation the
|
* mask and do not call the chip driver at all. On activation the
|
||||||
* driver has to make sure anyway that the interrupt is in a
|
* driver has to make sure anyway that the interrupt is in a
|
||||||
* useable state so startup works.
|
* useable state so startup works.
|
||||||
*/
|
*/
|
||||||
if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) || irqd_is_activated(data))
|
if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) ||
|
||||||
|
irqd_is_activated(data) || !irqd_affinity_on_activate(data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cpumask_copy(desc->irq_common_data.affinity, mask);
|
cpumask_copy(desc->irq_common_data.affinity, mask);
|
||||||
|
|
Loading…
Reference in a new issue