diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-07-04 18:07:30 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2006-07-04 18:07:30 +0000 |
commit | 3608a6714c5af67249bc89f89d148f1bf781b3fe (patch) | |
tree | 27a7720afc985f6ea709279045e08ce7416a7a75 /sys | |
parent | 2ee332f19d8c17ffec6b2885a1433ae59f06f12d (diff) |
Do not blindly enable io and mem space for all matched PCI devices. This is
known to be wrong for legacy VGA devices. It also seems to have bad side
effects for some unconfigured PCI-PCI bridges. Instead, enable io or mem
space when we map it.
ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/pci.c | 22 | ||||
-rw-r--r-- | sys/dev/pci/pci_map.c | 12 |
2 files changed, 13 insertions, 21 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index eb28392e01e..e68226b8cbd 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.c,v 1.45 2006/03/22 00:36:03 jsg Exp $ */ +/* $OpenBSD: pci.c,v 1.46 2006/07/04 18:07:29 kettenis Exp $ */ /* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */ /* @@ -222,7 +222,6 @@ pcisubmatch(struct device *parent, void *match, void *aux) { struct cfdata *cf = match; struct pci_attach_args *pa = aux; - int success; if (cf->pcicf_dev != PCI_UNK_DEV && cf->pcicf_dev != pa->pa_device) @@ -231,24 +230,7 @@ pcisubmatch(struct device *parent, void *match, void *aux) cf->pcicf_function != pa->pa_function) return (0); - success = (*cf->cf_attach->ca_match)(parent, match, aux); - - /* - * My Dell BIOS does not enable certain non-critical PCI devices - * for IO and memory cycles (e.g. network card). This is - * the generic approach to fixing this problem. Basically, if - * we support the card, then we enable its IO cycles. - */ - if (success) { - pcireg_t csr = pci_conf_read(pa->pa_pc, pa->pa_tag, - PCI_COMMAND_STATUS_REG); - - pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, - csr | PCI_COMMAND_MASTER_ENABLE | - PCI_COMMAND_IO_ENABLE | PCI_COMMAND_MEM_ENABLE); - } - - return (success); + return ((*cf->cf_attach->ca_match)(parent, match, aux)); } int diff --git a/sys/dev/pci/pci_map.c b/sys/dev/pci/pci_map.c index aee590c3b27..c95487360bf 100644 --- a/sys/dev/pci/pci_map.c +++ b/sys/dev/pci/pci_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_map.c,v 1.16 2006/05/31 08:58:05 jason Exp $ */ +/* $OpenBSD: pci_map.c,v 1.17 2006/07/04 18:07:29 kettenis Exp $ */ /* $NetBSD: pci_map.c,v 1.7 2000/05/10 16:58:42 thorpej Exp $ */ /*- @@ -306,9 +306,19 @@ pci_mapreg_map(struct pci_attach_args *pa, int reg, pcireg_t type, int busflags, bus_space_handle_t handle; bus_addr_t base; bus_size_t size; + pcireg_t csr; int flags; int rv; + csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) + csr |= PCI_COMMAND_IO_ENABLE; + else + csr |= PCI_COMMAND_MEM_ENABLE; + /* XXX Should this only be done for devices that do DMA? */ + csr |= PCI_COMMAND_MASTER_ENABLE; + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr); + if (PCI_MAPREG_TYPE(type) == PCI_MAPREG_TYPE_IO) { if ((pa->pa_flags & PCI_FLAGS_IO_ENABLED) == 0) return (EINVAL); |