Use separate callouts for motor-on and motor-off. Fixes a condition
where the floppy driver would wedge because a motor-on timeout would be cancelled by another I/O operation cancelling a motor-off timeout. From enami tsugutomo <enami@sm.sony.co.jp>.
This commit is contained in:
parent
6dd5a9db6e
commit
4044b5a41c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.19 2000/03/27 11:22:51 soda Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.20 2000/04/07 16:58:54 thorpej Exp $ */
|
||||
/* $OpenBSD: fd.c,v 1.6 1998/10/03 21:18:57 millert Exp $ */
|
||||
/* NetBSD: fd.c,v 1.78 1995/07/04 07:23:09 mycroft Exp */
|
||||
|
||||
@ -194,7 +194,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -406,7 +407,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -518,7 +520,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -582,7 +584,7 @@ fdfinish(fd, bp)
|
||||
BUFQ_REMOVE(&fd->sc_q, bp);
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 10 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 10 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -872,7 +874,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return 1;
|
||||
@ -881,14 +883,14 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
fd_set_motor(fdc, 0);
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
/* Allow .5s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 2,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 2,
|
||||
fd_motor_on, fd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.28 2000/03/23 06:35:15 thorpej Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.29 2000/04/07 16:58:54 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -228,7 +228,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
struct fd_type sc_type_copy; /* copy for fiddling when formatting */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -524,7 +525,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -643,7 +645,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -709,7 +711,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -1012,7 +1014,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return 1;
|
||||
@ -1021,14 +1023,14 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
fd_set_motor(fdc, 0);
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
/* Allow .25s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 4,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 4,
|
||||
fd_motor_on, fd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hdfd.c,v 1.21 2000/03/29 14:19:22 leo Exp $ */
|
||||
/* $NetBSD: hdfd.c,v 1.22 2000/04/07 16:58:55 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 Leo Weppelman
|
||||
@ -217,7 +217,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -481,7 +482,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -608,7 +610,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -674,7 +676,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -964,7 +966,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return 1;
|
||||
@ -973,14 +975,14 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
fd_set_motor(fdc, 0);
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
/* Allow .25s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 4,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 4,
|
||||
fd_motor_on, fd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.79 2000/03/24 10:30:12 hannken Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.80 2000/04/07 16:58:55 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -239,7 +239,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -761,7 +762,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -870,7 +872,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -935,7 +937,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -1445,7 +1447,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = (bp->b_blkno * DEV_BSIZE) / FD_BSIZE(fd);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return (1);
|
||||
@ -1454,7 +1456,7 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
@ -1462,7 +1464,7 @@ loop:
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
if ((fdc->sc_flags & FDC_NEEDMOTORWAIT) != 0) { /*XXX*/
|
||||
/* Allow .25s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 4,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 4,
|
||||
fd_motor_on, fd);
|
||||
} else {
|
||||
fd->sc_flags &= ~FD_MOTOR_WAIT;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.13 2000/03/23 06:45:37 thorpej Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.14 2000/04/07 16:58:56 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum.
|
||||
@ -198,7 +198,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -535,7 +536,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -640,7 +642,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -705,7 +707,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -1166,7 +1168,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return (1);
|
||||
@ -1175,7 +1177,7 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
@ -1183,7 +1185,7 @@ loop:
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
if (fdc->sc_flags & FDC_82077) { /* XXX */
|
||||
/* Allow .25s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 4,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 4,
|
||||
fd_motor_on, fd);
|
||||
} else {
|
||||
fd->sc_flags &= ~FD_MOTOR_WAIT;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.17 2000/03/31 14:18:53 tsutsui Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.18 2000/04/07 16:58:56 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993, 1994, 1995 Charles M. Hannum.
|
||||
@ -201,7 +201,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -510,7 +511,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -639,7 +641,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -704,7 +706,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -1160,7 +1162,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return (1);
|
||||
@ -1169,7 +1171,7 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
@ -1177,7 +1179,7 @@ loop:
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
if (fdc->sc_flags & FDC_82077) { /* XXX */
|
||||
/* Allow .25s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 4,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 4,
|
||||
fd_motor_on, fd);
|
||||
} else {
|
||||
fd->sc_flags &= ~FD_MOTOR_WAIT;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.32 2000/03/27 15:49:34 minoura Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.33 2000/04/07 16:58:56 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -225,7 +225,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_deftype; /* default type descriptor */
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -589,7 +590,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = &fd_types[0]; /* XXX 1.2MB */
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
fd->sc_flags = 0;
|
||||
|
||||
@ -692,7 +694,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -761,7 +763,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -1109,7 +1111,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return 1;
|
||||
@ -1120,7 +1122,7 @@ loop:
|
||||
for (i = 0; i < 4; i++) {
|
||||
struct fd_softc *ofd = fdc->sc_fd[i];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
break;
|
||||
}
|
||||
@ -1129,7 +1131,7 @@ loop:
|
||||
fd_set_motor(fdc, 0);
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
/* allow .5s for motor to stabilize */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 2,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 2,
|
||||
fd_motor_on, fd);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fd.c,v 1.1 2000/04/07 16:32:03 thorpej Exp $ */
|
||||
/* $NetBSD: fd.c,v 1.2 2000/04/07 16:58:53 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -253,7 +253,8 @@ struct fd_softc {
|
||||
struct fd_type *sc_type; /* current type descriptor */
|
||||
struct fd_type sc_type_copy; /* copy for fiddling when formatting */
|
||||
|
||||
struct callout sc_motor_ch;
|
||||
struct callout sc_motoron_ch;
|
||||
struct callout sc_motoroff_ch;
|
||||
|
||||
daddr_t sc_blkno; /* starting block number */
|
||||
int sc_bcount; /* byte count left */
|
||||
@ -593,7 +594,8 @@ fdattach(parent, self, aux)
|
||||
struct fd_type *type = fa->fa_deftype;
|
||||
int drive = fa->fa_drive;
|
||||
|
||||
callout_init(&fd->sc_motor_ch);
|
||||
callout_init(&fd->sc_motoron_ch);
|
||||
callout_init(&fd->sc_motoroff_ch);
|
||||
|
||||
/* XXX Allow `flags' to override device type? */
|
||||
|
||||
@ -725,7 +727,7 @@ fdstrategy(bp)
|
||||
/* Queue transfer on drive, activate drive and controller if idle. */
|
||||
s = splbio();
|
||||
disksort_cylinder(&fd->sc_q, bp);
|
||||
callout_stop(&fd->sc_motor_ch); /* a good idea */
|
||||
callout_stop(&fd->sc_motoroff_ch); /* a good idea */
|
||||
if (fd->sc_active == 0)
|
||||
fdstart(fd);
|
||||
#ifdef DIAGNOSTIC
|
||||
@ -795,7 +797,7 @@ fdfinish(fd, bp)
|
||||
|
||||
biodone(bp);
|
||||
/* turn off motor 5s from now */
|
||||
callout_reset(&fd->sc_motor_ch, 5 * hz, fd_motor_off, fd);
|
||||
callout_reset(&fd->sc_motoroff_ch, 5 * hz, fd_motor_off, fd);
|
||||
fdc->sc_state = DEVIDLE;
|
||||
}
|
||||
|
||||
@ -1098,7 +1100,7 @@ loop:
|
||||
fd->sc_skip = 0;
|
||||
fd->sc_bcount = bp->b_bcount;
|
||||
fd->sc_blkno = bp->b_blkno / (FDC_BSIZE / DEV_BSIZE);
|
||||
callout_stop(&fd->sc_motor_ch);
|
||||
callout_stop(&fd->sc_motoroff_ch);
|
||||
if ((fd->sc_flags & FD_MOTOR_WAIT) != 0) {
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
return 1;
|
||||
@ -1107,14 +1109,14 @@ loop:
|
||||
/* Turn on the motor, being careful about pairing. */
|
||||
struct fd_softc *ofd = fdc->sc_fd[fd->sc_drive ^ 1];
|
||||
if (ofd && ofd->sc_flags & FD_MOTOR) {
|
||||
callout_stop(&ofd->sc_motor_ch);
|
||||
callout_stop(&ofd->sc_motoroff_ch);
|
||||
ofd->sc_flags &= ~(FD_MOTOR | FD_MOTOR_WAIT);
|
||||
}
|
||||
fd->sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
|
||||
fd_set_motor(fdc, 0);
|
||||
fdc->sc_state = MOTORWAIT;
|
||||
/* Allow .25s for motor to stabilize. */
|
||||
callout_reset(&fd->sc_motor_ch, hz / 4,
|
||||
callout_reset(&fd->sc_motoron_ch, hz / 4,
|
||||
fd_motor_on, fd);
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user