PERFORCE change 167782 for review

Alexander Motin mav at FreeBSD.org
Tue Aug 25 10:54:21 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=167782

Change 167782 by mav at mav_mavbook on 2009/08/25 10:53:46

	Change slot selection algorithm to reuse previous slot if possible.
	Optimize CCC interrupts handling.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#55 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#55 (text+ko) ====

@@ -384,13 +384,16 @@
 	void *arg;
 	int unit;
 
-	is = ATA_INL(ctlr->r_mem, AHCI_IS);
 	if (irq->mode == AHCI_IRQ_MODE_ALL) {
+		unit = 0;
 		if (ctlr->ccc)
 			is = ctlr->ichannels;
-		unit = 0;
-	} else	/* AHCI_IRQ_MODE_AFTER */
+		else
+			is = ATA_INL(ctlr->r_mem, AHCI_IS);
+	} else {	/* AHCI_IRQ_MODE_AFTER */
 		unit = irq->r_irq_rid - 1;
+		is = ATA_INL(ctlr->r_mem, AHCI_IS);
+	}
 	for (; unit < ctlr->channels; unit++) {
 		if ((is & (1 << unit)) != 0 &&
 		    (arg = ctlr->interrupt[unit].argument)) {
@@ -948,6 +951,8 @@
 
 	/* Read and clear interrupt statuses. */
 	istatus = ATA_INL(ch->r_mem, AHCI_P_IS);
+	if (istatus == 0)
+		return;
 	ATA_OUTL(ch->r_mem, AHCI_P_IS, istatus);
 	/* Read command statuses. */
 	cstatus = ATA_INL(ch->r_mem, AHCI_P_CI);
@@ -963,17 +968,16 @@
 //    ATA_INL(ch->r_mem, AHCI_P_SERR));
 		ccs = (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CCS_MASK)
 		    >> AHCI_P_CMD_CCS_SHIFT;
+		err = ch->rslots & (cstatus | sstatus);
 		/* Kick controller into sane state */
 		ahci_stop(dev);
 		ahci_start(dev);
-		ok = ch->rslots & ~(cstatus | sstatus);
-		err = ch->rslots & (cstatus | sstatus);
 	} else {
 		ccs = 0;
-		ok = ch->rslots & ~(cstatus | sstatus);
 		err = 0;
 	}
 	/* Complete all successfull commands. */
+	ok = ch->rslots & ~(cstatus | sstatus);
 	for (i = 0; i < ch->numslots; i++) {
 		if ((ok >> i) & 1)
 			ahci_end_transaction(&ch->slot[i], AHCI_ERR_NONE);
@@ -1062,15 +1066,11 @@
 
 	/* Choose empty slot. */
 	tag = ch->lastslot;
-	do {
-		tag++;
-		if (tag >= ch->numslots)
+	while (ch->slot[tag].state != AHCI_SLOT_EMPTY) {
+		if (++tag >= ch->numslots)
 			tag = 0;
-		if (ch->slot[tag].state == AHCI_SLOT_EMPTY)
-			break;
-	} while (tag != ch->lastslot);
-	if (ch->slot[tag].state != AHCI_SLOT_EMPTY)
-		device_printf(ch->dev, "ALL SLOTS BUSY!\n");
+		KASSERT(tag != ch->lastslot, "ahci: ALL SLOTS BUSY!");
+	}
 	ch->lastslot = tag;
 	/* Occupy chosen slot. */
 	slot = &ch->slot[tag];


More information about the p4-projects mailing list