From: Julien Grall Date: Wed, 7 Jun 2017 13:55:49 +0000 (+0100) Subject: Implementation for registering hostbridge done X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Fdev-pci;p=people%2Fjulieng%2Flinux-arm.git Implementation for registering hostbridge done --- diff --git a/arch/arm/xen/pci.c b/arch/arm/xen/pci.c index 933b6b33fa59..dda1d7c76407 100644 --- a/arch/arm/xen/pci.c +++ b/arch/arm/xen/pci.c @@ -1,14 +1,58 @@ #include +#include #include +#include +#include +#include +#include +#include void xen_pci_register_host_bridge(struct pci_host_bridge *bridge) { -// struct physdev_pci_mmcfg_reserved r; + struct physdev_pci_mmcfg_reserved harg; struct pci_bus *bus = bridge->bus; + struct device *dev = bridge->dev.parent; + struct resource mmio_res, busr_res; + int err; - printk("============== Register Hostbridge ================\n"); + /* XXX: Implement ACPI */ + if (!acpi_disabled) + goto err; - printk("seg %u\n", pci_domain_nr(bus)); + /* + * For convience the resource 0 will always be used to fill the + * field 'address' of pci_mmcfg_reserved. + */ + err = of_address_to_resource(dev->of_node, 0, &mmio_res); + if (err) + goto err; - while (1); + /* + * bridge->windows should contain all the resources. However + * pci_register_host_register will move all the resources in a + * temporary list before calling pcibios_add_bus. So it is not + * possible to find the bus-range from that. Use the + * of_pci_parse_bus_range instead. + */ + err = of_pci_parse_bus_range(dev->of_node, &busr_res); + if (err) { + /* XXX: Assume the bus range is 0x00 - 0xff */ + busr_res.start = 0; + busr_res.end = 0xff; + } + + harg.address = mmio_res.start; + harg.segment = pci_domain_nr(bus); + harg.start_bus = busr_res.start; + harg.end_bus = busr_res.end; + harg.flags = XEN_PCI_MMCFG_RESERVED; + + err = HYPERVISOR_physdev_op(PHYSDEVOP_pci_mmcfg_reserved, &harg); + if ( err ) + goto err; + + return; + +err: + dev_err(dev, "xen: Failed to register hostbridge - passthrough might fail!\n"); } diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index 179494dc4ce8..1bb41f191e4a 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -213,7 +213,7 @@ void pcibios_add_bus(struct pci_bus *bus) * hooked up in another function or check if we are registering * the root parent */ - if (xen_initial_domain() && !pci_is_root_bus(bus)) + if (xen_initial_domain() && pci_is_root_bus(bus)) xen_pci_register_host_bridge(pci_find_host_bridge(bus)); }