Port-i386 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-i386/38729: ACPI kernel booted under qemu cannot detect devices



The attached patch fixes PCI bus detection issues in qemu with ACPI
enabled. It should apply cleanly to 5.0, and amd64 machdep will probably
need the same treatment but I cannot test.

Cheers,
Jared
Index: i386/i386/mainbus.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/i386/mainbus.c,v
retrieving revision 1.77
diff -u -p -r1.77 mainbus.c
--- i386/i386/mainbus.c 18 May 2008 02:06:14 -0000      1.77
+++ i386/i386/mainbus.c 24 Mar 2009 13:38:35 -0000
@@ -319,6 +319,8 @@ mainbus_attach(struct device *parent, st
         */
 #if NPCI > 0
        if (pci_mode != 0) {
+               int npcibus = 0;
+
                mba.mba_pba.pba_iot = X86_BUS_SPACE_IO;
                mba.mba_pba.pba_memt = X86_BUS_SPACE_MEM;
                mba.mba_pba.pba_dmat = &pci_bus_dma_tag;
@@ -328,16 +330,18 @@ mainbus_attach(struct device *parent, st
                mba.mba_pba.pba_bus = 0;
                mba.mba_pba.pba_bridgetag = NULL;
 #if NACPI > 0 && defined(ACPI_SCANPCI)
-               if (mpacpi_active)
-                       mpacpi_scan_pci(self, &mba.mba_pba, pcibusprint);
-               else
+               if (npcibus == 0 && mpacpi_active)
+                       npcibus = mpacpi_scan_pci(self, &mba.mba_pba,
+                           pcibusprint);
 #endif
 #if defined(MPBIOS) && defined(MPBIOS_SCANPCI)
-               if (mpbios_scanned != 0)
-                       mpbios_scan_pci(self, &mba.mba_pba, pcibusprint);
-               else
-#endif
-               config_found_ia(self, "pcibus", &mba.mba_pba, pcibusprint);
+               if (npcibus == 0 && mpbios_scanned != 0)
+                       npcibus = mpbios_scan_pci(self, &mba.mba_pba,
+                           pcibusprint);
+#endif
+               if (npcibus == 0)
+                       config_found_ia(self, "pcibus", &mba.mba_pba,
+                           pcibusprint);
 #if NACPI > 0
                if (mp_verbose)
                        acpi_pci_link_state();
Index: x86/x86/mpacpi.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/mpacpi.c,v
retrieving revision 1.69.4.1
diff -u -p -r1.69.4.1 mpacpi.c
--- x86/x86/mpacpi.c    16 Jan 2009 21:35:43 -0000      1.69.4.1
+++ x86/x86/mpacpi.c    24 Mar 2009 13:38:35 -0000
@@ -1165,7 +1165,7 @@ int
 mpacpi_scan_pci(struct device *self, struct pcibus_attach_args *pba,
                cfprint_t print)
 {
-       int i;
+       int i, cnt = 0;
        struct mp_bus *mpb;
        struct pci_attach_args;
 
@@ -1176,9 +1176,10 @@ mpacpi_scan_pci(struct device *self, str
                if (!strcmp(mpb->mb_name, "pci") && mpb->mb_configured == 0) {
                        pba->pba_bus = i;
                        config_found_ia(self, "pcibus", pba, print);
+                       ++cnt;
                }
        }
-       return 0;
+       return cnt;
 }
 
 #endif
Index: x86/x86/mpbios.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/mpbios.c,v
retrieving revision 1.47
diff -u -p -r1.47 mpbios.c
--- x86/x86/mpbios.c    26 Aug 2008 12:04:18 -0000      1.47
+++ x86/x86/mpbios.c    24 Mar 2009 13:38:35 -0000
@@ -1203,7 +1203,7 @@ int
 mpbios_scan_pci(struct device *self, struct pcibus_attach_args *pba,
                cfprint_t print)
 {
-       int i;
+       int i, cnt = 0;
        struct mp_bus *mpb;
        struct pci_attach_args;
 
@@ -1214,9 +1214,10 @@ mpbios_scan_pci(struct device *self, str
                if (!strcmp(mpb->mb_name, "pci") && mpb->mb_configured == 0) {
                        pba->pba_bus = i;
                        config_found_ia(self, "pcibus", pba, print);
+                       ++cnt;
                }
        }
-       return 0;
+       return cnt;
 }
 
 #endif


Home | Main Index | Thread Index | Old Index