Module Name:    src
Committed By:   matt
Date:           Sun Sep  8 11:47:16 UTC 2013

Modified Files:
        src/sys/dev/ic: ahcisata_core.c ahcisatavar.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/ahcisatavar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.49 src/sys/dev/ic/ahcisata_core.c:1.50
--- src/sys/dev/ic/ahcisata_core.c:1.49	Sun Sep  8 11:19:47 2013
+++ src/sys/dev/ic/ahcisata_core.c	Sun Sep  8 11:47:16 2013
@@ -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 @@ ahci_reset(struct ahci_softc *sc)
 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 @@ ahci_setup_ports(struct ahci_softc *sc)
 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 @@ ahci_enable_intrs(struct ahci_softc *sc)
 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_attach(struct ahci_softc *sc)
 
 	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 @@ ahci_detach(struct ahci_softc *sc, int f
 	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",

Index: src/sys/dev/ic/ahcisatavar.h
diff -u src/sys/dev/ic/ahcisatavar.h:1.14 src/sys/dev/ic/ahcisatavar.h:1.15
--- src/sys/dev/ic/ahcisatavar.h:1.14	Thu Sep 20 17:53:48 2012
+++ src/sys/dev/ic/ahcisatavar.h	Sun Sep  8 11:47:16 2013
@@ -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 @@ struct ahci_softc {
 
 	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 */

Reply via email to