Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Stop abuse of PCI_FLAGS_IO_ENABLED and PCI_FLAGS...



details:   https://anonhg.NetBSD.org/src/rev/ff35fc71e415
branches:  trunk
changeset: 764887:ff35fc71e415
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Tue May 10 18:31:33 2011 +0000

description:
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.

diffstat:

 sys/dev/pci/if_hme_pci.c    |   6 ++----
 sys/dev/pci/if_ral_pci.c    |   5 ++---
 sys/dev/pci/machfb.c        |  10 +++++-----
 sys/dev/pci/pci.c           |   8 ++------
 sys/dev/pci/pciide_common.c |  16 +++++++++-------
 sys/dev/pci/viaide.c        |  14 +++++++-------
 6 files changed, 27 insertions(+), 32 deletions(-)

diffs (205 lines):

diff -r ea979d3a28ec -r ff35fc71e415 sys/dev/pci/if_hme_pci.c
--- a/sys/dev/pci/if_hme_pci.c  Tue May 10 17:00:44 2011 +0000
+++ b/sys/dev/pci/if_hme_pci.c  Tue May 10 18:31:33 2011 +0000
@@ -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 @@
         */
        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;
diff -r ea979d3a28ec -r ff35fc71e415 sys/dev/pci/if_ral_pci.c
--- a/sys/dev/pci/if_ral_pci.c  Tue May 10 17:00:44 2011 +0000
+++ b/sys/dev/pci/if_ral_pci.c  Tue May 10 18:31:33 2011 +0000
@@ -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 @@
        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 |
diff -r ea979d3a28ec -r ff35fc71e415 sys/dev/pci/machfb.c
--- a/sys/dev/pci/machfb.c      Tue May 10 17:00:44 2011 +0000
+++ b/sys/dev/pci/machfb.c      Tue May 10 18:31:33 2011 +0000
@@ -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 @@
        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 @@
        
        /* 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);
        }
diff -r ea979d3a28ec -r ff35fc71e415 sys/dev/pci/pci.c
--- a/sys/dev/pci/pci.c Tue May 10 17:00:44 2011 +0000
+++ b/sys/dev/pci/pci.c Tue May 10 18:31:33 2011 +0000
@@ -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 @@
         * 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
diff -r ea979d3a28ec -r ff35fc71e415 sys/dev/pci/pciide_common.c
--- a/sys/dev/pci/pciide_common.c       Tue May 10 17:00:44 2011 +0000
+++ b/sys/dev/pci/pciide_common.c       Tue May 10 18:31:33 2011 +0000
@@ -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 @@
        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;
diff -r ea979d3a28ec -r ff35fc71e415 sys/dev/pci/viaide.c
--- a/sys/dev/pci/viaide.c      Tue May 10 17:00:44 2011 +0000
+++ b/sys/dev/pci/viaide.c      Tue May 10 18:31:33 2011 +0000
@@ -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 @@
 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 @@
                /*
                 * 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);



Home | Main Index | Thread Index | Old Index