Skip to content

Commit 335b422

Browse files
heynemaxjgross1
authored andcommitted
x86/pci/xen: populate MSI sysfs entries
Commit bf5e758 ("genirq/msi: Simplify sysfs handling") reworked the creation of sysfs entries for MSI IRQs. The creation used to be in msi_domain_alloc_irqs_descs_locked after calling ops->domain_alloc_irqs. Then it moved into __msi_domain_alloc_irqs which is an implementation of domain_alloc_irqs. However, Xen comes with the only other implementation of domain_alloc_irqs and hence doesn't run the sysfs population code anymore. Commit 6c79699 ("x86/pci/xen: Fixup fallout from the PCI/MSI overhaul") set the flag MSI_FLAG_DEV_SYSFS for the xen msi_domain_info but that doesn't actually have an effect because Xen uses it's own domain_alloc_irqs implementation. Fix this by making use of the fallback functions for sysfs population. Fixes: bf5e758 ("genirq/msi: Simplify sysfs handling") Signed-off-by: Maximilian Heyne <mheyne@amazon.de> Reviewed-by: Juergen Gross <jgross@suse.com> Link: https://lore.kernel.org/r/20230503131656.15928-1-mheyne@amazon.de Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 8fafac2 commit 335b422

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

arch/x86/pci/xen.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
198198
i++;
199199
}
200200
kfree(v);
201-
return 0;
201+
return msi_device_populate_sysfs(&dev->dev);
202202

203203
error:
204204
if (ret == -ENOSYS)
@@ -254,7 +254,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
254254
dev_dbg(&dev->dev,
255255
"xen: msi --> pirq=%d --> irq=%d\n", pirq, irq);
256256
}
257-
return 0;
257+
return msi_device_populate_sysfs(&dev->dev);
258258

259259
error:
260260
dev_err(&dev->dev, "Failed to create MSI%s! ret=%d!\n",
@@ -346,7 +346,7 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
346346
if (ret < 0)
347347
goto out;
348348
}
349-
ret = 0;
349+
ret = msi_device_populate_sysfs(&dev->dev);
350350
out:
351351
return ret;
352352
}
@@ -394,6 +394,8 @@ static void xen_teardown_msi_irqs(struct pci_dev *dev)
394394
xen_destroy_irq(msidesc->irq + i);
395395
msidesc->irq = 0;
396396
}
397+
398+
msi_device_destroy_sysfs(&dev->dev);
397399
}
398400

399401
static void xen_pv_teardown_msi_irqs(struct pci_dev *dev)

include/linux/msi.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,21 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc);
383383
void arch_teardown_msi_irq(unsigned int irq);
384384
int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
385385
void arch_teardown_msi_irqs(struct pci_dev *dev);
386+
#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */
387+
388+
/*
389+
* Xen uses non-default msi_domain_ops and hence needs a way to populate sysfs
390+
* entries of MSI IRQs.
391+
*/
392+
#if defined(CONFIG_PCI_XEN) || defined(CONFIG_PCI_MSI_ARCH_FALLBACKS)
386393
#ifdef CONFIG_SYSFS
387394
int msi_device_populate_sysfs(struct device *dev);
388395
void msi_device_destroy_sysfs(struct device *dev);
389396
#else /* CONFIG_SYSFS */
390397
static inline int msi_device_populate_sysfs(struct device *dev) { return 0; }
391398
static inline void msi_device_destroy_sysfs(struct device *dev) { }
392399
#endif /* !CONFIG_SYSFS */
393-
#endif /* CONFIG_PCI_MSI_ARCH_FALLBACKS */
400+
#endif /* CONFIG_PCI_XEN || CONFIG_PCI_MSI_ARCH_FALLBACKS */
394401

395402
/*
396403
* The restore hook is still available even for fully irq domain based

kernel/irq/msi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static int msi_sysfs_populate_desc(struct device *dev, struct msi_desc *desc)
542542
return ret;
543543
}
544544

545-
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
545+
#if defined(CONFIG_PCI_MSI_ARCH_FALLBACKS) || defined(CONFIG_PCI_XEN)
546546
/**
547547
* msi_device_populate_sysfs - Populate msi_irqs sysfs entries for a device
548548
* @dev: The device (PCI, platform etc) which will get sysfs entries
@@ -574,7 +574,7 @@ void msi_device_destroy_sysfs(struct device *dev)
574574
msi_for_each_desc(desc, dev, MSI_DESC_ALL)
575575
msi_sysfs_remove_desc(dev, desc);
576576
}
577-
#endif /* CONFIG_PCI_MSI_ARCH_FALLBACK */
577+
#endif /* CONFIG_PCI_MSI_ARCH_FALLBACK || CONFIG_PCI_XEN */
578578
#else /* CONFIG_SYSFS */
579579
static inline int msi_sysfs_create_group(struct device *dev) { return 0; }
580580
static inline int msi_sysfs_populate_desc(struct device *dev, struct msi_desc *desc) { return 0; }

0 commit comments

Comments
 (0)