NetBSD Problem Report #55301
From www@netbsd.org Tue May 26 07:32:39 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id DBC961A9227
for <gnats-bugs@gnats.NetBSD.org>; Tue, 26 May 2020 07:32:39 +0000 (UTC)
Message-Id: <20200526073238.DB1DF1A9247@mollari.NetBSD.org>
Date: Tue, 26 May 2020 07:32:38 +0000 (UTC)
From: nia@pkgsrc.org
Reply-To: nia@pkgsrc.org
To: gnats-bugs@NetBSD.org
Subject: rare audio panic on resume, assertion "sc->sc_pbusy == false" failed
X-Send-Pr-Version: www-1.0
>Number: 55301
>Category: kern
>Synopsis: rare audio panic on resume, assertion "sc->sc_pbusy == false" failed
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: kern-bug-people
>State: analyzed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue May 26 07:35:00 +0000 2020
>Closed-Date:
>Last-Modified: Sun Jun 07 19:05:01 +0000 2020
>Originator: nia
>Release: -current
>Organization:
>Environment:
NetBSD r 9.99.63 NetBSD 9.99.63 (R) #6: Fri May 22 23:06:42 IST 2020 nia@r:/home/nia/src/sys/arch/amd64/compile/obj/R amd64
>Description:
panic: kernel diagnostic assertion "sc->sc_pbusy == false" failed: file "/home/nia/src/sys/dev/audio/audio.c", line 5074
cpu0: Begin traceback...
vpanic() at netbsd:vpanic+0x152
__x86_indirect_thunk_rax() at netbsd:__x86_indirect_thunk_rax
audio_pmixer_start() at netbsd:audio_pmixer_start+0x14e
audio_resume() at netbsd:audio_resume+0x138
device_pmf_driver_resume() at netbsd:device_pmf_driver_resume+0x49
pmf_device_resume_locked() at netbsd:pmf_device_resume_locked+0xd3
pmf_device_resume() at netbsd:pmf_device_resume+0x45
pmf_system_resume() at netbsd:pmf_system_resume+0xb8
acpi_enter_sleep_state() at netbsd:acpi_enter_sleep_state+0x187
sysctl_hw_acpi_sleepstate() at netbsd:sysctl_hw_acpi_sleepstate+0xdf
sysctl_dispatch() at netbsd:sysctl_dispatch+0xa5
sys___sysctl() at netbsd:sys___sysctl+0xc5
syscall() at netbsd:syscall+0x26f
--- syscall (number 202) ---
netbsd:syscall+0x26f:
cpu0: End traceback...
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip 0xffffffff8021f3d5 cs 0x8 rflags 0x202 cr2 0x7ddd6774a000 ilevel 0 rsp 0xffffd200c7c5a890
curlwp 0xfffff504491ba340 pid 14216.14216 lowest kstack 0xffffd200c7c572c0
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: nia <nia@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: nia@pkgsrc.org
Subject: Re: kern/55301: rare audio panic on resume, assertion "sc->sc_pbusy
== false" failed
Date: Tue, 26 May 2020 09:52:31 +0000
The logic in audio_resume is busted.
It's calling audio_pmixer_start when sc->sc_pbusy which is totally
wrong.
This inverts the logic, which fixes the panic. Programs using
audio still hang on resume, but it's an improvement.
Index: sys/dev/audio/audio.c
===================================================================
RCS file: /cvsroot/src/sys/dev/audio/audio.c,v
retrieving revision 1.69
diff -u -r1.69 audio.c
--- sys/dev/audio/audio.c 1 May 2020 08:21:27 -0000 1.69
+++ sys/dev/audio/audio.c 26 May 2020 09:50:39 -0000
@@ -7755,11 +7755,9 @@
/* Halts mixers but don't clear busy flag for resume */
if (sc->sc_pbusy) {
audio_pmixer_halt(sc);
- sc->sc_pbusy = true;
}
if (sc->sc_rbusy) {
audio_rmixer_halt(sc);
- sc->sc_rbusy = true;
}
#ifdef AUDIO_PM_IDLE
@@ -7786,9 +7784,9 @@
AUDIO_INITINFO(&ai);
audio_hw_setinfo(sc, &ai, NULL);
- if (sc->sc_pbusy)
+ if (!sc->sc_pbusy)
audio_pmixer_start(sc, true);
- if (sc->sc_rbusy)
+ if (!sc->sc_rbusy)
audio_rmixer_start(sc);
audio_exlock_mutex_exit(sc);
State-Changed-From-To: open->analyzed
State-Changed-By: nia@NetBSD.org
State-Changed-When: Tue, 26 May 2020 09:58:04 +0000
State-Changed-Why:
This is actually not rare and happens whenever the audio device is in active use.
I normally stop audio from playing before suspending, so I didn't notice it until now.
Anyway, the previously posted patch is a cursory fix.
From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55301 CVS commit: src/sys/dev/audio
Date: Tue, 26 May 2020 10:07:29 +0000
Module Name: src
Committed By: nia
Date: Tue May 26 10:07:29 UTC 2020
Modified Files:
src/sys/dev/audio: audio.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/audio/audio.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55301 CVS commit: [netbsd-9] src/sys/dev/audio
Date: Sun, 7 Jun 2020 19:04:00 +0000
Module Name: src
Committed By: martin
Date: Sun Jun 7 19:04:00 UTC 2020
Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c audiovar.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.28.2.15 -r1.28.2.16 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.4.2.3 -r1.4.2.4 src/sys/dev/audio/audiovar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.