Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Nov 2009 15:10:46 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r198896 - head/sys/dev/siis
Message-ID:  <200911041510.nA4FAkCA035763@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Nov  4 15:10:46 2009
New Revision: 198896
URL: http://svn.freebsd.org/changeset/base/198896

Log:
  Do not unarm callout on request completion and change slot selection
  algorithm as done in ahci(4). This saves some CPU time on high request
  rates.

Modified:
  head/sys/dev/siis/siis.c

Modified: head/sys/dev/siis/siis.c
==============================================================================
--- head/sys/dev/siis/siis.c	Wed Nov  4 15:05:51 2009	(r198895)
+++ head/sys/dev/siis/siis.c	Wed Nov  4 15:10:46 2009	(r198896)
@@ -641,6 +641,7 @@ siis_slotsfree(device_t dev)
 	for (i = 0; i < SIIS_MAX_SLOTS; i++) {
 		struct siis_slot *slot = &ch->slot[i];
 
+		callout_drain(&slot->timeout);
 		if (slot->dma.data_map) {
 			bus_dmamap_destroy(ch->dma.data_tag, slot->dma.data_map);
 			slot->dma.data_map = NULL;
@@ -838,15 +839,11 @@ siis_begin_transaction(device_t dev, uni
 	mtx_assert(&ch->mtx, MA_OWNED);
 	/* Choose empty slot. */
 	tag = ch->lastslot;
-	do {
-		tag++;
-		if (tag >= SIIS_MAX_SLOTS)
+	while (ch->slot[tag].state != SIIS_SLOT_EMPTY) {
+		if (++tag >= SIIS_MAX_SLOTS)
 			tag = 0;
-		if (ch->slot[tag].state == SIIS_SLOT_EMPTY)
-			break;
-	} while (tag != ch->lastslot);
-	if (ch->slot[tag].state != SIIS_SLOT_EMPTY)
-		device_printf(ch->dev, "ALL SLOTS BUSY!\n");
+		KASSERT(tag != ch->lastslot, ("siis: ALL SLOTS BUSY!"));
+	}
 	ch->lastslot = tag;
 	/* Occupy chosen slot. */
 	slot = &ch->slot[tag];
@@ -999,6 +996,9 @@ siis_timeout(struct siis_slot *slot)
 	struct siis_channel *ch = device_get_softc(dev);
 
 	mtx_assert(&ch->mtx, MA_OWNED);
+	/* Check for stale timeout. */
+	if (slot->state < SIIS_SLOT_RUNNING)
+		return;
 	device_printf(dev, "Timeout on slot %d\n", slot->slot);
 device_printf(dev, "%s is %08x ss %08x rs %08x es %08x sts %08x serr %08x\n",
     __func__, ATA_INL(ch->r_mem, SIIS_P_IS), ATA_INL(ch->r_mem, SIIS_P_SS), ch->rslots,
@@ -1024,8 +1024,6 @@ siis_end_transaction(struct siis_slot *s
 	union ccb *ccb = slot->ccb;
 
 	mtx_assert(&ch->mtx, MA_OWNED);
-	/* Cancel command execution timeout */
-	callout_stop(&slot->timeout);
 	bus_dmamap_sync(ch->dma.work_tag, ch->dma.work_map,
 	    BUS_DMASYNC_POSTWRITE);
 	/* Read result registers to the result struct



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911041510.nA4FAkCA035763>