Apply fixes from jmcneill@ for PR port-i386/38729

(ACPI kernel booted under qemu cannot detect devices):
- make MP SCANPCI function for ACPI_SCANPCI and MPBIOS_SCANPCI
  return a number of attached PCI busses
- if no valid PCI busses are attached in the MP SCANPCI function,
  try to probe and attach pci0 at mainbus as well as kernels
  with no SCANPCI options

"Feel free to check it in" from jmcneill@.
Tested in pkgsrc qemu-0.9.1 (both i386 and x86_64) on NetBSD/i386.

Note original jmcneill's patch was posted on March:
http://mail-index.NetBSD.org/port-i386/2009/03/24/msg001281.html
and I also applied it to amd64:
http://mail-index.NetBSD.org/port-i386/2009/03/24/msg001283.html
but x86 MP attach functions have been reorganized by dyoung@ on April:
http://mail-index.NetBSD.org/source-changes/2009/04/17/msg219992.html
so I've modified the original patches to adapt the changes.
(mpacpi_scan_pci() and mpbios_scan_pci() have been merged into
 common mp_pci_scan() in new arch/x86/x86/mp.c)
For netbsd-5 and netbsd-5-0 branches, the original patches should be
applied cleanly, and they have been tested by abs@ on a selection of
i386 boxes and in qemu.
This commit is contained in:
tsutsui 2009-06-13 13:35:11 +00:00
parent 4a186c8fa5
commit 9c2e10416b
3 changed files with 26 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mainbus.c,v 1.27 2009/04/17 21:07:58 dyoung Exp $ */
/* $NetBSD: mainbus.c,v 1.28 2009/06/13 13:35:11 tsutsui Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.27 2009/04/17 21:07:58 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.28 2009/06/13 13:35:11 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -253,6 +253,8 @@ mainbus_attach(device_t parent, device_t self, void *aux)
#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;
@ -262,16 +264,16 @@ mainbus_attach(device_t parent, device_t self, void *aux)
mba.mba_pba.pba_bus = 0;
mba.mba_pba.pba_bridgetag = NULL;
#if NACPI > 0 && defined(ACPI_SCANPCI)
if (mpacpi_active)
mp_pci_scan(self, &mba.mba_pba, pcibusprint);
else
if (npcibus == 0 && mpacpi_active)
npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint);
#endif
#if defined(MPBIOS) && defined(MPBIOS_SCANPCI)
if (mpbios_scanned != 0)
mp_pci_scan(self, &mba.mba_pba, pcibusprint);
else
if (npcibus == 0 && mpbios_scanned != 0)
npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint);
#endif
config_found_ia(self, "pcibus", &mba.mba_pba, pcibusprint);
if (npcibus == 0)
config_found_ia(self, "pcibus", &mba.mba_pba,
pcibusprint);
#if NACPI > 0
if (mp_verbose)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mainbus.c,v 1.84 2009/04/17 21:07:58 dyoung Exp $ */
/* $NetBSD: mainbus.c,v 1.85 2009/06/13 13:35:11 tsutsui Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.84 2009/04/17 21:07:58 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.85 2009/06/13 13:35:11 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -396,6 +396,8 @@ mainbus_rescan(device_t self, const char *ifattr, const int *locators)
*/
#if NPCI > 0
if (pci_mode != 0 && ifattr_match(ifattr, "pcibus")) {
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;
@ -405,16 +407,14 @@ mainbus_rescan(device_t self, const char *ifattr, const int *locators)
mba.mba_pba.pba_bus = 0;
mba.mba_pba.pba_bridgetag = NULL;
#if NACPI > 0 && defined(ACPI_SCANPCI)
if (sc->sc_mpacpi_active)
mp_pci_scan(self, &mba.mba_pba, pcibusprint);
else
if (npcibus == 0 && sc->sc_mpacpi_active)
npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint);
#endif
#if defined(MPBIOS) && defined(MPBIOS_SCANPCI)
if (mpbios_scanned != 0)
mp_pci_scan(self, &mba.mba_pba, pcibusprint);
else
if (npcibus == 0 && mpbios_scanned != 0)
npcibus = mp_pci_scan(self, &mba.mba_pba, pcibusprint);
#endif
if (sc->sc_pci == NULL) {
if (npcibus == 0 && sc->sc_pci == NULL) {
sc->sc_pci = config_found_ia(self, "pcibus",
&mba.mba_pba, pcibusprint);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mp.c,v 1.1 2009/04/17 21:07:58 dyoung Exp $ */
/* $NetBSD: mp.c,v 1.2 2009/06/13 13:35:11 tsutsui Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.1 2009/04/17 21:07:58 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: mp.c,v 1.2 2009/06/13 13:35:11 tsutsui Exp $");
#include "opt_multiprocessor.h"
#include "pchb.h"
@ -64,9 +64,10 @@ int
mp_pci_scan(device_t self, struct pcibus_attach_args *pba,
cfprint_t print)
{
int i;
int i, cnt;
struct mp_bus *mpb;
cnt = 0;
for (i = 0; i < mp_nbus; i++) {
mpb = &mp_busses[i];
if (mpb->mb_name == NULL)
@ -75,9 +76,10 @@ mp_pci_scan(device_t self, struct pcibus_attach_args *pba,
pba->pba_bus = i;
mpb->mb_dev =
config_found_ia(self, "pcibus", pba, print);
cnt++;
}
}
return 0;
return cnt;
}
void