summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2013-11-02 22:58:49 +0000
committerdlg <dlg@openbsd.org>2013-11-02 22:58:49 +0000
commit274ffc924d53a7274c52690d04df24d3a3f5a13f (patch)
tree4e37944e3acf5270c2d0dc73f924a3b1e96365e9
parentReplace drm_handle_create/delete with drm_gem_handle_create/delete and make (diff)
downloadwireguard-openbsd-274ffc924d53a7274c52690d04df24d3a3f5a13f.tar.xz
wireguard-openbsd-274ffc924d53a7274c52690d04df24d3a3f5a13f.zip
replace bare use of disksort with a bufq, modelled on the sys/dev/isa/fd.c
change. ok miod@
-rw-r--r--sys/arch/sparc64/dev/fd.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/sys/arch/sparc64/dev/fd.c b/sys/arch/sparc64/dev/fd.c
index 72b1c785d12..36436fdfb81 100644
--- a/sys/arch/sparc64/dev/fd.c
+++ b/sys/arch/sparc64/dev/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.41 2013/11/01 17:36:19 krw Exp $ */
+/* $OpenBSD: fd.c,v 1.42 2013/11/02 22:58:49 dlg Exp $ */
/* $NetBSD: fd.c,v 1.112 2003/08/07 16:29:35 agc Exp $ */
/*-
@@ -267,7 +267,8 @@ struct fd_softc {
TAILQ_ENTRY(fd_softc) sc_drivechain;
int sc_ops; /* I/O ops since last switch */
- struct buf sc_q; /* pending I/O requests */
+ struct bufq sc_bufq; /* pending I/O requests */
+ struct buf *sc_bp; /* current I/O */
};
/* floppy driver configuration */
@@ -669,6 +670,7 @@ fdattach(parent, self, aux)
*/
fd->sc_dk.dk_flags = DKF_NOLABELREAD;
fd->sc_dk.dk_name = fd->sc_dv.dv_xname;
+ bufq_init(&fd->sc_bufq, BUFQ_DEFAULT);
disk_attach(&fd->sc_dv, &fd->sc_dk);
}
@@ -752,11 +754,13 @@ fdstrategy(bp)
(long long)fd->sc_blkno, bp->b_cylinder);
#endif
+ /* Queue transfer */
+ bufq_queue(&fd->sc_bufq, bp);
+
/* Queue transfer on drive, activate drive and controller if idle. */
s = splbio();
- disksort(&fd->sc_q, bp);
timeout_del(&fd->sc_motoroff_to); /* a good idea */
- if (!fd->sc_q.b_active)
+ if (fd->sc_bp == NULL)
fdstart(fd);
#ifdef DIAGNOSTIC
else {
@@ -787,7 +791,7 @@ fdstart(fd)
int active = !TAILQ_EMPTY(&fdc->sc_drives);
/* Link into controller queue. */
- fd->sc_q.b_active = 1;
+ fd->sc_bp = bufq_dequeue(&fd->sc_bufq);
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
/* If controller not already active, start it. */
@@ -802,6 +806,9 @@ fdfinish(fd, bp)
{
struct fdc_softc *fdc = (void *)fd->sc_dv.dv_parent;
+ fd->sc_skip = 0;
+ fd->sc_bp = bufq_dequeue(&fd->sc_bufq);
+
/*
* Move this drive to the end of the queue to give others a `fair'
* chance. We only force a switch if N operations are completed while
@@ -811,15 +818,11 @@ fdfinish(fd, bp)
if (TAILQ_NEXT(fd, sc_drivechain) != NULL && ++fd->sc_ops >= 8) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
- if (bp->b_actf) {
+ if (fd->sc_bp != NULL)
TAILQ_INSERT_TAIL(&fdc->sc_drives, fd, sc_drivechain);
- } else
- fd->sc_q.b_active = 0;
}
- bp->b_resid = fd->sc_bcount;
- fd->sc_skip = 0;
- fd->sc_q.b_actf = bp->b_actf;
+ bp->b_resid = fd->sc_bcount;
biodone(bp);
/* turn off motor 5s from now */
timeout_add_sec(&fd->sc_motoroff_to, 5);
@@ -1140,7 +1143,7 @@ fdctimeout(arg)
goto out;
}
- if (fd->sc_q.b_actf)
+ if (fd->sc_bp != NULL)
fdc->sc_state++;
else
fdc->sc_state = DEVIDLE;
@@ -1317,11 +1320,10 @@ loop:
}
/* Is there a transfer to this drive? If not, deactivate drive. */
- bp = fd->sc_q.b_actf;
+ bp = fd->sc_bp;
if (bp == NULL) {
fd->sc_ops = 0;
TAILQ_REMOVE(&fdc->sc_drives, fd, sc_drivechain);
- fd->sc_q.b_active = 0;
goto loop;
}
@@ -1736,7 +1738,7 @@ fdcretry(fdc)
int error = EIO;
fd = TAILQ_FIRST(&fdc->sc_drives);
- bp = fd->sc_q.b_actf;
+ bp = fd->sc_bp;
fdc->sc_overruns = 0;
if (fd->sc_opts & FDOPT_NORETRY)