linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen/pci: try to reserve MCFG areas earlier
@ 2019-09-04  0:20 Igor Druzhinin
  2019-09-04  9:08 ` Jan Beulich
  2019-09-06 22:30 ` Boris Ostrovsky
  0 siblings, 2 replies; 22+ messages in thread
From: Igor Druzhinin @ 2019-09-04  0:20 UTC (permalink / raw)
  To: xen-devel, linux-kernel; +Cc: jgross, boris.ostrovsky, Igor Druzhinin

If MCFG area is not reserved in E820, Xen by default will defer its usage
until Dom0 registers it explicitly after ACPI parser recognizes it as
a reserved resource in DSDT. Having it reserved in E820 is not
mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2)
and firmware is free to keep a hole E820 in that place. Xen doesn't know
what exactly is inside this hole since it lacks full ACPI view of the
platform therefore it's potentially harmful to access MCFG region
without additional checks as some machines are known to provide
inconsistent information on the size of the region.

Now xen_mcfg_late() runs after acpi_init() which is too late as some basic
PCI enumeration starts exactly there. Trying to register a device prior
to MCFG reservation causes multiple problems with PCIe extended
capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are
no convenient hooks for us to subscribe to so try to register MCFG
areas earlier upon the first invocation of xen_add_device(). Keep the
existing initcall in case information of MCFG areas is updated later
in acpi_init().

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
 drivers/xen/pci.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c
index 7494dbe..800f415 100644
--- a/drivers/xen/pci.c
+++ b/drivers/xen/pci.c
@@ -29,6 +29,9 @@
 #include "../pci/pci.h"
 #ifdef CONFIG_PCI_MMCONFIG
 #include <asm/pci_x86.h>
+
+static int xen_mcfg_late(void);
+static bool __read_mostly pci_mcfg_reserved = false;
 #endif
 
 static bool __read_mostly pci_seg_supported = true;
@@ -41,6 +44,16 @@ static int xen_add_device(struct device *dev)
 	struct pci_dev *physfn = pci_dev->physfn;
 #endif
 
+#ifdef CONFIG_PCI_MMCONFIG
+	/*
+	 * Try to reserve MCFG areas discovered so far early on first invocation
+	 * due to this being potentially called from inside of acpi_init
+	 */
+	if (!pci_mcfg_reserved) {
+		xen_mcfg_late();
+		pci_mcfg_reserved = true;
+	}
+#endif
 	if (pci_seg_supported) {
 		struct {
 			struct physdev_pci_device_add add;
@@ -213,7 +226,7 @@ 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)
+static int xen_mcfg_late(void)
 {
 	struct pci_mmcfg_region *cfg;
 	int rc;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2019-09-12 17:34 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-04  0:20 [PATCH] xen/pci: try to reserve MCFG areas earlier Igor Druzhinin
2019-09-04  9:08 ` Jan Beulich
2019-09-04 11:36   ` Igor Druzhinin
2019-09-04 12:09     ` Jan Beulich
2019-09-06 22:30 ` Boris Ostrovsky
2019-09-06 23:00   ` Igor Druzhinin
2019-09-08 18:28     ` Boris Ostrovsky
2019-09-08 21:11       ` Igor Druzhinin
2019-09-08 23:30         ` Boris Ostrovsky
2019-09-08 23:37           ` Igor Druzhinin
2019-09-09 19:19             ` Boris Ostrovsky
2019-09-09 21:48               ` Igor Druzhinin
2019-09-10  1:47                 ` [Xen-devel] " Boris Ostrovsky
2019-09-10  9:46                   ` Igor Druzhinin
2019-09-10  9:55                     ` Jan Beulich
2019-09-10 10:08                       ` Igor Druzhinin
2019-09-10 17:48                     ` Boris Ostrovsky
2019-09-10 20:36                       ` Igor Druzhinin
2019-09-10 21:19                         ` Boris Ostrovsky
2019-09-11  1:15                           ` Igor Druzhinin
2019-09-11  9:13                             ` Jan Beulich
2019-09-12 17:33                             ` Boris Ostrovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).