diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-12-14 17:36:13 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-12-14 17:36:13 +0000 |
commit | c4c3193cc824f923b4f1e5b8c5ec27c32bbbcd8f (patch) | |
tree | b468fde9421bc79f715486e8c79db8efe9bb2abd /sys/dev/pci | |
parent | 95476d7a5b0c0ad0d5c49ec2f74336bdafa725a3 (diff) |
Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.
ok deraadt@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/pci.c | 13 | ||||
-rw-r--r-- | sys/dev/pci/pcivar.h | 10 | ||||
-rw-r--r-- | sys/dev/pci/ppb.c | 3 |
3 files changed, 20 insertions, 6 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 143952ea170..f9f62a68882 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.48 2006/12/11 19:47:37 kettenis Exp $ */ +/* $OpenBSD: pci.c,v 1.49 2006/12/14 17:36:12 kettenis Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -72,6 +72,8 @@ struct cfdriver pci_cd = { NULL, "pci", DV_DULL }; +int pci_ndomains; + int pciprint(void *, const char *); int pcisubmatch(struct device *, void *, void *); @@ -150,6 +152,7 @@ pciattach(struct device *parent, struct device *self, void *aux) sc->sc_memt = pba->pba_memt; sc->sc_dmat = pba->pba_dmat; sc->sc_pc = pba->pba_pc; + sc->sc_domain = pba->pba_domain; sc->sc_bus = pba->pba_bus; sc->sc_bridgetag = pba->pba_bridgetag; sc->sc_maxndevs = pci_bus_maxdevs(pba->pba_pc, pba->pba_bus); @@ -265,6 +268,7 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag, pa.pa_memt = sc->sc_memt; pa.pa_dmat = sc->sc_dmat; pa.pa_pc = pc; + pa.pa_domain = sc->sc_domain; pa.pa_bus = bus; pa.pa_device = device; pa.pa_function = function; @@ -496,6 +500,10 @@ pciopen(dev_t dev, int oflags, int devtype, struct proc *p) { PCIDEBUG(("pciopen ndevs: %d\n" , pci_cd.cd_ndevs)); + if (minor(dev) >= pci_ndomains) { + return ENXIO; + } + #ifndef APERTURE if ((oflags & FWRITE) && securelevel > 0) { return EPERM; @@ -533,7 +541,8 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) for (i = 0; i < pci_cd.cd_ndevs; i++) { pci = pci_cd.cd_devs[i]; - if (pci != NULL && pci->sc_bus == io->pi_sel.pc_bus) + if (pci != NULL && pci->sc_domain == minor(dev) && + pci->sc_bus == io->pi_sel.pc_bus) break; } if (pci != NULL && pci->sc_bus == io->pi_sel.pc_bus) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 27396b2c348..99cafa18b2d 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcivar.h,v 1.49 2006/12/11 19:47:37 kettenis Exp $ */ +/* $OpenBSD: pcivar.h,v 1.50 2006/12/14 17:36:12 kettenis Exp $ */ /* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -80,6 +80,7 @@ struct pcibus_attach_args { bus_dma_tag_t pba_dmat; /* DMA tag */ pci_chipset_tag_t pba_pc; + int pba_domain; /* PCI domain */ int pba_bus; /* PCI bus number */ /* @@ -106,8 +107,9 @@ struct pci_attach_args { pci_chipset_tag_t pa_pc; int pa_flags; /* flags; see below */ - u_int pa_device; + u_int pa_domain; u_int pa_bus; + u_int pa_device; u_int pa_function; pcitag_t pa_tag; pcireg_t pa_id, pa_class; @@ -159,12 +161,14 @@ struct pci_softc { pci_chipset_tag_t sc_pc; void *sc_powerhook; LIST_HEAD(, pci_dev) sc_devs; - int sc_bus, sc_maxndevs; + int sc_domain, sc_bus, sc_maxndevs; pcitag_t *sc_bridgetag; u_int sc_intrswiz; pcitag_t sc_intrtag; }; +extern int pci_ndomains; + /* * Locators devices that attach to 'pcibus', as specified to config. */ diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c index bd21727ff23..84470f0fab6 100644 --- a/sys/dev/pci/ppb.c +++ b/sys/dev/pci/ppb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppb.c,v 1.16 2006/07/04 18:26:30 kettenis Exp $ */ +/* $OpenBSD: ppb.c,v 1.17 2006/12/14 17:36:12 kettenis Exp $ */ /* $NetBSD: ppb.c,v 1.16 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -131,6 +131,7 @@ ppbattach(struct device *parent, struct device *self, void *aux) #if 0 pba.pba_flags = pa->pa_flags & ~PCI_FLAGS_MRM_OKAY; #endif + pba.pba_domain = pa->pa_domain; pba.pba_bus = PPB_BUSINFO_SECONDARY(busdata); pba.pba_bridgetag = &sc->sc_tag; pba.pba_intrswiz = pa->pa_intrswiz; |