From owner-p4-projects@FreeBSD.ORG Sun Jun 14 12:45:05 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4A98B1065676; Sun, 14 Jun 2009 12:45:05 +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 080401065675 for ; Sun, 14 Jun 2009 12:45:05 +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 E5A348FC25 for ; Sun, 14 Jun 2009 12:45:04 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5ECj42A005469 for ; Sun, 14 Jun 2009 12:45:04 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5ECj4BV005467 for perforce@freebsd.org; Sun, 14 Jun 2009 12:45:04 GMT (envelope-from mav@freebsd.org) Date: Sun, 14 Jun 2009 12:45:04 GMT Message-Id: <200906141245.n5ECj4BV005467@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 164334 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: Sun, 14 Jun 2009 12:45:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=164334 Change 164334 by mav@mav_mavbook on 2009/06/14 12:44:53 On hard reset requeue all running/pending commands. Affected files ... .. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#29 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#29 (text+ko) ==== @@ -69,7 +69,6 @@ static void ahci_execute_transaction(struct ahci_slot *slot); static void ahci_timeout(struct ahci_slot *slot); static void ahci_end_transaction(struct ahci_slot *slot, enum ahci_err_type et); -static int ahci_hardreset(device_t dev); static int ahci_setup_fis(struct ahci_cmd_tab *ctp, union ccb *ccb, int tag); static void ahci_dmainit(device_t dev); static void ahci_dmasetupc_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int error); @@ -1128,30 +1127,9 @@ { device_t dev = slot->dev; struct ahci_channel *ch = device_get_softc(dev); - enum ahci_err_type et; - int i; device_printf(dev, "Timeout on slot %d\n", slot->slot); - /* Requeue freezed command. */ - if (ch->frozen) { - union ccb *fccb = ch->frozen; - ch->frozen = NULL; - xpt_release_simq(ch->sim, TRUE); - fccb->ccb_h.status = CAM_SCSI_BUS_RESET; - xpt_done(fccb); - } - /* Kill the engine and terminate all commands. */ - ahci_stop(dev); - for (i = 0; i < ch->numslots; i++) { - /* Do we have a running request on slot? */ - if (ch->slot[i].state < AHCI_SLOT_RUNNING) - continue; - if (i == slot->slot) - et = AHCI_ERR_TIMEOUT; - else - et = AHCI_ERR_RESET; - ahci_end_transaction(&ch->slot[i], et); - } + ahci_end_transaction(&ch->slot[slot->slot], AHCI_ERR_TIMEOUT); /* XXX: This is wrong for NCQ error recovery. */ ahci_reset(dev); } @@ -1376,35 +1354,34 @@ return (0); } -static int -ahci_hardreset(device_t dev) -{ - - ahci_stop(dev); - /* Reset port */ - if (!ahci_sata_phy_reset(dev, 0)) - return (ENOENT); - /* Wait for clearing busy status. */ - if (ahci_wait_ready(dev, 10000)) { - device_printf(dev, "device ready timeout\n"); - ahci_clo(dev); - } - ahci_start(dev); - return (0); -} - static void ahci_reset(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); + int i; if (bootverbose) device_printf(dev, "AHCI reset...\n"); - + /* Requeue freezed command. */ + if (ch->frozen) { + union ccb *fccb = ch->frozen; + ch->frozen = NULL; + xpt_release_simq(ch->sim, TRUE); + fccb->ccb_h.status = CAM_SCSI_BUS_RESET; + xpt_done(fccb); + } + /* Kill the engine and requeue all running commands. */ + ahci_stop(dev); + for (i = 0; i < ch->numslots; i++) { + /* Do we have a running request on slot? */ + if (ch->slot[i].state < AHCI_SLOT_RUNNING) + continue; + ahci_end_transaction(&ch->slot[i], AHCI_ERR_RESET); + } /* Disable port interrupts */ ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); /* Reset and reconnect PHY, */ - if (ahci_hardreset(dev)) { + if (!ahci_sata_phy_reset(dev, 0)) { if (bootverbose) device_printf(dev, "AHCI reset done: phy reset found no device\n"); @@ -1414,6 +1391,12 @@ (AHCI_P_IX_CPD | AHCI_P_IX_PRC | AHCI_P_IX_PC)); return; } + /* Wait for clearing busy status. */ + if (ahci_wait_ready(dev, 10000)) { + device_printf(dev, "device ready timeout\n"); + ahci_clo(dev); + } + ahci_start(dev); ch->devices = 1; /* Enable wanted port interrupts */ ATA_OUTL(ch->r_mem, AHCI_P_IE, @@ -1424,9 +1407,8 @@ AHCI_P_IX_DS | AHCI_P_IX_PS | AHCI_P_IX_DHR)); if (bootverbose) device_printf(dev, "AHCI reset done: devices=%08x\n", ch->devices); - /* If we've attached to the XPT, tell it about the event */ - if (ch->path != NULL) - xpt_async(AC_BUS_RESET, ch->path, NULL); + /* Tell the XPT about the event */ + xpt_async(AC_BUS_RESET, ch->path, NULL); } static int