Index: ata-all.c =================================================================== RCS file: /home/cvs/ncvs/src/sys/dev/ata/ata-all.c,v retrieving revision 1.232 diff -u -u -r1.232 ata-all.c --- ata-all.c 13 Oct 2004 15:16:35 -0000 1.232 +++ ata-all.c 19 Oct 2004 19:30:59 -0000 @@ -86,6 +86,7 @@ static struct intr_config_hook *ata_delayed_attach = NULL; static int ata_dma = 1; static int atapi_dma = 1; +static int ata_resuming = 0; /* sysctl vars */ SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters"); @@ -337,20 +352,21 @@ ata_suspend(device_t dev) { struct ata_channel *ch; - int gotit = 0; if (!dev || !(ch = device_get_softc(dev))) return ENXIO; - while (!gotit) { + while (1) { mtx_lock(&ch->state_mtx); if (ch->state == ATA_IDLE) { ch->state = ATA_ACTIVE; - gotit = 1; + mtx_unlock(&ch->state_mtx); + goto out; } mtx_unlock(&ch->state_mtx); - tsleep(&gotit, PRIBIO, "atasusp", hz/10); + tsleep(ch, PRIBIO, "atasusp", hz/10); } +out: ch->locking(ch, ATA_LF_UNLOCK); return 0; } @@ -364,8 +380,10 @@ if (!dev || !(ch = device_get_softc(dev))) return ENXIO; + ata_resuming = 1; error = ata_reinit(ch); ata_start(ch); + ata_resuming = 0; return error; } @@ -838,7 +944,7 @@ void ata_udelay(int interval) { - if (interval < (1000000/hz) || ata_delayed_attach) + if (interval < (1000000/hz) || ata_delayed_attach || ata_resuming) DELAY(interval); else tsleep(&interval, PRIBIO, "ataslp", interval/(1000000/hz));