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/63f8d238af46
branches:  netbsd-9
changeset: 1001805:63f8d238af46
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Jun 07 19:04:00 2020 +0000

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

        sys/dev/audio/audio.c: revision 1.71
        sys/dev/audio/audio.c: revision 1.73
        sys/dev/audio/audio.c: revision 1.74
        sys/dev/audio/audio.c: revision 1.75
        sys/dev/audio/audiovar.h: revision 1.12

audio: Fix logic for resuming when the device is in use.

audio_[r/p]mixer_start should never be called when the device is
marked busy.

Resolves a panic on resume when audio is playing, PR kern/55301

audio: remove comment that is no longer valid

audio: Only restart recording mixer on resume if it's already been started

Fix suspend/resume.
- Revert temporary usage of sc_[pr]busy during suspend.  These indicate
  whether the mixer needs to be restarted or not.
- Avoid timeout error when about to suspend.

diffstat:

 sys/dev/audio/audio.c    |  32 +++++++++++++++++++++++++++-----
 sys/dev/audio/audiovar.h |   8 +++++++-
 2 files changed, 34 insertions(+), 6 deletions(-)

diffs (104 lines):

diff -r d00f7eb660f1 -r 63f8d238af46 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Sun Jun 07 17:07:07 2020 +0000
+++ b/sys/dev/audio/audio.c     Sun Jun 07 19:04:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio.c,v 1.28.2.15 2020/05/18 18:12:24 martin Exp $   */
+/*     $NetBSD: audio.c,v 1.28.2.16 2020/06/07 19:04:00 martin Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.15 2020/05/18 18:12:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.16 2020/06/07 19:04:00 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -1561,6 +1561,13 @@
        /* Wait for pending I/O to complete. */
        error = cv_timedwait_sig(&track->mixer->outcv, sc->sc_lock,
            mstohz(AUDIO_TIMEOUT));
+       if (sc->sc_suspending) {
+               /* If it's about to suspend, ignore timeout error. */
+               if (error == EWOULDBLOCK) {
+                       TRACET(2, track, "timeout (suspending)");
+                       return 0;
+               }
+       }
        if (sc->sc_dying) {
                error = EIO;
        }
@@ -7748,15 +7755,17 @@
        error = audio_exlock_mutex_enter(sc);
        if (error)
                return error;
+       sc->sc_suspending = true;
        audio_mixer_capture(sc);
 
-       /* Halts mixers but don't clear busy flag for resume */
        if (sc->sc_pbusy) {
                audio_pmixer_halt(sc);
+               /* Reuse this as need-to-restart flag while suspending */
                sc->sc_pbusy = true;
        }
        if (sc->sc_rbusy) {
                audio_rmixer_halt(sc);
+               /* Reuse this as need-to-restart flag while suspending */
                sc->sc_rbusy = true;
        }
 
@@ -7779,15 +7788,28 @@
        if (error)
                return error;
 
+       sc->sc_suspending = false;
        audio_mixer_restore(sc);
        /* XXX ? */
        AUDIO_INITINFO(&ai);
        audio_hw_setinfo(sc, &ai, NULL);
 
-       if (sc->sc_pbusy)
+       /*
+        * During from suspend to resume here, sc_[pr]busy is used as
+        * need-to-restart flag temporarily.  After this point,
+        * sc_[pr]busy is returned to its original usage (busy flag).
+        * And note that sc_[pr]busy must be false to call [pr]mixer_start().
+        */
+       if (sc->sc_pbusy) {
+               /* pmixer_start() requires pbusy is false */
+               sc->sc_pbusy = false;
                audio_pmixer_start(sc, true);
-       if (sc->sc_rbusy)
+       }
+       if (sc->sc_rbusy) {
+               /* rmixer_start() requires rbusy is false */
+               sc->sc_rbusy = false;
                audio_rmixer_start(sc);
+       }
 
        audio_exlock_mutex_exit(sc);
 
diff -r d00f7eb660f1 -r 63f8d238af46 sys/dev/audio/audiovar.h
--- a/sys/dev/audio/audiovar.h  Sun Jun 07 17:07:07 2020 +0000
+++ b/sys/dev/audio/audiovar.h  Sun Jun 07 19:04:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audiovar.h,v 1.4.2.3 2020/04/30 16:05:18 martin Exp $  */
+/*     $NetBSD: audiovar.h,v 1.4.2.4 2020/06/07 19:04:00 martin Exp $  */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -243,6 +243,12 @@
        bool            sc_dying;
 
        /*
+        * Indicates that about to suspend.
+        * Must be protected by sc_lock.
+        */
+       bool            sc_suspending;
+
+       /*
         * If multiuser is false, other users who have different euid
         * than the first user cannot open this device.
         * Must be protected by sc_exlock.



Home | Main Index | Thread Index | Old Index