Source-Changes-HG archive

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

[src/yamt-pagecache]: src/sys/arch/x86/pci pull following revisions from trun...



details:   https://anonhg.NetBSD.org/src/rev/5193768bb1bb
branches:  yamt-pagecache
changeset: 770876:5193768bb1bb
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Apr 18 13:38:27 2012 +0000

description:
pull following revisions from trunk so that the kernel at least boot
on my system.
        cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/pci/pchb.c
        cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/pchbvar.h
        cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdnb_misc.c

diffstat:

 sys/arch/x86/pci/amdnb_misc.c |  81 +++++++++++++++++++++++++++++++++++++++---
 sys/arch/x86/pci/pchb.c       |  54 ++++-----------------------
 sys/arch/x86/pci/pchbvar.h    |   6 +-
 3 files changed, 86 insertions(+), 55 deletions(-)

diffs (266 lines):

diff -r dd9acc031ffc -r 5193768bb1bb sys/arch/x86/pci/amdnb_misc.c
--- a/sys/arch/x86/pci/amdnb_misc.c     Tue Apr 17 00:01:34 2012 +0000
+++ b/sys/arch/x86/pci/amdnb_misc.c     Wed Apr 18 13:38:27 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdnb_misc.c,v 1.2.2.2 2012/04/17 00:07:05 yamt Exp $ */
+/*     $NetBSD: amdnb_misc.c,v 1.2.2.3 2012/04/18 13:38:27 yamt Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.2.2.2 2012/04/17 00:07:05 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.2.2.3 2012/04/18 13:38:27 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -41,9 +41,16 @@
 static int amdnb_misc_match(device_t, cfdata_t match, void *);
 static void amdnb_misc_attach(device_t, device_t, void *);
 static int amdnb_misc_detach(device_t, int);
+static int amdnb_misc_rescan(device_t, const char *, const int *);
+static void amdnb_misc_childdet(device_t, device_t);
 
-CFATTACH_DECL_NEW(amdnb_misc, 0,
-    amdnb_misc_match, amdnb_misc_attach, amdnb_misc_detach, NULL);
+struct amdnb_misc_softc {
+       struct pci_attach_args sc_pa;
+};
+
+CFATTACH_DECL3_NEW(amdnb_misc, sizeof(struct amdnb_misc_softc),
+    amdnb_misc_match, amdnb_misc_attach, amdnb_misc_detach, NULL,
+    amdnb_misc_rescan, amdnb_misc_childdet, DVF_DETACH_SHUTDOWN);
 
 
 static int
@@ -71,8 +78,41 @@
 static int
 amdnb_misc_search(device_t parent, cfdata_t cf, const int *locs, void *aux)
 {
-       if (config_match(parent, cf, aux))
-               config_attach_loc(parent, cf, locs, aux, NULL);
+       device_t dev;
+       deviter_t di;
+       bool attach;
+
+       if (!config_match(parent, cf, aux))
+               return 0;
+
+       attach = true;
+
+       /* Figure out if found child 'cf' is already attached.
+        * No need to attach it twice.
+        */
+
+       /* XXX: I only want to iterate over the children of *this* device.
+        * Can we introduce a
+        * deviter_first_child(&di, parent, DEVITER_F_LEAVES_ONLY)
+        * or even better, can we introduce a query function that returns
+        * if a child is already attached?
+        */
+       for (dev = deviter_first(&di, DEVITER_F_LEAVES_FIRST); dev != NULL;
+           dev = deviter_next(&di))
+       {
+               if (device_parent(dev) != parent)
+                       continue;
+               if (device_is_a(dev, cf->cf_name)) {
+                       attach = false;
+                       break;
+               }
+       }
+       deviter_release(&di);
+
+       if (!attach)
+               return 0;
+
+       config_attach_loc(parent, cf, locs, aux, NULL);
 
        return 0;
 }
@@ -80,13 +120,20 @@
 static void
 amdnb_misc_attach(device_t parent, device_t self, void *aux)
 {
+       struct amdnb_misc_softc *sc = device_private(self);
+       struct pci_attach_args *pa = aux;
+
+       sc->sc_pa = *pa;
+
        aprint_naive("\n");
        aprint_normal(": AMD NB Misc Configuration\n");
 
        if (!pmf_device_register(self, NULL, NULL))
                aprint_error_dev(self, "couldn't establish power handler\n");
 
-       config_search_loc(amdnb_misc_search, self, "amdnb_miscbus", NULL, aux);
+       config_search_loc(amdnb_misc_search, self, "amdnb_miscbus",
+           NULL, &sc->sc_pa);
+
        return;
 }
 
@@ -102,3 +149,23 @@
        pmf_device_deregister(self);
        return rv;
 }
+
+static int
+amdnb_misc_rescan(device_t self, const char *ifattr, const int *locators)
+{
+       struct amdnb_misc_softc *sc = device_private(self);
+
+       if (!ifattr_match(ifattr, "amdnb_miscbus"))
+               return 0;
+
+       config_search_loc(amdnb_misc_search, self, ifattr,
+           locators, &sc->sc_pa);
+
+       return 0;
+}
+
+static void
+amdnb_misc_childdet(device_t self, device_t child)
+{
+       return;
+}
diff -r dd9acc031ffc -r 5193768bb1bb sys/arch/x86/pci/pchb.c
--- a/sys/arch/x86/pci/pchb.c   Tue Apr 17 00:01:34 2012 +0000
+++ b/sys/arch/x86/pci/pchb.c   Wed Apr 18 13:38:27 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pchb.c,v 1.32.2.1 2012/04/17 00:07:05 yamt Exp $ */
+/*     $NetBSD: pchb.c,v 1.32.2.2 2012/04/18 13:38:27 yamt Exp $ */
 
 /*-
  * Copyright (c) 1996, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.32.2.1 2012/04/17 00:07:05 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.32.2.2 2012/04/18 13:38:27 yamt Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -72,16 +72,12 @@
 static int     pchbmatch(device_t, cfdata_t, void *);
 static void    pchbattach(device_t, device_t, void *);
 static int     pchbdetach(device_t, int);
-static int     pchbrescan(device_t, const char *, const int *);
-static void    pchbchilddet(device_t, device_t);
 
 static bool    pchb_resume(device_t, const pmf_qual_t *);
 static bool    pchb_suspend(device_t, const pmf_qual_t *);
 
-static void    pchb_amdtempbus_configure(struct pchb_softc *);
-
 CFATTACH_DECL3_NEW(pchb, sizeof(struct pchb_softc),
-    pchbmatch, pchbattach, pchbdetach, NULL, pchbrescan, pchbchilddet, DVF_DETACH_SHUTDOWN);
+    pchbmatch, pchbattach, pchbdetach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
 
 static int
 pchbmatch(device_t parent, cfdata_t match, void *aux)
@@ -167,7 +163,8 @@
        attachflags = pa->pa_flags;
 
        sc->sc_dev = self;
-       sc->sc_pa = *pa;
+       sc->sc_pc = pa->pa_pc;
+       sc->sc_tag = pa->pa_tag;
 
        /*
         * Print out a description, and configure certain chipsets which
@@ -437,8 +434,6 @@
                memset(&pba.pba_intrtag, 0, sizeof(pba.pba_intrtag));
                config_found_ia(self, "pcibus", &pba, pcibusprint);
        }
-
-       pchb_amdtempbus_configure(sc);
 }
 
 static int
@@ -454,28 +449,6 @@
        return 0;
 }
 
-static int
-pchbrescan(device_t self, const char *ifattr, const int *locators)
-{
-       struct pchb_softc *sc = device_private(self);
-
-       if (ifattr_match(ifattr, "amdtempbus"))
-               pchb_amdtempbus_configure(sc);
-
-       return 0;
-}
-
-static void
-pchbchilddet(device_t self, device_t child)
-{
-       struct pchb_softc *sc = device_private(self);
-
-       if (sc->sc_amdtempbus == child) {
-               sc->sc_amdtempbus = NULL;
-               return;
-       }
-}
-
 static bool
 pchb_suspend(device_t dv, const pmf_qual_t *qual)
 {
@@ -484,8 +457,8 @@
        pcitag_t tag;
        int off;
 
-       pc = sc->sc_pa.pa_pc;
-       tag = sc->sc_pa.pa_tag;
+       pc = sc->sc_pc;
+       tag = sc->sc_tag;
 
        for (off = 0x40; off <= 0xff; off += 4)
                sc->sc_pciconfext[(off - 0x40) / 4] = pci_conf_read(pc, tag, off);
@@ -501,20 +474,11 @@
        pcitag_t tag;
        int off;
 
-       pc = sc->sc_pa.pa_pc;
-       tag = sc->sc_pa.pa_tag;
+       pc = sc->sc_pc;
+       tag = sc->sc_tag;
 
        for (off = 0x40; off <= 0xff; off += 4)
                pci_conf_write(pc, tag, off, sc->sc_pciconfext[(off - 0x40) / 4]);
 
        return true;
 }
-
-static void
-pchb_amdtempbus_configure(struct pchb_softc *sc)
-{
-       if (sc->sc_amdtempbus != NULL)
-               return;
-
-       sc->sc_amdtempbus = config_found_ia(sc->sc_dev, "amdtempbus", &sc->sc_pa, NULL);
-}
diff -r dd9acc031ffc -r 5193768bb1bb sys/arch/x86/pci/pchbvar.h
--- a/sys/arch/x86/pci/pchbvar.h        Tue Apr 17 00:01:34 2012 +0000
+++ b/sys/arch/x86/pci/pchbvar.h        Wed Apr 18 13:38:27 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pchbvar.h,v 1.8 2011/08/20 20:01:08 jakllsch Exp $     */
+/*     $NetBSD: pchbvar.h,v 1.8.2.1 2012/04/18 13:38:27 yamt Exp $     */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -34,9 +34,9 @@
 
 struct pchb_softc {
        device_t sc_dev;
-       device_t sc_amdtempbus;
 
-       struct pci_attach_args sc_pa;
+       pci_chipset_tag_t sc_pc;
+       pcitag_t sc_tag;
 
        pcireg_t sc_pciconfext[48];
 };



Home | Main Index | Thread Index | Old Index