Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/dev/audio Pull up following revision(s) (requested by...



details:   https://anonhg.NetBSD.org/src/rev/656fa976792f
branches:  netbsd-9
changeset: 746078:656fa976792f
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Mar 21 15:41:18 2020 +0000

description:
Pull up following revision(s) (requested by isaki in ticket #793):

        sys/dev/audio/audio.c: revision 1.42
        sys/dev/audio/audio.c: revision 1.47
        sys/dev/audio/audiodef.h: revision 1.9

Remove incorrect KASSERT(!mutex_owned()).
Pointed out by riastradh@.

Improve KASSERT messages.

diffstat:

 sys/dev/audio/audio.c    |  150 ++++++++++++++++++++++++++--------------------
 sys/dev/audio/audiodef.h |   15 +++-
 2 files changed, 95 insertions(+), 70 deletions(-)

diffs (truncated from 459 to 300 lines):

diff -r 111104144ffc -r 656fa976792f sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Sat Mar 21 15:31:50 2020 +0000
+++ b/sys/dev/audio/audio.c     Sat Mar 21 15:41:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.28.2.7 2020/01/21 11:19:19 martin Exp $    */
+/*     $NetBSD: audio.c,v 1.28.2.8 2020/03/21 15:41:18 martin Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.7 2020/01/21 11:19:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.8 2020/03/21 15:41:18 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1357,14 +1357,13 @@
 /*
  * Acquire sc_lock and enter exlock critical section.
  * If successful, it returns 0.  Otherwise returns errno.
+ * Must be called without sc_lock held.
  */
 static int
 audio_enter_exclusive(struct audio_softc *sc)
 {
        int error;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
        mutex_enter(sc->sc_lock);
        if (sc->sc_dying) {
                mutex_exit(sc->sc_lock);
@@ -2062,7 +2061,7 @@
                *bellfile = af;
        } else {
                error = fd_clone(fp, fd, flags, &audio_fileops, af);
-               KASSERT(error == EMOVEFD);
+               KASSERTMSG(error == EMOVEFD, "error=%d", error);
        }
 
        TRACEF(3, af, "done");
@@ -2095,7 +2094,7 @@
 }
 
 /*
- * Must NOT called with sc_lock nor sc_exlock held.
+ * Must be called without sc_lock nor sc_exlock held.
  */
 int
 audio_close(struct audio_softc *sc, audio_file_t *file)
@@ -2103,8 +2102,6 @@
        audio_track_t *oldtrack;
        int error;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
        TRACEF(1, file, "%spid=%d.%d po=%d ro=%d",
            (audiodebug >= 3) ? "start " : "",
            (int)curproc->p_pid, (int)curlwp->l_lid,
@@ -2205,6 +2202,9 @@
        return 0;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_read(struct audio_softc *sc, struct uio *uio, int ioflag,
        audio_file_t *file)
@@ -2214,8 +2214,6 @@
        audio_ring_t *input;
        int error;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
        /*
         * On half-duplex hardware, O_RDWR is treated as O_WRONLY.
         * However read() system call itself can be called because it's
@@ -2332,6 +2330,9 @@
                audio_track_clear(sc, file->rtrack);
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_write(struct audio_softc *sc, struct uio *uio, int ioflag,
        audio_file_t *file)
@@ -2341,8 +2342,6 @@
        audio_ring_t *outbuf;
        int error;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
        track = file->ptrack;
        KASSERT(track);
 
@@ -2454,6 +2453,9 @@
        return error;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_ioctl(dev_t dev, struct audio_softc *sc, u_long cmd, void *addr, int flag,
        struct lwp *l, audio_file_t *file)
@@ -2469,8 +2471,6 @@
        int index;
        int error;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
 #if defined(AUDIO_DEBUG)
        const char *ioctlnames[] = {
                " AUDIO_GETINFO",       /* 21 */
@@ -2762,6 +2762,9 @@
        return bytes;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_poll(struct audio_softc *sc, int events, struct lwp *l,
        audio_file_t *file)
@@ -2771,8 +2774,6 @@
        bool in_is_valid;
        bool out_is_valid;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
 #if defined(AUDIO_DEBUG)
 #define POLLEV_BITMAP "\177\020" \
            "b\10WRBAND\0" \
@@ -2920,13 +2921,14 @@
        return (track->usrbuf.used < track->usrbuf_usedlow);
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_kqfilter(struct audio_softc *sc, audio_file_t *file, struct knote *kn)
 {
        struct klist *klist;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
        TRACEF(3, file, "kn=%p kn_filter=%x", kn, (int)kn->kn_filter);
 
        switch (kn->kn_filter) {
@@ -2953,6 +2955,9 @@
        return 0;
 }
 
+/*
+ * Must be called without sc_lock nor sc_exlock held.
+ */
 int
 audio_mmap(struct audio_softc *sc, off_t *offp, size_t len, int prot,
        int *flagsp, int *advicep, struct uvm_object **uobjp, int *maxprotp,
@@ -2962,8 +2967,6 @@
        vsize_t vsize;
        int error;
 
-       KASSERT(!mutex_owned(sc->sc_lock));
-
        TRACEF(2, file, "off=%lld, prot=%d", (long long)(*offp), prot);
 
        if (*offp < 0)
@@ -3056,7 +3059,7 @@
        /* Not necessary to insert sc_files. */
 
        error = fd_clone(fp, fd, flags, &audio_fileops, af);
-       KASSERT(error == EMOVEFD);
+       KASSERTMSG(error == EMOVEFD, "error=%d", error);
 
        return error;
 }
@@ -3209,9 +3212,12 @@
        u_int channels;
 
        DIAGNOSTIC_filter_arg(arg);
-       KASSERT(arg->srcfmt->channels == arg->dstfmt->channels);
+       KASSERTMSG(arg->srcfmt->channels == arg->dstfmt->channels,
+           "arg->srcfmt->channels=%d, arg->dstfmt->channels=%d",
+           arg->srcfmt->channels, arg->dstfmt->channels);
        KASSERT(arg->context != NULL);
-       KASSERT(arg->srcfmt->channels <= AUDIO_MAX_CHANNELS);
+       KASSERTMSG(arg->srcfmt->channels <= AUDIO_MAX_CHANNELS,
+           "arg->srcfmt->channels=%d", arg->srcfmt->channels);
 
        s = arg->src;
        d = arg->dst;
@@ -3369,8 +3375,12 @@
        DIAGNOSTIC_ring(dst);
        DIAGNOSTIC_ring(src);
        KASSERT(src->used > 0);
-       KASSERT(src->fmt.channels == dst->fmt.channels);
-       KASSERT(src->head % track->mixer->frames_per_block == 0);
+       KASSERTMSG(src->fmt.channels == dst->fmt.channels,
+           "src->fmt.channels=%d dst->fmt.channels=%d",
+           src->fmt.channels, dst->fmt.channels);
+       KASSERTMSG(src->head % track->mixer->frames_per_block == 0,
+           "src->head=%d track->mixer->frames_per_block=%d",
+           src->head, track->mixer->frames_per_block);
 
        s = arg->src;
        d = arg->dst;
@@ -3495,9 +3505,11 @@
        DIAGNOSTIC_ring(dst);
        DIAGNOSTIC_ring(src);
        KASSERT(src->used > 0);
-       KASSERT(src->fmt.channels == dst->fmt.channels);
+       KASSERTMSG(src->fmt.channels == dst->fmt.channels,
+           "src->fmt.channels=%d dst->fmt.channels=%d",
+           src->fmt.channels, dst->fmt.channels);
        KASSERTMSG(src->head % track->mixer->frames_per_block == 0,
-           "src->head=%d fpb=%d",
+           "src->head=%d track->mixer->frames_per_block=%d",
            src->head, track->mixer->frames_per_block);
 
        s0 = arg->src;
@@ -4188,7 +4200,9 @@
 
        n = (ring->capacity - ring->used) % fpb;
 
-       KASSERT(auring_get_contig_free(ring) >= n);
+       KASSERTMSG(auring_get_contig_free(ring) >= n,
+           "auring_get_contig_free(ring)=%d n=%d",
+           auring_get_contig_free(ring), n);
 
        memset(auring_tailptr_aint(ring), 0,
            n * ring->fmt.channels * sizeof(aint_t));
@@ -4221,7 +4235,7 @@
        dstcount = auring_get_contig_free(stage->dst);
 
        if (isfreq) {
-               KASSERTMSG(srccount > 0, "freq but srccount == %d", srccount);
+               KASSERTMSG(srccount > 0, "freq but srccount=%d", srccount);
                count = uimin(dstcount, track->mixer->frames_per_block);
        } else {
                count = uimin(srccount, dstcount);
@@ -4306,7 +4320,8 @@
                int bytes2;
 
                bytes1 = auring_get_contig_used(usrbuf);
-               KASSERT(bytes1 % framesize == 0);
+               KASSERTMSG(bytes1 % framesize == 0,
+                   "bytes1=%d framesize=%d", bytes1, framesize);
                memcpy((uint8_t *)input->mem + auring_tail(input) * framesize,
                    (uint8_t *)usrbuf->mem + usrbuf->head,
                    bytes1);
@@ -4469,7 +4484,8 @@
                int bytes2;
 
                bytes1 = auring_get_contig_free(usrbuf);
-               KASSERT(bytes1 % framesize == 0);
+               KASSERTMSG(bytes1 % framesize == 0,
+                   "bytes1=%d framesize=%d", bytes1, framesize);
                memcpy((uint8_t *)usrbuf->mem + auring_tail(usrbuf),
                    (uint8_t *)outbuf->mem + outbuf->head * framesize,
                    bytes1);
@@ -4865,7 +4881,9 @@
        mixer = sc->sc_pmixer;
 
        frame_count = mixer->frames_per_block;
-       KASSERT(auring_get_contig_free(&mixer->hwbuf) >= frame_count);
+       KASSERTMSG(auring_get_contig_free(&mixer->hwbuf) >= frame_count,
+           "auring_get_contig_free()=%d frame_count=%d",
+           auring_get_contig_free(&mixer->hwbuf), frame_count);
        sample_count = frame_count * mixer->mixfmt.channels;
 
        mixer->mixseq++;
@@ -5156,7 +5174,9 @@
        TRACE(4, "pbusy=%d hwbuf=%d/%d/%d",
            sc->sc_pbusy,
            mixer->hwbuf.head, mixer->hwbuf.used, mixer->hwbuf.capacity);
-       KASSERT(mixer->hwbuf.used >= mixer->frames_per_block);
+       KASSERTMSG(mixer->hwbuf.used >= mixer->frames_per_block,
+           "mixer->hwbuf.used=%d mixer->frames_per_block=%d",
+           mixer->hwbuf.used, mixer->frames_per_block);
 
        blksize = frametobyte(&mixer->hwbuf.fmt, mixer->frames_per_block);
 
@@ -5399,7 +5419,9 @@
                            input->head, input->used, input->capacity);
                        auring_take(input, drops);
                }
-               KASSERT(input->used % mixer->frames_per_block == 0);
+               KASSERTMSG(input->used % mixer->frames_per_block == 0,
+                   "input->used=%d mixer->frames_per_block=%d",
+                   input->used, mixer->frames_per_block);
 
                memcpy(auring_tailptr_aint(input),
                    auring_headptr_aint(mixersrc),
@@ -6038,8 +6060,7 @@



Home | Main Index | Thread Index | Old Index