From 5469ac9d1c012316d3ac8102d9f5ef9142513d68 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 2 Mar 2011 21:57:40 +0000 Subject: [PATCH] When probing the PCI bars, make sure to only probe BARS (PPBs and PCB has fewer bars than type 0 devices). --- sys/dev/pci/pci.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 16a8645a7f36..2e8f387aeca8 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: pci.c,v 1.134 2011/02/27 18:10:25 jmcneill Exp $ */ +/* $NetBSD: pci.c,v 1.135 2011/03/02 21:57:40 matt Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.134 2011/02/27 18:10:25 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.135 2011/03/02 21:57:40 matt Exp $"); #include "opt_pci.h" @@ -272,7 +272,7 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag, { pci_chipset_tag_t pc = sc->sc_pc; struct pci_attach_args pa; - pcireg_t id, csr, class, intr, bhlcr, bar; + pcireg_t id, csr, class, intr, bhlcr, bar, endbar; int ret, pin, bus, device, function, i, width; int locs[PCICF_NLOCS]; @@ -301,7 +301,12 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag, memset(sc->PCI_SC_DEVICESC(device, function).c_range, 0, sizeof(sc->PCI_SC_DEVICESC(device, function).c_range)); i = 0; - for (bar = PCI_MAPREG_START; bar < PCI_MAPREG_END; bar += width) { + switch (PCI_HDRTYPE_TYPE(bhlcr)) { + case PCI_HDRTYPE_PPB: endbar = PCI_MAPREG_PPB_END; break; + case PCI_HDRTYPE_PCB: endbar = PCI_MAPREG_PCB_END; break; + default: endbar = PCI_MAPREG_END; break; + } + for (bar = PCI_MAPREG_START; bar < endbar; bar += width) { struct pci_range *r; pcireg_t type;