NetBSD Problem Report #26457

Received: (qmail 636 invoked by uid 605); 28 Jul 2004 04:13:07 -0000
Message-Id: <20040728014900.99A9D11153@narn.netbsd.org>
Date: Wed, 28 Jul 2004 01:49:00 +0000 (UTC)
From: Joachim.Thiemann@Mail.McGill.CA
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: Joachim.Thiemann@Mail.McGill.CA
To: gnats-bugs@gnats.NetBSD.org
Subject: ac97 is not ready after suspend/resume (fix included, should be considered for 2.0)
X-Send-Pr-Version: www-1.0

>Number:         26457
>Category:       kern
>Synopsis:       ac97 is not ready after suspend/resume (fix included, should be considered for 2.0)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kent
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 28 04:14:00 +0000 2004
>Closed-Date:    Fri Jan 21 15:24:03 +0000 2005
>Last-Modified:  Fri Jan 21 15:24:03 +0000 2005
>Originator:     Joachim Thiemann
>Release:        2.0_BETA
>Organization:
>Environment:
NetBSD codaget3002 2.0_BETA NetBSD 2.0_BETA (IBMT30) #28: Thu Jul 15 21:57:25 EDT 2004  thiemann@codaget3002:/home/thiemann/NetBSD/sys/arch/i386/compile/IBMT30 i386

from dmesg:
auich0 at pci0 dev 31 function 5: i82801CA (ICH3) AC-97 Audio
auich0: interrupting at irq 5
auich0: ac97: Analog Devices AD1881A codec; headphone, Analog Devices Phat Stereo
auich0: ac97: ext id 1<VRA>
auich0: measured ac97 link rate at 47277 Hz, will use 48000 Hz

>Description:
After a suspend/resume cycle of a laptop, the ac97 takes some time
to power up fully.  If registers are modified before that, it
the changes are ignored.  In particular, the ac97_restore_shadow
function is ignored, and the pre-suspend mixer values are lost.
Also, the chip may get stuck in the 48000 sample rate.
>How-To-Repeat:
Have a sound file sampled at low rate (eg. 8000 or 16000 Hz)

audioplay soundfile.wav
(suspend)
(resume)
audioplay soundfile.wav
mixerctl -w outputs.master.mute=off
mixerctl -w inputs.dac.mute=off
audioplay soundfile.wav
>Fix:
I have patched ac97.c to 1) wait until the power register claims that all subsystems are powered up, and 2) try modifying the master volume, until the write actually suceeds.

RCS file: /cvsroot/src/sys/dev/ic/ac97.c,v
retrieving revision 1.52
diff -c -r1.52 ac97.c
*** ac97.c      24 Nov 2003 16:05:10 -0000      1.52
--- ac97.c      28 Jul 2004 04:00:46 -0000
***************
*** 702,712 ****
        struct ac97_softc *as;
        const struct ac97_source_info *si;
        int idx;

        as = (struct ac97_softc *) self;
        for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) {
                si = &source_info[idx];
!               ac97_write(as, si->reg, as->shadow_reg[si->reg >> 1]);
        }

        if (as->ext_id & (AC97_EXT_AUDIO_VRA | AC97_EXT_AUDIO_DRA
--- 702,740 ----
        struct ac97_softc *as;
        const struct ac97_source_info *si;
        int idx;
+       u_int16_t val;

        as = (struct ac97_softc *) self;
+
+       /* make sure chip is fully operational */
+       for (idx = 500000; idx >= 0; idx--) {
+               ac97_read(as, AC97_REG_POWER, &val);
+               if ((val & AC97_POWER_REF) &&
+                   (val & AC97_POWER_ANL) &&
+                   (val & AC97_POWER_DAC) &&
+                   (val & AC97_POWER_ADC)) break;
+               DELAY(1);
+       }
+
+       if (idx <= 0)
+               printf( "ac97 timeout on restore\n" );
+
+       /* actually try changing a value! */
+       for (idx = 500000; idx >= 0; idx--) {
+               as->host_if->write(as->host_if->arg, AC97_REG_MASTER_VOLUME, 0x1010);
+               ac97_read(as, AC97_REG_MASTER_VOLUME, &val);
+               if (val == 0x1010) break;
+               DELAY(1);
+       }
+
+       if (idx <= 0)
+               printf( "ac97 timeout on ch reg\n" );
+
        for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) {
                si = &source_info[idx];
!               /* don't "restore" to the reset reg! */
!               if (si->reg)
!                       ac97_write(as, si->reg, as->shadow_reg[si->reg >> 1]);
        }

        if (as->ext_id & (AC97_EXT_AUDIO_VRA | AC97_EXT_AUDIO_DRA

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->kent 
Responsible-Changed-By: kent 
Responsible-Changed-When: Wed Aug 11 14:09:00 UTC 2004 
Responsible-Changed-Why:  

From: TAMURA Kent <kent@NetBSD.org>
To: Joachim.Thiemann@Mail.McGill.CA, gnats-bugs@gnats.NetBSD.org
Cc: TAMURA Kent <kent@NetBSD.org>
Subject: Re: kern/26457: ac97 is not ready after suspend/resume (fix included, should be considered for 2.0)
Date: Wed, 11 Aug 2004 23:18:15 +0900 (JST)

 Would you do the following?

  1. remove "#ifdef DEBUG" and "#endif" in auich_reset_codec() of
    sys/dev/pci/auich.c, rebuild the kernel, install it, and
    reboot
  2. suspend and resume the machine
  3. check what the new kernel prints just after resuming

 -- 
 TAMURA Kent <kent2004? at hauN.org> <kent at NetBSD.org>

From: TAMURA Kent <kent@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/26457 CVS commit: src/sys/dev/ic
Date: Fri, 20 Aug 2004 14:36:13 +0000 (UTC)

 Module Name:	src
 Committed By:	kent
 Date:		Fri Aug 20 14:36:13 UTC 2004

 Modified Files:
 	src/sys/dev/ic: ac97.c

 Log Message:
 Check power states after codec reset.  This change fixes a
 resume problem on some boards.
 Patch provided by Joachim Thiemann in PR kern/26457


 To generate a diff of this commit:
 cvs rdiff -r1.58 -r1.59 src/sys/dev/ic/ac97.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback 
State-Changed-By: kent 
State-Changed-When: Fri Aug 20 14:51:14 UTC 2004 
State-Changed-Why:  
Please try ac97.c rev1.59 

From: Joachim Thiemann <Joachim.Thiemann@Mail.McGill.CA>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: Re: kern/26457
Date: Mon, 23 Aug 2004 14:19:14 -0400

 On Friday 20 August 2004 10:51, kent@netbsd.org wrote:
 > Synopsis: ac97 is not ready after suspend/resume (fix included, should be
 > considered for 2.0)
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: kent
 > State-Changed-When: Fri Aug 20 14:51:14 UTC 2004
 > State-Changed-Why:
 > Please try ac97.c rev1.59

 Unfortunately, I no longer have the machine (IBM Thinkpad T30) that showed 
 this problem.  Please contact Peter Seebach (seebs@plethora.net) who had 
 the same problem on similar hardware.

 Joe.

 -- 
 ------------------------------------------------------------------------
 Joachim Thiemann                         Joachim.Thiemann@Mail.McGill.CA
 http://www.gel.usherbrooke.ca/thiemann

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/26457 CVS commit: [netbsd-2-0] src/sys/dev/ic
Date: Fri, 10 Sep 2004 06:52:02 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Fri Sep 10 06:52:02 UTC 2004

 Modified Files:
 	src/sys/dev/ic [netbsd-2-0]: ac97.c

 Log Message:
 Pull up revision 1.59 (requested by kent in ticket #823):
 Check power states after codec reset.  This change fixes a
 resume problem on some boards.
 Patch provided by Joachim Thiemann in PR kern/26457


 To generate a diff of this commit:
 cvs rdiff -r1.52.2.1 -r1.52.2.2 src/sys/dev/ic/ac97.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: TAMURA Kent <kent@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/26457 CVS commit: src/sys/dev/ic
Date: Sun, 17 Oct 2004 08:20:15 +0000 (UTC)

 Module Name:	src
 Committed By:	kent
 Date:		Sun Oct 17 08:20:15 UTC 2004

 Modified Files:
 	src/sys/dev/ic: ac97.c

 Log Message:
 make sure of readiness of an AC'97 codec by writing a value and
 reading it.  There is a codec which is not operational just
 after power states become ready.

 PR#26457


 To generate a diff of this commit:
 cvs rdiff -r1.63 -r1.64 src/sys/dev/ic/ac97.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: kent@netbsd.org
State-Changed-When: Fri, 21 Jan 2005 15:24:03 +0000
State-Changed-Why:
feedback timeout


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.