PCI: hv: Set up MSI domain at bridge probing time
authorBoqun Feng <boqun.feng@gmail.com>
Mon, 26 Jul 2021 18:06:56 +0000 (02:06 +0800)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 23 Aug 2021 09:59:27 +0000 (10:59 +0100)
Since PCI_HYPERV depends on PCI_MSI_IRQ_DOMAIN which selects
GENERIC_MSI_IRQ_DOMAIN, we can use dev_set_msi_domain() to set up the
MSI domain at probing time, and this works for both x86 and ARM64.

Therefore use it as the preparation for ARM64 Hyper-V PCI support.

As a result, no longer need to maintain ->fwnode in x86 specific
pci_sysdata, and make hv_pcibus_device own it instead.

Link: https://lore.kernel.org/r/20210726180657.142727-8-boqun.feng@gmail.com
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
drivers/pci/controller/pci-hyperv.c

index 5741b1dd3c14508c68969484d20e0e2ab5792c60..e6276aaa46595ceaec51e51f66728b74b6881e68 100644 (file)
@@ -450,6 +450,7 @@ enum hv_pcibus_state {
 struct hv_pcibus_device {
        struct pci_sysdata sysdata;
        struct pci_host_bridge *bridge;
+       struct fwnode_handle *fwnode;
        /* Protocol version negotiated with the host */
        enum pci_protocol_version_t protocol_version;
        enum hv_pcibus_state state;
@@ -1565,7 +1566,7 @@ static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus)
        hbus->msi_info.handler = handle_edge_irq;
        hbus->msi_info.handler_name = "edge";
        hbus->msi_info.data = hbus;
-       hbus->irq_domain = pci_msi_create_irq_domain(hbus->sysdata.fwnode,
+       hbus->irq_domain = pci_msi_create_irq_domain(hbus->fwnode,
                                                     &hbus->msi_info,
                                                     x86_vector_domain);
        if (!hbus->irq_domain) {
@@ -1574,6 +1575,8 @@ static int hv_pcie_init_irq_domain(struct hv_pcibus_device *hbus)
                return -ENODEV;
        }
 
+       dev_set_msi_domain(&hbus->bridge->dev, hbus->irq_domain);
+
        return 0;
 }
 
@@ -3118,9 +3121,9 @@ static int hv_pci_probe(struct hv_device *hdev,
                goto unmap;
        }
 
-       hbus->sysdata.fwnode = irq_domain_alloc_named_fwnode(name);
+       hbus->fwnode = irq_domain_alloc_named_fwnode(name);
        kfree(name);
-       if (!hbus->sysdata.fwnode) {
+       if (!hbus->fwnode) {
                ret = -ENOMEM;
                goto unmap;
        }
@@ -3198,7 +3201,7 @@ exit_d0:
 free_irq_domain:
        irq_domain_remove(hbus->irq_domain);
 free_fwnode:
-       irq_domain_free_fwnode(hbus->sysdata.fwnode);
+       irq_domain_free_fwnode(hbus->fwnode);
 unmap:
        iounmap(hbus->cfg_addr);
 free_config:
@@ -3314,7 +3317,7 @@ static int hv_pci_remove(struct hv_device *hdev)
        hv_free_config_window(hbus);
        hv_pci_free_bridge_windows(hbus);
        irq_domain_remove(hbus->irq_domain);
-       irq_domain_free_fwnode(hbus->sysdata.fwnode);
+       irq_domain_free_fwnode(hbus->fwnode);
 
        hv_put_dom_num(hbus->bridge->domain_nr);