Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS_MEM_ENABLED. The flags

specifically tell a driver that bridges upstream forward PCI I/O (or
memory) transactions to the device."  Only bus drivers have any business
modifying these.
This commit is contained in:
dyoung 2011-05-10 18:31:33 +00:00
parent 88152d886b
commit e4c26632ea
6 changed files with 27 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_hme_pci.c,v 1.35 2010/03/23 21:54:23 dyoung Exp $ */
/* $NetBSD: if_hme_pci.c,v 1.36 2011/05/10 18:31:33 dyoung Exp $ */
/*
* Copyright (c) 2000 Matthew R. Green
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_hme_pci.c,v 1.35 2010/03/23 21:54:23 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_hme_pci.c,v 1.36 2011/05/10 18:31:33 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -155,12 +155,10 @@ hmeattach_pci(device_t parent, device_t self, void *aux)
*/
switch (type) {
case PCI_MAPREG_TYPE_MEM:
pa->pa_flags |= PCI_FLAGS_MEM_ENABLED;
csr |= PCI_COMMAND_MEM_ENABLE;
sc->sc_bustag = pa->pa_memt;
break;
case PCI_MAPREG_TYPE_IO:
pa->pa_flags |= PCI_FLAGS_IO_ENABLED;
csr |= PCI_COMMAND_IO_ENABLE;
sc->sc_bustag = pa->pa_iot;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ral_pci.c,v 1.15 2010/01/19 22:07:01 pooka Exp $ */
/* $NetBSD: if_ral_pci.c,v 1.16 2011/05/10 18:31:33 dyoung Exp $ */
/* $OpenBSD: if_ral_pci.c,v 1.6 2006/01/09 20:03:43 damien Exp $ */
/*-
@ -22,7 +22,7 @@
* PCI front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.15 2010/01/19 22:07:01 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.16 2011/05/10 18:31:33 dyoung Exp $");
#include <sys/param.h>
@ -144,7 +144,6 @@ ral_pci_attach(device_t parent, device_t self, void *aux)
reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
reg |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE;
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, reg);
pa->pa_flags |= PCI_FLAGS_MEM_ENABLED;
/* map control/status registers */
error = pci_mapreg_map(pa, RAL_PCI_BAR0, PCI_MAPREG_TYPE_MEM |

View File

@ -1,4 +1,4 @@
/* $NetBSD: machfb.c,v 1.64 2011/05/04 23:36:21 macallan Exp $ */
/* $NetBSD: machfb.c,v 1.65 2011/05/10 18:31:33 dyoung Exp $ */
/*
* Copyright (c) 2002 Bang Jun-Young
@ -34,7 +34,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0,
"$NetBSD: machfb.c,v 1.64 2011/05/04 23:36:21 macallan Exp $");
"$NetBSD: machfb.c,v 1.65 2011/05/10 18:31:33 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -521,6 +521,7 @@ mach64_attach(device_t parent, device_t self, void *aux)
int setmode, width, height;
pcireg_t screg;
uint32_t reg;
const pcireg_t enables = PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_IO_ENABLE;
sc->sc_dev = self;
sc->sc_pc = pa->pa_pc;
@ -543,9 +544,8 @@ mach64_attach(device_t parent, device_t self, void *aux)
/* enable memory and disable IO access */
screg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, PCI_COMMAND_STATUS_REG);
if ((screg & PCI_FLAGS_MEM_ENABLED) == 0) {
screg |= PCI_FLAGS_IO_ENABLED;
screg |= PCI_FLAGS_MEM_ENABLED;
if ((screg & enables) != enables) {
screg |= enables;
pci_conf_write(sc->sc_pc, sc->sc_pcitag,
PCI_COMMAND_STATUS_REG, screg);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci.c,v 1.138 2011/04/05 23:10:52 dyoung Exp $ */
/* $NetBSD: pci.c,v 1.139 2011/05/10 18:31:33 dyoung Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.138 2011/04/05 23:10:52 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.139 2011/05/10 18:31:33 dyoung Exp $");
#include "opt_pci.h"
@ -370,10 +370,6 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag,
* as appropriate.
*/
pa.pa_flags = sc->sc_flags;
if ((csr & PCI_COMMAND_IO_ENABLE) == 0)
pa.pa_flags &= ~PCI_FLAGS_IO_ENABLED;
if ((csr & PCI_COMMAND_MEM_ENABLE) == 0)
pa.pa_flags &= ~PCI_FLAGS_MEM_ENABLED;
/*
* If the cache line size is not configured, then

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciide_common.c,v 1.49 2011/04/04 20:37:56 dyoung Exp $ */
/* $NetBSD: pciide_common.c,v 1.50 2011/05/10 18:31:33 dyoung Exp $ */
/*
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.49 2011/04/04 20:37:56 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: pciide_common.c,v 1.50 2011/05/10 18:31:33 dyoung Exp $");
#include <sys/param.h>
#include <sys/malloc.h>
@ -267,12 +267,14 @@ pciide_chipen(struct pciide_softc *sc, const struct pci_attach_args *pa)
pcireg_t csr;
if ((pa->pa_flags & PCI_FLAGS_IO_ENABLED) == 0) {
csr = pci_conf_read(sc->sc_pc, sc->sc_tag,
PCI_COMMAND_STATUS_REG);
aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
"device disabled (at %s)\n",
(csr & PCI_COMMAND_IO_ENABLE) == 0 ?
"device" : "bridge");
"I/O access disabled at bridge\n");
return 0;
}
csr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG);
if ((csr & PCI_COMMAND_IO_ENABLE) == 0) {
aprint_normal_dev(sc->sc_wdcdev.sc_atac.atac_dev,
"I/O access disabled at device\n");
return 0;
}
return 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: viaide.c,v 1.73 2011/04/10 15:02:01 jakllsch Exp $ */
/* $NetBSD: viaide.c,v 1.74 2011/05/10 18:31:33 dyoung Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1.73 2011/04/10 15:02:01 jakllsch Exp $");
__KERNEL_RCSID(0, "$NetBSD: viaide.c,v 1.74 2011/05/10 18:31:33 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -837,6 +837,7 @@ pio: /* setup PIO mode */
static int
via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa)
{
pcireg_t csr;
int maptype, ret;
if (pciide_chipen(sc, pa) == 0)
@ -877,12 +878,11 @@ via_sata_chip_map_common(struct pciide_softc *sc, struct pci_attach_args *pa)
/*
* Enable memory-space access if it isn't already there.
*/
if ((pa->pa_flags & PCI_FLAGS_MEM_ENABLED) == 0) {
pcireg_t csr;
csr = pci_conf_read(pa->pa_pc, pa->pa_tag,
PCI_COMMAND_STATUS_REG);
if ((csr & PCI_COMMAND_MEM_ENABLE) == 0 &&
(pa->pa_flags & PCI_FLAGS_MEM_ENABLED) != 0) {
pa->pa_flags |= PCI_FLAGS_MEM_ENABLED;
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_MEM_ENABLE);