From 8deb3eb1461e4cb136c88d03ec5a6729ccf2f933 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Fri, 25 Oct 2013 16:26:02 -0400 Subject: xen/mcfg: Call PHYSDEVOP_pci_mmcfg_reserved for MCFG areas. The PCI MMCONFIG area is usually reserved via the E820 so the Xen hypervisor is aware of these regions. But they can also be enumerated in the ACPI DSDT which means the hypervisor won't know of them until the initial domain informs it of via PHYSDEVOP_pci_mmcfg_reserved. This is what this patch does for all of the MCFG regions that the initial domain is aware of (E820 enumerated and ACPI). Reported-by: Santosh Jodh CC: Jan Beulich Reviewed-by: Boris Ostrovsky CC: David Vrabel CC: Mukesh Rathor Signed-off-by: Konrad Rzeszutek Wilk [v1: Redid it a bit] [v2: Dropped the P2M 1-1 setting] [v3: Check for Xen in-case we are running under baremetal] [v4: Wrap with CONFIG_PCI_MMCONFIG] --- drivers/xen/pci.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'drivers/xen/pci.c') diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c index 18fff88254eb..d15f6e80479f 100644 --- a/drivers/xen/pci.c +++ b/drivers/xen/pci.c @@ -26,6 +26,7 @@ #include #include #include "../pci/pci.h" +#include static bool __read_mostly pci_seg_supported = true; @@ -192,3 +193,49 @@ static int __init register_xen_pci_notifier(void) } arch_initcall(register_xen_pci_notifier); + +#ifdef CONFIG_PCI_MMCONFIG +static int __init xen_mcfg_late(void) +{ + struct pci_mmcfg_region *cfg; + int rc; + + if (!xen_initial_domain()) + return 0; + + if ((pci_probe & PCI_PROBE_MMCONF) == 0) + return 0; + + if (list_empty(&pci_mmcfg_list)) + return 0; + + /* Check whether they are in the right area. */ + list_for_each_entry(cfg, &pci_mmcfg_list, list) { + struct physdev_pci_mmcfg_reserved r; + + r.address = cfg->address; + r.segment = cfg->segment; + r.start_bus = cfg->start_bus; + r.end_bus = cfg->end_bus; + r.flags = XEN_PCI_MMCFG_RESERVED; + + rc = HYPERVISOR_physdev_op(PHYSDEVOP_pci_mmcfg_reserved, &r); + switch (rc) { + case 0: + case -ENOSYS: + continue; + + default: + pr_warn("Failed to report MMCONFIG reservation" + " state for %s to hypervisor" + " (%d)\n", + cfg->name, rc); + } + } + return 0; +} +/* + * Needs to be done after acpi_init which are subsys_initcall. + */ +subsys_initcall_sync(xen_mcfg_late); +#endif -- cgit v1.2.3-59-g8ed1b