Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Allow the attachment to override ahci_ports.



details:   https://anonhg.NetBSD.org/src/rev/c2de6f332c02
branches:  trunk
changeset: 789807:c2de6f332c02
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Sep 08 11:47:16 2013 +0000

description:
Allow the attachment to override ahci_ports.
Keep ACHI_PI cached in the softc.

diffstat:

 sys/dev/ic/ahcisata_core.c |  27 ++++++++++++---------------
 sys/dev/ic/ahcisatavar.h   |   3 ++-
 2 files changed, 14 insertions(+), 16 deletions(-)

diffs (112 lines):

diff -r bb10740a4708 -r c2de6f332c02 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Sun Sep 08 11:19:47 2013 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Sun Sep 08 11:47:16 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.49 2013/09/08 11:19:47 matt Exp $  */
+/*     $NetBSD: ahcisata_core.c,v 1.50 2013/09/08 11:47:16 matt Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.49 2013/09/08 11:19:47 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.50 2013/09/08 11:47:16 matt Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -144,12 +144,10 @@
 static void
 ahci_setup_ports(struct ahci_softc *sc)
 {
-       uint32_t ahci_ports;
        int i, port;
        
-       ahci_ports = AHCI_READ(sc, AHCI_PI);
        for (i = 0, port = 0; i < AHCI_MAX_PORTS; i++) {
-               if ((ahci_ports & (1 << i)) == 0)
+               if ((sc->sc_ahci_ports & (1 << i)) == 0)
                        continue;
                if (port >= sc->sc_atac.atac_nchannels) {
                        aprint_error("%s: more ports than announced\n",
@@ -163,14 +161,12 @@
 static void
 ahci_reprobe_drives(struct ahci_softc *sc)
 {
-       uint32_t ahci_ports;
        int i, port;
        struct ahci_channel *achp;
        struct ata_channel *chp;
 
-       ahci_ports = AHCI_READ(sc, AHCI_PI);
        for (i = 0, port = 0; i < AHCI_MAX_PORTS; i++) {
-               if ((ahci_ports & (1 << i)) == 0)
+               if ((sc->sc_ahci_ports & (1 << i)) == 0)
                        continue;
                if (port >= sc->sc_atac.atac_nchannels) {
                        aprint_error("%s: more ports than announced\n",
@@ -210,7 +206,7 @@
 void
 ahci_attach(struct ahci_softc *sc)
 {
-       uint32_t ahci_rev, ahci_ports;
+       uint32_t ahci_rev;
        int i, j, port;
        struct ahci_channel *achp;
        struct ata_channel *chp;
@@ -313,10 +309,13 @@
 
        ahci_enable_intrs(sc);
 
-       ahci_ports = AHCI_READ(sc, AHCI_PI);
-       AHCIDEBUG_PRINT(("active ports %#x\n", ahci_ports), DEBUG_PROBE);
+       if (sc->sc_ahci_ports == 0) {
+               sc->sc_ahci_ports = AHCI_READ(sc, AHCI_PI);
+               AHCIDEBUG_PRINT(("active ports %#x\n", sc->sc_ahci_ports),
+                   DEBUG_PROBE);
+       }
        for (i = 0, port = 0; i < AHCI_MAX_PORTS; i++) {
-               if ((ahci_ports & (1 << i)) == 0)
+               if ((sc->sc_ahci_ports & (1 << i)) == 0)
                        continue;
                if (port >= sc->sc_atac.atac_nchannels) {
                        aprint_error("%s: more ports than announced\n",
@@ -438,19 +437,17 @@
        struct ahci_channel *achp;
        struct ata_channel *chp;
        struct scsipi_adapter *adapt;
-       uint32_t ahci_ports;
        int i, j;
        int error;
 
        atac = &sc->sc_atac;
        adapt = &atac->atac_atapi_adapter._generic;
 
-       ahci_ports = AHCI_READ(sc, AHCI_PI);
        for (i = 0; i < AHCI_MAX_PORTS; i++) {
                achp = &sc->sc_channels[i];
                chp = &achp->ata_channel;
 
-               if ((ahci_ports & (1 << i)) == 0)
+               if ((sc->sc_ahci_ports & (1 << i)) == 0)
                        continue;
                if (i >= sc->sc_atac.atac_nchannels) {
                        aprint_error("%s: more ports than announced\n",
diff -r bb10740a4708 -r c2de6f332c02 sys/dev/ic/ahcisatavar.h
--- a/sys/dev/ic/ahcisatavar.h  Sun Sep 08 11:19:47 2013 +0000
+++ b/sys/dev/ic/ahcisatavar.h  Sun Sep 08 11:47:16 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisatavar.h,v 1.14 2012/09/20 17:53:48 matt Exp $    */
+/*     $NetBSD: ahcisatavar.h,v 1.15 2013/09/08 11:47:16 matt Exp $    */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -62,6 +62,7 @@
 
        uint32_t sc_ahci_cap;   /* copy of AHCI_CAP */
        int sc_ncmds; /* number of command slots */
+       uint32_t sc_ahci_ports;
        struct ata_channel *sc_chanarray[AHCI_MAX_PORTS];
        struct ahci_channel {
                struct ata_channel ata_channel; /* generic part */



Home | Main Index | Thread Index | Old Index