From 0e07fcb33baa179ca4746beb14c610bdca63c802 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Sun, 24 Oct 2004 09:31:25 +0000 Subject: MFC: Do not retry on requests that has lost thier device during reinit. Should fix hangs on IBM's etc with the fake slave problem. Approved by: re --- sys/dev/ata/ata-all.c | 12 ++++++------ sys/dev/ata/ata-queue.c | 15 +++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index d546c588feb6..f2fccd7105a8 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -306,6 +306,12 @@ ata_reinit(struct ata_channel *ch) } } + ch->flags &= ~ATA_IMMEDIATE_MODE; + mtx_lock(&ch->state_mtx); + ch->state = ATA_IDLE; + mtx_unlock(&ch->state_mtx); + ch->locking(ch, ATA_LF_UNLOCK); + /* attach new devices */ if ((newdev = ~devices & ch->devices)) { if ((newdev & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) && @@ -323,12 +329,6 @@ ata_reinit(struct ata_channel *ch) if (bootverbose) ata_printf(ch, -1, "device config done ..\n"); - ch->flags &= ~ATA_IMMEDIATE_MODE; - mtx_lock(&ch->state_mtx); - ch->state = ATA_IDLE; - mtx_unlock(&ch->state_mtx); - ch->locking(ch, ATA_LF_UNLOCK); - ata_start(ch); return 0; } diff --git a/sys/dev/ata/ata-queue.c b/sys/dev/ata/ata-queue.c index 32332726dcf0..d0544d07ea27 100644 --- a/sys/dev/ata/ata-queue.c +++ b/sys/dev/ata/ata-queue.c @@ -182,15 +182,13 @@ ata_start(struct ata_channel *ch) /* check for the right state */ mtx_lock(&ch->state_mtx); if (ch->state == ATA_IDLE) { + ATA_DEBUG_RQ(request, "starting"); TAILQ_REMOVE(&ch->ata_queue, request, chain); ch->running = request; - - ATA_DEBUG_RQ(request, "starting"); - + ch->state = ATA_ACTIVE; if (!dumping) callout_reset(&request->callout, request->timeout * hz, (timeout_t*)ata_timeout, request); - if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) { ch->running = NULL; ch->state = ATA_IDLE; @@ -200,8 +198,6 @@ ata_start(struct ata_channel *ch) ata_finish(request); return; } - else - ch->state = ATA_ACTIVE; } mtx_unlock(&ch->state_mtx); } @@ -242,14 +238,9 @@ ata_completed(void *context, int dummy) /* if we had a timeout, reinit channel and deal with the falldown */ if (request->flags & ATA_R_TIMEOUT) { - int error = ata_reinit(ch); - /* if our device disappeared return as cleanup was done already */ - if (!request->device->param) - return; - /* if reinit succeeded and retries still permit, reinject request */ - if (!error && request->retries-- > 0) { + if (ata_reinit(ch) && request->retries-- > 0 && request->device->param){ request->flags &= ~(ATA_R_TIMEOUT | ATA_R_DEBUG); request->flags |= (ATA_R_IMMEDIATE | ATA_R_REQUEUE); ATA_DEBUG_RQ(request, "completed reinject"); -- cgit v1.2.3