diff options
author | tanimura <tanimura@FreeBSD.org> | 2001-03-14 07:29:47 +0000 |
---|---|---|
committer | tanimura <tanimura@FreeBSD.org> | 2001-03-14 07:29:47 +0000 |
commit | a6f258c4f0f90ea76335ae4af593f7482df5d7a4 (patch) | |
tree | 3e02aa536e35d86a0eb73fb532b481b978cfd764 /sys/dev | |
parent | be9d069cf0df15e40cb07b595afbe56b5359b408 (diff) | |
download | FreeBSD-src-a6f258c4f0f90ea76335ae4af593f7482df5d7a4.zip FreeBSD-src-a6f258c4f0f90ea76335ae4af593f7482df5d7a4.tar.gz |
- Do not touch the Giant.
Requested by: jhb
- Initialize a mutex prior to locking it.
Spotted by: dcs
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/sound/isa/gusmidi.c | 4 | ||||
-rw-r--r-- | sys/dev/sound/isa/mpu.c | 4 | ||||
-rw-r--r-- | sys/dev/sound/isa/uartsio.c | 4 | ||||
-rw-r--r-- | sys/dev/sound/midi/midi.c | 84 | ||||
-rw-r--r-- | sys/dev/sound/midi/midi.h | 13 | ||||
-rw-r--r-- | sys/dev/sound/midi/sequencer.c | 78 | ||||
-rw-r--r-- | sys/dev/sound/pci/csamidi.c | 4 |
7 files changed, 2 insertions, 189 deletions
diff --git a/sys/dev/sound/isa/gusmidi.c b/sys/dev/sound/isa/gusmidi.c index e40e8c1..a9b2150 100644 --- a/sys/dev/sound/isa/gusmidi.c +++ b/sys/dev/sound/isa/gusmidi.c @@ -294,8 +294,6 @@ gusmidi_intr(void *arg) scp = (sc_p)arg; devinfo = scp->devinfo; - MIDI_DROP_GIANT_NOSWITCH(); - /* XXX No framing/overrun checks... */ mtx_lock(&devinfo->flagqueue_mtx); mtx_lock(&scp->mtx); @@ -341,8 +339,6 @@ gusmidi_intr(void *arg) /* Invoke the upper layer. */ midi_intr(devinfo); - - MIDI_PICKUP_GIANT(); } static int diff --git a/sys/dev/sound/isa/mpu.c b/sys/dev/sound/isa/mpu.c index 2ccd0a2..7653010 100644 --- a/sys/dev/sound/isa/mpu.c +++ b/sys/dev/sound/isa/mpu.c @@ -457,8 +457,6 @@ mpu_intr(void *arg) scp = (sc_p)arg; devinfo = scp->devinfo; - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&devinfo->flagqueue_mtx); mtx_lock(&scp->mtx); @@ -483,8 +481,6 @@ mpu_intr(void *arg) /* Invoke the upper layer. */ midi_intr(devinfo); - - MIDI_PICKUP_GIANT(); } static int diff --git a/sys/dev/sound/isa/uartsio.c b/sys/dev/sound/isa/uartsio.c index b98e0f3..3f514a8 100644 --- a/sys/dev/sound/isa/uartsio.c +++ b/sys/dev/sound/isa/uartsio.c @@ -311,16 +311,12 @@ uartsio_intr(void *arg) scp = (sc_p)arg; devinfo = scp->devinfo; - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&devinfo->flagqueue_mtx); uartsio_xmit(scp); mtx_unlock(&devinfo->flagqueue_mtx); /* Invoke the upper layer. */ midi_intr(devinfo); - - MIDI_PICKUP_GIANT(); } static int diff --git a/sys/dev/sound/midi/midi.c b/sys/dev/sound/midi/midi.c index 3d6a16c..ce272e0 100644 --- a/sys/dev/sound/midi/midi.c +++ b/sys/dev/sound/midi/midi.c @@ -273,8 +273,6 @@ midiopen(dev_t i_dev, int flags, int mode, struct proc * p) { int ret; - MIDI_DROP_GIANT_NOSWITCH(); - switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: ret = midi_open(i_dev, flags, mode, p); @@ -287,8 +285,6 @@ midiopen(dev_t i_dev, int flags, int mode, struct proc * p) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -297,8 +293,6 @@ midiclose(dev_t i_dev, int flags, int mode, struct proc * p) { int ret; - MIDI_DROP_GIANT_NOSWITCH(); - switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: ret = midi_close(i_dev, flags, mode, p); @@ -311,8 +305,6 @@ midiclose(dev_t i_dev, int flags, int mode, struct proc * p) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -321,8 +313,6 @@ midiread(dev_t i_dev, struct uio * buf, int flag) { int ret; - MIDI_DROP_GIANT_NOSWITCH(); - switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: ret = midi_read(i_dev, buf, flag); @@ -335,8 +325,6 @@ midiread(dev_t i_dev, struct uio * buf, int flag) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -345,8 +333,6 @@ midiwrite(dev_t i_dev, struct uio * buf, int flag) { int ret; - MIDI_DROP_GIANT_NOSWITCH(); - switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: ret = midi_write(i_dev, buf, flag); @@ -356,8 +342,6 @@ midiwrite(dev_t i_dev, struct uio * buf, int flag) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -366,8 +350,6 @@ midiioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) { int ret; - MIDI_DROP_GIANT_NOSWITCH(); - switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: ret = midi_ioctl(i_dev, cmd, arg, mode, p); @@ -377,8 +359,6 @@ midiioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc * p) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -387,8 +367,6 @@ midipoll(dev_t i_dev, int events, struct proc * p) { int ret; - MIDI_DROP_GIANT_NOSWITCH(); - switch (MIDIDEV(i_dev)) { case MIDI_DEV_MIDIN: ret = midi_poll(i_dev, events, p); @@ -398,8 +376,6 @@ midipoll(dev_t i_dev, int events, struct proc * p) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -503,9 +479,6 @@ midi_read(dev_t i_dev, struct uio * buf, int flag) { int dev, unit, len, ret; mididev_info *d ; -#if defined(MIDI_OUTOFGIANT) - char *buf2; /* XXX Until uiomove(9) becomes MP-safe. */ -#endif /* MIDI_OUTOFGIANT */ dev = minor(i_dev); @@ -517,14 +490,6 @@ midi_read(dev_t i_dev, struct uio * buf, int flag) ret = 0; -#if defined(MIDI_OUTOFGIANT) - mtx_lock(&Giant); - buf2 = malloc(buf->uio_resid, M_DEVBUF, M_WAITOK); - mtx_unlock(&Giant); - if (buf2 == NULL) - return (ENOMEM); -#endif /* MIDI_OUTOFGIANT */ - mtx_lock(&d->flagqueue_mtx); /* Begin recording. */ @@ -536,15 +501,8 @@ midi_read(dev_t i_dev, struct uio * buf, int flag) if ((d->flags & MIDI_F_NBIO) != 0 && d->midi_dbuf_in.rl == 0) ret = EAGAIN; else { -#if defined(MIDI_OUTOFGIANT) - len = buf->uio_resid; - if ((d->flags & MIDI_F_NBIO) != 0 && len > d->midi_dbuf_in.rl) - len = d->midi_dbuf_in.rl; - ret = midibuf_seqread(&d->midi_dbuf_in, buf2, len, &d->flagqueue_mtx); -#else len = buf->uio_resid; ret = midibuf_uioread(&d->midi_dbuf_in, buf, len, &d->flagqueue_mtx); -#endif /* MIDI_OUTOFGIANT */ if (ret < 0) ret = -ret; else @@ -553,14 +511,6 @@ midi_read(dev_t i_dev, struct uio * buf, int flag) mtx_unlock(&d->flagqueue_mtx); -#if defined(MIDI_OUTOFGIANT) - mtx_lock(&Giant); - if (ret == 0) - uiomove((caddr_t)buf2, len, buf); - free(buf2, M_DEVBUF); - mtx_unlock(&Giant); -#endif /* MIDI_OUTOFGIANT */ - return (ret); } @@ -569,10 +519,6 @@ midi_write(dev_t i_dev, struct uio * buf, int flag) { int dev, unit, len, ret; mididev_info *d; -#if defined(MIDI_OUTOFGIANT) - char *buf2, *p; /* XXX Until uiomove(9) becomes MP-safe. */ - int resid; -#endif /* MIDI_OUTOFGIANT */ dev = minor(i_dev); d = get_mididev_info(i_dev, &unit); @@ -584,22 +530,6 @@ midi_write(dev_t i_dev, struct uio * buf, int flag) ret = 0; -#if defined(MIDI_OUTOFGIANT) - resid = buf->uio_resid; - mtx_lock(&d->flagqueue_mtx); - if (resid > d->midi_dbuf_out.fl && - (d->flags & MIDI_F_NBIO)) - resid = d->midi_dbuf_out.fl; - mtx_unlock(&d->flagqueue_mtx); - mtx_lock(&Giant); - buf2 = p = malloc(resid, M_DEVBUF, M_WAITOK); - if (buf2 == NULL) { - mtx_unlock(&Giant); - return (ENOMEM); - } - ret = uiomove((caddr_t)buf2, resid, buf); -#endif /* MIDI_OUTOFGIANT */ - mtx_lock(&d->flagqueue_mtx); /* Have we got the data to write? */ @@ -608,19 +538,11 @@ midi_write(dev_t i_dev, struct uio * buf, int flag) d->callback(d, MIDI_CB_START | MIDI_CB_WR); ret = EAGAIN; } else { -#if defined(MIDI_OUTOFGIANT) - len = resid - (p - buf2); -#else len = buf->uio_resid; -#endif /* MIDI_OUTOFGIANT */ if (len > d->midi_dbuf_out.fl && (d->flags & MIDI_F_NBIO)) len = d->midi_dbuf_out.fl; -#if defined(MIDI_OUTOFGIANT) - ret = midibuf_seqwrite(&d->midi_dbuf_out, p, len, &d->flagqueue_mtx); -#else ret = midibuf_uiowrite(&d->midi_dbuf_out, buf, len, &d->flagqueue_mtx); -#endif /* MIDI_OUTOFGIANT */ if (ret < 0) ret = -ret; else { @@ -632,12 +554,6 @@ midi_write(dev_t i_dev, struct uio * buf, int flag) mtx_unlock(&d->flagqueue_mtx); -#if defined(MIDI_OUTOFGIANT) - mtx_lock(&Giant); - free(buf2, M_DEVBUF); - mtx_unlock(&Giant); -#endif /* MIDI_OUTOFGIANT */ - return (ret); } diff --git a/sys/dev/sound/midi/midi.h b/sys/dev/sound/midi/midi.h index d9b81c7..f6e54b1 100644 --- a/sys/dev/sound/midi/midi.h +++ b/sys/dev/sound/midi/midi.h @@ -75,19 +75,6 @@ /*#define MIDI_OUTOFGIANT*/ -#if defined(MIDI_OUTOFGIANT) -#define MIDI_DROP_GIANT DROP_GIANT -#define MIDI_DROP_GIANT_NOSWITCH DROP_GIANT_NOSWITCH -#define MIDI_PICKUP_GIANT PICKUP_GIANT -#define MIDI_PARTIAL_PICKUP_GIANT PARTIAL_PICKUP_GIANT -#else -#define MIDI_DROP_GIANT() -#define MIDI_DROP_GIANT_NOSWITCH() -#define MIDI_PICKUP_GIANT() -#define MIDI_PARTIAL_PICKUP_GIANT() -#endif /* MIDI_OUTOFGIANT */ - - /* * The order of mutex lock (from the first to the last) * diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c index dd4ce6a..34995d6 100644 --- a/sys/dev/sound/midi/sequencer.c +++ b/sys/dev/sound/midi/sequencer.c @@ -291,13 +291,10 @@ seq_open(dev_t i_dev, int flags, int mode, struct proc *p) } scp = sd->softc; - MIDI_DROP_GIANT_NOSWITCH(); - /* Mark this device busy. */ mtx_lock(&sd->flagqueue_mtx); if ((sd->flags & SEQ_F_BUSY) != 0) { mtx_unlock(&sd->flagqueue_mtx); - MIDI_PARTIAL_PICKUP_GIANT(); DEB(printf("seq_open: unit %d is busy.\n", unit)); return (EBUSY); } @@ -317,8 +314,6 @@ seq_open(dev_t i_dev, int flags, int mode, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); - MIDI_PICKUP_GIANT(); - DEB(printf("seq%d: opened.\n", unit)); return (0); @@ -348,8 +343,6 @@ seq_close(dev_t i_dev, int flags, int mode, struct proc *p) } scp = sd->softc; - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&sd->flagqueue_mtx); if (!(sd->flags & MIDI_F_NBIO)) @@ -372,8 +365,6 @@ seq_close(dev_t i_dev, int flags, int mode, struct proc *p) sd->flags &= ~(SEQ_F_BUSY | SEQ_F_READING | SEQ_F_WRITING | SEQ_F_INSYNC); mtx_unlock(&sd->flagqueue_mtx); - MIDI_PICKUP_GIANT(); - DEB(printf("seq%d: closed.\n", unit)); return (0); @@ -385,9 +376,6 @@ seq_read(dev_t i_dev, struct uio *buf, int flag) int unit, ret, len; sc_p scp; seqdev_info *sd; -#if defined(MIDI_OUTOFGIANT) - char *buf2; /* XXX Until uiomove(9) becomes MP-safe. */ -#endif /* MIDI_OUTOFGIANT */ unit = MIDIUNIT(i_dev); @@ -409,14 +397,6 @@ seq_read(dev_t i_dev, struct uio *buf, int flag) return (EIO); } -#if defined(MIDI_OUTOFGIANT) - buf2 = malloc(buf->uio_resid, M_DEVBUF, M_WAITOK); - if (buf2 == NULL) - return (ENOMEM); -#endif /* MIDI_OUTOFGIANT */ - - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&sd->flagqueue_mtx); /* Begin recording. */ @@ -429,15 +409,8 @@ seq_read(dev_t i_dev, struct uio *buf, int flag) if ((sd->flags & SEQ_F_NBIO) != 0 && sd->midi_dbuf_in.rl == 0) ret = EAGAIN; else { -#if defined(MIDI_OUTOFGIANT) - len = buf->uio_resid; - if ((sd->flags & SEQ_F_NBIO) != 0 && len > sd->midi_dbuf_in.rl) - len = sd->midi_dbuf_in.rl; - ret = midibuf_seqread(&sd->midi_dbuf_in, buf2, len, &sd->flagqueue_mtx); -#else len = buf->uio_resid; ret = midibuf_uioread(&sd->midi_dbuf_in, buf, len, &sd->flagqueue_mtx); -#endif /* MIDI_OUTOFGIANT */ if (ret < 0) ret = -ret; else @@ -445,14 +418,6 @@ seq_read(dev_t i_dev, struct uio *buf, int flag) } mtx_unlock(&sd->flagqueue_mtx); - MIDI_PICKUP_GIANT(); - -#if defined(MIDI_OUTOFGIANT) - if (ret == 0) - uiomove((caddr_t)buf2, len, buf); - free(buf2, M_DEVBUF); -#endif /* MIDI_OUTOFGIANT */ - return (ret); } @@ -489,18 +454,10 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) countorg = buf->uio_resid; count = countorg; - MIDI_DROP_GIANT_NOSWITCH(); - /* Pick up an event. */ while (count >= 4) { -#if defined(MIDI_OUTOFGIANT) - mtx_lock(&Giant); -#endif /* MIDI_OUTOFGIANT */ if (uiomove((caddr_t)event, 4, buf)) printf("seq_write: user memory mangled?\n"); -#if defined(MIDI_OUTOFGIANT) - mtx_unlock(&Giant); -#endif /* MIDI_OUTOFGIANT */ ev_code = event[0]; /* Have a look at the event code. */ @@ -511,15 +468,12 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) mtx_lock(&sd->flagqueue_mtx); ret = lookup_mididev(scp, midiunit, LOOKUP_OPEN, &md); mtx_unlock(&sd->flagqueue_mtx); - if (ret != 0) { - MIDI_PARTIAL_PICKUP_GIANT(); + if (ret != 0) return (ret); - } DEB(printf("seq_write: loading a patch to the unit %d.\n", midiunit)); ret = md->synth.loadpatch(md, *(short *)&event[0], buf, p + 4, count, 0); - MIDI_PARTIAL_PICKUP_GIANT(); return (ret); } @@ -528,7 +482,6 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) /* Some sort of an extended event. The size is eight bytes. */ #if notyet if (scp->seq_mode == SEQ_2 && ev_code == SEQ_EXTENDED) { - MIDI_PARTIAL_PICKUP_GIANT(); printf("seq%d: invalid level two event %x.\n", unit, ev_code); return (EINVAL); } @@ -542,23 +495,15 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) sd->callback(sd, SEQ_CB_START | SEQ_CB_WR); mtx_unlock(&sd->flagqueue_mtx); - MIDI_PARTIAL_PICKUP_GIANT(); return (0); } -#if defined(MIDI_OUTOFGIANT) - mtx_lock(&Giant); -#endif /* MIDI_OUTOFGIANT */ if (uiomove((caddr_t)&event[4], 4, buf)) printf("seq_write: user memory mangled?\n"); -#if defined(MIDI_OUTOFGIANT) - mtx_unlock(&Giant); -#endif /* MIDI_OUTOFGIANT */ } else { /* Not an extended event. The size is four bytes. */ #if notyet if (scp->seq_mode == SEQ_2) { - MIDI_PARTIAL_PICKUP_GIANT(); printf("seq%d: four byte event in level two mode.\n", unit); return (EINVAL); } @@ -571,10 +516,8 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) mtx_lock(&sd->flagqueue_mtx); ret = lookup_mididev(scp, midiunit, LOOKUP_OPEN, &md); mtx_unlock(&sd->flagqueue_mtx); - if (ret != 0) { - MIDI_PARTIAL_PICKUP_GIANT(); + if (ret != 0) return (ret); - } } /*DEB(printf("seq_write: queueing event %d.\n", event[0]));*/ @@ -586,15 +529,12 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) if ((sd->flags & SEQ_F_WRITING) == 0) sd->callback(sd, SEQ_CB_START | SEQ_CB_WR); mtx_unlock(&sd->flagqueue_mtx); - MIDI_PARTIAL_PICKUP_GIANT(); return (0); case EINTR: mtx_unlock(&sd->flagqueue_mtx); - MIDI_PARTIAL_PICKUP_GIANT(); return (EINTR); case ERESTART: mtx_unlock(&sd->flagqueue_mtx); - MIDI_PARTIAL_PICKUP_GIANT(); return (ERESTART); } mtx_unlock(&sd->flagqueue_mtx); @@ -608,8 +548,6 @@ seq_write(dev_t i_dev, struct uio *buf, int flag) sd->callback(sd, SEQ_CB_START | SEQ_CB_WR); mtx_unlock(&sd->flagqueue_mtx); - MIDI_PICKUP_GIANT(); - return (0); } @@ -642,8 +580,6 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) } scp = sd->softc; - MIDI_DROP_GIANT_NOSWITCH(); - ret = 0; switch (cmd) { @@ -940,8 +876,6 @@ seq_ioctl(dev_t i_dev, u_long cmd, caddr_t arg, int mode, struct proc *p) break; } - MIDI_PICKUP_GIANT(); - return (ret); } @@ -967,8 +901,6 @@ seq_poll(dev_t i_dev, int events, struct proc *p) } scp = sd->softc; - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&sd->flagqueue_mtx); ret = 0; @@ -1009,8 +941,6 @@ seq_poll(dev_t i_dev, int events, struct proc *p) mtx_unlock(&sd->flagqueue_mtx); - MIDI_PICKUP_GIANT(); - return (ret); } @@ -1023,8 +953,6 @@ seq_intr(void *p, mididev_info *md) sd = (seqdev_info *)p; scp = sd->softc; - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&sd->flagqueue_mtx); /* Restart playing if we have the data to output. */ @@ -1035,8 +963,6 @@ seq_intr(void *p, mididev_info *md) seq_midiinput(scp, md); mtx_unlock(&sd->flagqueue_mtx); - - MIDI_PICKUP_GIANT(); } static int diff --git a/sys/dev/sound/pci/csamidi.c b/sys/dev/sound/pci/csamidi.c index 256d485..f646a37 100644 --- a/sys/dev/sound/pci/csamidi.c +++ b/sys/dev/sound/pci/csamidi.c @@ -262,8 +262,6 @@ csamidi_intr(void *arg) scp = (sc_p)arg; devinfo = scp->devinfo; - MIDI_DROP_GIANT_NOSWITCH(); - mtx_lock(&devinfo->flagqueue_mtx); mtx_lock(&scp->mtx); @@ -294,8 +292,6 @@ csamidi_intr(void *arg) /* Invoke the upper layer. */ midi_intr(devinfo); - - MIDI_PICKUP_GIANT(); } static int |