Module Name:    src
Committed By:   jdolecek
Date:           Tue Sep 19 17:52:52 UTC 2017

Modified Files:
        src/sys/dev/ic [jdolecek-ncq]: ahcisata_core.c

Log Message:
seems the CMD/CCS slot is always zero at least under QEMU for successful
polled commands, so go back to using it only on error path; while the value
seems good on real hardware, there is no good reason for register read anyway


To generate a diff of this commit:
cvs rdiff -u -r1.57.6.27 -r1.57.6.28 src/sys/dev/ic/ahcisata_core.c

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.57.6.27 src/sys/dev/ic/ahcisata_core.c:1.57.6.28
--- src/sys/dev/ic/ahcisata_core.c:1.57.6.27	Sun Sep 10 19:31:15 2017
+++ src/sys/dev/ic/ahcisata_core.c	Tue Sep 19 17:52:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.57.6.27 2017/09/10 19:31:15 jdolecek Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.57.6.28 2017/09/19 17:52:52 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.27 2017/09/10 19:31:15 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.57.6.28 2017/09/19 17:52:52 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -568,7 +568,7 @@ ahci_intr_port(struct ahci_softc *sc, st
 	uint32_t is, tfd, sact;
 	struct ata_channel *chp = &achp->ata_channel;
 	struct ata_xfer *xfer;
-	int slot;
+	int slot = -1;
 	bool recover = false;
 
 	is = AHCI_READ(sc, AHCI_P_IS(chp->ch_channel));
@@ -585,12 +585,9 @@ ahci_intr_port(struct ahci_softc *sc, st
 	if ((chp->ch_flags & ATACH_NCQ) == 0) {
 		/* Non-NCQ operation */
 		sact = AHCI_READ(sc, AHCI_P_CI(chp->ch_channel));
-		slot = (AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel))
-			& AHCI_P_CMD_CCS_MASK) >> AHCI_P_CMD_CCS_SHIFT;
 	} else {
 		/* NCQ operation */
 		sact = AHCI_READ(sc, AHCI_P_SACT(chp->ch_channel));
-		slot = -1;
 	}
 
 	/* Handle errors */
@@ -600,6 +597,14 @@ ahci_intr_port(struct ahci_softc *sc, st
 		if (is & AHCI_P_IX_TFES) {
 			tfd = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
 
+			if ((chp->ch_flags & ATACH_NCQ) == 0) {
+				/* Slot valid only for Non-NCQ operation */
+				slot = (AHCI_READ(sc,
+				    AHCI_P_CMD(chp->ch_channel))
+				    & AHCI_P_CMD_CCS_MASK)
+				    >> AHCI_P_CMD_CCS_SHIFT;
+			}
+
 			aprint_error("%s port %d: active %x is 0x%x tfd 0x%x\n",
 			    AHCINAME(sc), chp->ch_channel, sact, is, tfd);
 		} else {
@@ -657,7 +662,7 @@ ahci_intr_port(struct ahci_softc *sc, st
 			if ((aslots & __BIT(slot)) != 0 &&
 			    (sact & __BIT(slot)) == 0) {
 				xfer = ata_queue_hwslot_to_xfer(chp, slot);
-				xfer->c_intr(chp, xfer, 0);
+				xfer->c_intr(chp, xfer, tfd);
 			}
 		}
 	}

Reply via email to