Fix the semantics of __PCI_DEV_FUNCORDER so that they're actually useful:

If __PCI_DEV_FUNCORDER is defined, don't do the song-and-dance to check if
a device is multi-function; machdep code is going to tell us exactly which
functions to probe.

Note this required changing how pci_func_devorder() works in the
sparc64 PCI machdep code; now the "curnode" is assumed to point
to the bus, rather than some function (typically 0) on the device,
just as pci_bus_devorder() makes that assumption.

All this should allow the PCI code to actually locate the second
HME device on a Sun Netra t1, which is at 3,1 -- previously, the
PCI code would have missed it because there is no device at 3,0.

(Sun deserves a brick to the head for this one -- this seems clearly
out of line with the PCI spec.)
This commit is contained in:
thorpej 2001-10-17 22:16:41 +00:00
parent 663a1fb2a8
commit 397a84f51a
2 changed files with 16 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci_machdep.c,v 1.24 2001/09/15 19:32:14 mrg Exp $ */
/* $NetBSD: pci_machdep.c,v 1.25 2001/10/17 22:16:41 thorpej Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@ -171,13 +171,14 @@ pci_dev_funcorder(pc, busno, device, funcs)
}
#endif
/*
* Functions are siblings. Presumably we're only called when the
* first instance of this device is detected, so we should be able to
* get to all the other functions with OF_peer(). But there seems
* some issues with this scheme, so we always go to the first node on
* this bus segment for a scan.
* Initially, curnode is the root of the pci tree. As we
* attach bridges, curnode should be set to that of the bridge.
*
* Note this search is almost exactly the same as pci_bus_devorder()'s,
* except that we limit the search to only those with a matching
* "device" number.
*/
for (node = OF_child(OF_parent(node)); node; node = OF_peer(node)) {
for (node = OF_child(node); node; node = OF_peer(node)) {
len = OF_getproplen(node, "reg");
if (len < sizeof(reg))
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci.c,v 1.56 2001/09/13 21:49:40 thorpej Exp $ */
/* $NetBSD: pci.c,v 1.57 2001/10/17 22:16:41 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998
@ -127,7 +127,6 @@ pci_probe_bus(struct device *self, int (*match)(struct pci_attach_args *),
struct pci_softc *sc = (struct pci_softc *)self;
bus_space_tag_t iot, memt;
pci_chipset_tag_t pc;
const struct pci_quirkdata *qd;
int bus, device, function, nfunctions, ret;
#ifdef __PCI_BUS_DEVORDER
char devs[32];
@ -136,6 +135,8 @@ pci_probe_bus(struct device *self, int (*match)(struct pci_attach_args *),
#ifdef __PCI_DEV_FUNCORDER
char funcs[8];
int j;
#else
const struct pci_quirkdata *qd;
#endif
iot = sc->sc_iot;
@ -154,6 +155,10 @@ pci_probe_bus(struct device *self, int (*match)(struct pci_attach_args *),
struct pci_attach_args pa;
int pin;
#ifdef __PCI_DEV_FUNCORDER
pci_dev_funcorder(sc->sc_pc, sc->sc_bus, device, funcs);
nfunctions = 8;
#else
tag = pci_make_tag(pc, bus, device, 0);
id = pci_conf_read(pc, tag, PCI_ID_REG);
@ -173,9 +178,9 @@ pci_probe_bus(struct device *self, int (*match)(struct pci_attach_args *),
nfunctions = 8;
else
nfunctions = 1;
#endif /* __PCI_DEV_FUNCORDER */
#ifdef __PCI_DEV_FUNCORDER
pci_dev_funcorder(sc->sc_pc, sc->sc_bus, device, funcs);
for (j = 0; (function = funcs[j]) < nfunctions &&
function >= 0; j++)
#else