Skip to content

Commit 2f285f4

Browse files
dcuiKAGA-KOKO
authored andcommitted
x86/hyperv: Suppress "PCI: Fatal: No config space access function found"
A Generation-2 Linux VM on Hyper-V doesn't have the legacy PCI bus, and users always see the scary warning, which is actually harmless. Suppress it. Signed-off-by: Dexuan Cui <decui@microsoft.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: KY Srinivasan <kys@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Stephen Hemminger <sthemmin@microsoft.com> Cc: "devel@linuxdriverproject.org" <devel@linuxdriverproject.org> Cc: Olaf Aepfle <olaf@aepfle.de> Cc: Andy Whitcroft <apw@canonical.com> Cc: Jason Wang <jasowang@redhat.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: Marcelo Cerri <marcelo.cerri@canonical.com> Cc: Josh Poulson <jopoulso@microsoft.com> Link: https://lkml.kernel.org/r/ <KU1P153MB0166D977DC930996C4BF538ABF1D0@KU1P153MB0166.APCP153.PROD.OUTLOOK.COM
1 parent c307aaf commit 2f285f4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

arch/x86/hyperv/hv_init.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*
1818
*/
1919

20+
#include <linux/efi.h>
2021
#include <linux/types.h>
2122
#include <asm/apic.h>
2223
#include <asm/desc.h>
@@ -253,6 +254,22 @@ static int hv_cpu_die(unsigned int cpu)
253254
return 0;
254255
}
255256

257+
static int __init hv_pci_init(void)
258+
{
259+
int gen2vm = efi_enabled(EFI_BOOT);
260+
261+
/*
262+
* For Generation-2 VM, we exit from pci_arch_init() by returning 0.
263+
* The purpose is to suppress the harmless warning:
264+
* "PCI: Fatal: No config space access function found"
265+
*/
266+
if (gen2vm)
267+
return 0;
268+
269+
/* For Generation-1 VM, we'll proceed in pci_arch_init(). */
270+
return 1;
271+
}
272+
256273
/*
257274
* This function is to be invoked early in the boot sequence after the
258275
* hypervisor has been detected.
@@ -329,6 +346,8 @@ void __init hyperv_init(void)
329346

330347
hv_apic_init();
331348

349+
x86_init.pci.arch_init = hv_pci_init;
350+
332351
/*
333352
* Register Hyper-V specific clocksource.
334353
*/

0 commit comments

Comments
 (0)