PERFORCE change 169446 for review
Alexander Motin
mav at FreeBSD.org
Tue Oct 13 09:13:55 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=169446
Change 169446 by mav at mav_mavtest on 2009/10/13 09:13:48
Improve timeout handling to avoid false positives, when command
with small timeout waiting one with bigger.
Submitted by: avg
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#68 edit
.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.h#23 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#68 (text+ko) ====
@@ -1236,7 +1236,7 @@
return;
}
/* Start command execution timeout */
- callout_reset(&slot->timeout, (int)ccb->ccb_h.timeout * hz / 1000,
+ callout_reset(&slot->timeout, (int)ccb->ccb_h.timeout * hz / 2000,
(timeout_t*)ahci_timeout, slot);
return;
}
@@ -1247,11 +1247,28 @@
{
device_t dev = slot->dev;
struct ahci_channel *ch = device_get_softc(dev);
+ uint32_t sstatus;
+ int ccs;
int i;
/* Check for stale timeout. */
- if (slot->state != AHCI_SLOT_RUNNING)
+ if (slot->state < AHCI_SLOT_RUNNING)
+ return;
+
+ /* Check if slot was not being executed last time we checked. */
+ if (slot->state < AHCI_SLOT_EXECUTING) {
+ /* Check if slot started executing. */
+ sstatus = ATA_INL(ch->r_mem, AHCI_P_SACT);
+ ccs = (ATA_INL(ch->r_mem, AHCI_P_CMD) & AHCI_P_CMD_CCS_MASK)
+ >> AHCI_P_CMD_CCS_SHIFT;
+ if ((sstatus & (1 << slot->slot)) != 0 || ccs == slot->slot)
+ slot->state = AHCI_SLOT_EXECUTING;
+
+ callout_reset(&slot->timeout,
+ (int)slot->ccb->ccb_h.timeout * hz / 2000,
+ (timeout_t*)ahci_timeout, slot);
return;
+ }
device_printf(dev, "Timeout on slot %d\n", slot->slot);
device_printf(dev, "%s is %08x cs %08x ss %08x rs %08x tfd %02x serr %08x\n",
==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.h#23 (text+ko) ====
@@ -328,7 +328,7 @@
AHCI_SLOT_EMPTY,
AHCI_SLOT_LOADING,
AHCI_SLOT_RUNNING,
- AHCI_SLOT_WAITING
+ AHCI_SLOT_EXECUTING
};
struct ahci_slot {
More information about the p4-projects
mailing list