Date: Sun, 14 Jun 2009 12:45:04 GMT From: Alexander Motin <mav@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 164334 for review Message-ID: <200906141245.n5ECj4BV005467@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906141245.n5ECj4BV005467>