[Midnightbsd-cvs] src [9292] trunk/sys/dev/ahci/ahci.c: Depending on combination of running commands (NCQ/non-NCQ) try to avoid

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Mar 2 18:16:05 EST 2017


Revision: 9292
          http://svnweb.midnightbsd.org/src/?rev=9292
Author:   laffer1
Date:     2017-03-02 18:16:04 -0500 (Thu, 02 Mar 2017)
Log Message:
-----------
Depending on combination of running commands (NCQ/non-NCQ) try to avoid
extra read from PxCI/PxSACT registers.  If only NCQ commands are running, we
don't really need PxCI.  If only non-NCQ commands are running we don't need
PxSACT.  Mixed set may happen only on controllers with FIS-based switching
when port multiplier is attached, and then we have to read both registers.

Obtained from: FreeBSD 249851

Modified Paths:
--------------
    trunk/sys/dev/ahci/ahci.c

Modified: trunk/sys/dev/ahci/ahci.c
===================================================================
--- trunk/sys/dev/ahci/ahci.c	2017-03-02 23:09:35 UTC (rev 9291)
+++ trunk/sys/dev/ahci/ahci.c	2017-03-02 23:16:04 UTC (rev 9292)
@@ -1576,7 +1576,7 @@
 {
 	device_t dev = (device_t)data;
 	struct ahci_channel *ch = device_get_softc(dev);
-	uint32_t istatus, sstatus, cstatus, serr = 0, sntf = 0, ok, err;
+	uint32_t istatus, cstatus, serr = 0, sntf = 0, ok, err;
 	enum ahci_err_type et;
 	int i, ccs, port, reset = 0;
 
@@ -1586,8 +1586,13 @@
 		return;
 	ATA_OUTL(ch->r_mem, AHCI_P_IS, istatus);
 	/* Read command statuses. */
-	sstatus = ATA_INL(ch->r_mem, AHCI_P_SACT);
-	cstatus = ATA_INL(ch->r_mem, AHCI_P_CI);
+	if (ch->numtslots != 0)
+		cstatus = ATA_INL(ch->r_mem, AHCI_P_SACT);
+	else
+		cstatus = 0;
+	if (ch->numrslots != ch->numtslots)
+		cstatus |= ATA_INL(ch->r_mem, AHCI_P_CI);
+	/* Read SNTF in one of possible ways. */
 	if (istatus & AHCI_P_IX_SDB) {
 		if (ch->caps & AHCI_CAP_SSNTF)
 			sntf = ATA_INL(ch->r_mem, AHCI_P_SNTF);
@@ -1647,7 +1652,7 @@
 				}
 			}
 		}
-		err = ch->rslots & (cstatus | sstatus);
+		err = ch->rslots & cstatus;
 	} else {
 		ccs = 0;
 		err = 0;
@@ -1654,7 +1659,7 @@
 		port = -1;
 	}
 	/* Complete all successfull commands. */
-	ok = ch->rslots & ~(cstatus | sstatus);
+	ok = ch->rslots & ~cstatus;
 	for (i = 0; i < ch->numslots; i++) {
 		if ((ok >> i) & 1)
 			ahci_end_transaction(&ch->slot[i], AHCI_ERR_NONE);



More information about the Midnightbsd-cvs mailing list