From owner-p4-projects@FreeBSD.ORG Tue Oct 13 09:13:55 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CC8451065672; Tue, 13 Oct 2009 09:13:54 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9103F106566B for ; Tue, 13 Oct 2009 09:13:54 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 7EBCE8FC0C for ; Tue, 13 Oct 2009 09:13:54 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n9D9DsbV085869 for ; Tue, 13 Oct 2009 09:13:54 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n9D9DsMD085867 for perforce@freebsd.org; Tue, 13 Oct 2009 09:13:54 GMT (envelope-from mav@freebsd.org) Date: Tue, 13 Oct 2009 09:13:54 GMT Message-Id: <200910130913.n9D9DsMD085867@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Cc: Subject: PERFORCE change 169446 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2009 09:13:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=169446 Change 169446 by mav@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 {