linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/PCI: Use MMCONFIG by default for KVM guests
@ 2020-07-22  0:15 Julia Suvorova
  2020-07-22  2:59 ` Matthew Wilcox
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Julia Suvorova @ 2020-07-22  0:15 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Bjorn Helgaas, Michael S. Tsirkin, Matthew Wilcox,
	Vitaly Kuznetsov, Julia Suvorova

Scanning for PCI devices at boot takes a long time for KVM guests. It
can be reduced if KVM will handle all configuration space accesses for
non-existent devices without going to userspace [1]. But for this to
work, all accesses must go through MMCONFIG.
This change allows to use pci_mmcfg as raw_pci_ops for 64-bit KVM
guests making MMCONFIG the default access method.

[1] https://lkml.org/lkml/2020/5/14/936

Signed-off-by: Julia Suvorova <jusual@redhat.com>
---
 arch/x86/pci/direct.c      | 5 +++++
 arch/x86/pci/mmconfig_64.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/arch/x86/pci/direct.c b/arch/x86/pci/direct.c
index a51074c55982..8ff6b65d8f48 100644
--- a/arch/x86/pci/direct.c
+++ b/arch/x86/pci/direct.c
@@ -6,6 +6,7 @@
 #include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/dmi.h>
+#include <linux/kvm_para.h>
 #include <asm/pci_x86.h>
 
 /*
@@ -264,6 +265,10 @@ void __init pci_direct_init(int type)
 {
 	if (type == 0)
 		return;
+
+	if (raw_pci_ext_ops && kvm_para_available())
+		return;
+
 	printk(KERN_INFO "PCI: Using configuration type %d for base access\n",
 		 type);
 	if (type == 1) {
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index 0c7b6e66c644..9eb772821766 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -10,6 +10,7 @@
 #include <linux/init.h>
 #include <linux/acpi.h>
 #include <linux/bitmap.h>
+#include <linux/kvm_para.h>
 #include <linux/rcupdate.h>
 #include <asm/e820/api.h>
 #include <asm/pci_x86.h>
@@ -122,6 +123,8 @@ int __init pci_mmcfg_arch_init(void)
 		}
 
 	raw_pci_ext_ops = &pci_mmcfg;
+	if (kvm_para_available())
+		raw_pci_ops = &pci_mmcfg;
 
 	return 1;
 }
-- 
2.25.4


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

end of thread, other threads:[~2020-07-29 14:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22  0:15 [PATCH] x86/PCI: Use MMCONFIG by default for KVM guests Julia Suvorova
2020-07-22  2:59 ` Matthew Wilcox
2020-07-22  9:43 ` Vitaly Kuznetsov
2020-07-26 18:35   ` Julia Suvorova
2020-07-27 14:04   ` Andy Shevchenko
2020-07-27 15:55     ` Vitaly Kuznetsov
2020-07-22 10:59 ` Michael S. Tsirkin
2020-07-22 23:19 ` Bjorn Helgaas
2020-07-26 18:58   ` Julia Suvorova
2020-07-29 14:43     ` Michael S. Tsirkin

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).