77#include <linux/pci.h>
88#include <linux/logic_iomem.h>
99#include <linux/of_platform.h>
10+ #include <linux/irqchip/irq-msi-lib.h>
1011#include <linux/irqdomain.h>
1112#include <linux/msi.h>
1213#include <linux/unaligned.h>
@@ -29,7 +30,6 @@ static struct um_pci_device *um_pci_platform_device;
2930static struct um_pci_device_reg um_pci_devices [MAX_DEVICES ];
3031static struct fwnode_handle * um_pci_fwnode ;
3132static struct irq_domain * um_pci_inner_domain ;
32- static struct irq_domain * um_pci_msi_domain ;
3333static unsigned long um_pci_msi_used [BITS_TO_LONGS (MAX_MSI_VECTORS )];
3434
3535static unsigned long um_pci_cfgspace_read (void * priv , unsigned int offset ,
@@ -400,21 +400,24 @@ static void um_pci_inner_domain_free(struct irq_domain *domain,
400400}
401401
402402static const struct irq_domain_ops um_pci_inner_domain_ops = {
403+ .select = msi_lib_irq_domain_select ,
403404 .alloc = um_pci_inner_domain_alloc ,
404405 .free = um_pci_inner_domain_free ,
405406};
406407
407- static struct irq_chip um_pci_msi_irq_chip = {
408- .name = "UM virtual PCIe MSI" ,
409- .irq_mask = pci_msi_mask_irq ,
410- .irq_unmask = pci_msi_unmask_irq ,
411- };
412-
413- static struct msi_domain_info um_pci_msi_domain_info = {
414- .flags = MSI_FLAG_USE_DEF_DOM_OPS |
415- MSI_FLAG_USE_DEF_CHIP_OPS |
416- MSI_FLAG_PCI_MSIX ,
417- .chip = & um_pci_msi_irq_chip ,
408+ #define UM_PCI_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
409+ MSI_FLAG_USE_DEF_CHIP_OPS | \
410+ MSI_FLAG_NO_AFFINITY)
411+ #define UM_PCI_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
412+ MSI_FLAG_PCI_MSIX)
413+
414+ static const struct msi_parent_ops um_pci_msi_parent_ops = {
415+ .required_flags = UM_PCI_MSI_FLAGS_REQUIRED ,
416+ .supported_flags = UM_PCI_MSI_FLAGS_SUPPORTED ,
417+ .bus_select_token = DOMAIN_BUS_NEXUS ,
418+ .bus_select_mask = MATCH_PCI_MSI ,
419+ .prefix = "UM-virtual-" ,
420+ .init_dev_msi_info = msi_lib_init_dev_msi_info ,
418421};
419422
420423static struct resource busn_resource = {
@@ -559,17 +562,14 @@ static int __init um_pci_init(void)
559562 goto free ;
560563 }
561564
562- um_pci_inner_domain = irq_domain_create_linear (um_pci_fwnode , MAX_MSI_VECTORS ,
563- & um_pci_inner_domain_ops , NULL );
564- if (!um_pci_inner_domain ) {
565- err = - ENOMEM ;
566- goto free ;
567- }
565+ struct irq_domain_info info = {
566+ .fwnode = um_pci_fwnode ,
567+ .ops = & um_pci_inner_domain_ops ,
568+ .size = MAX_MSI_VECTORS ,
569+ };
568570
569- um_pci_msi_domain = pci_msi_create_irq_domain (um_pci_fwnode ,
570- & um_pci_msi_domain_info ,
571- um_pci_inner_domain );
572- if (!um_pci_msi_domain ) {
571+ um_pci_inner_domain = msi_create_parent_irq_domain (& info , & um_pci_msi_parent_ops );
572+ if (!um_pci_inner_domain ) {
573573 err = - ENOMEM ;
574574 goto free ;
575575 }
@@ -611,7 +611,6 @@ device_initcall(um_pci_init);
611611
612612static void __exit um_pci_exit (void )
613613{
614- irq_domain_remove (um_pci_msi_domain );
615614 irq_domain_remove (um_pci_inner_domain );
616615 pci_free_resource_list (& bridge -> windows );
617616 pci_free_host_bridge (bridge );
0 commit comments