From oberman@es.net  Fri Aug  8 11:02:50 2003
Return-Path: <oberman@es.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 81B8C37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  8 Aug 2003 11:02:50 -0700 (PDT)
Received: from puppeteer.es.net (puppeteer.es.net [198.128.4.54])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0143943F85
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  8 Aug 2003 11:02:49 -0700 (PDT)
	(envelope-from oberman@es.net)
Received: by puppeteer.es.net (Postfix, from userid 1001)
	id 1F5EB30DEA; Fri,  8 Aug 2003 11:02:48 -0700 (PDT)
Message-Id: <20030808180248.1F5EB30DEA@puppeteer.es.net>
Date: Fri,  8 Aug 2003 11:02:48 -0700 (PDT)
From: Kevin Oberman <oberman@es.net>
Reply-To: Kevin Oberman <oberman@es.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ICH sampling rate changes after resume from suspend
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         55395
>Category:       kern
>Synopsis:       ICH sampling rate changes after resume from suspend
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    matk
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 08 11:10:14 PDT 2003
>Closed-Date:    Wed Apr 05 19:44:40 GMT 2006
>Last-Modified:  Wed Apr 05 19:44:40 GMT 2006
>Originator:     Kevin Oberman
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
ESnet-The Energy Sciences Network
>Environment:
System: FreeBSD puppeteer.es.net 5.1-CURRENT FreeBSD 5.1-CURRENT #19: Fri Aug 8 07:37:52 PDT 2003 oberman@puppeteer.es.net:/usr/obj/usr/src/sys/IBM-T30-D i386

>Description:
	If I suspend and resume (apm) my IBM T30, the sampling rate on
	the ICH3 is too high. I have not done careful timing, but I
	seem to gain about 5 seconds/minute. It is enough to make the
	audio very unpleasant when playing MP3s.

>How-To-Repeat:
	Suspend and resume. Play audio
>Fix:
	Only known work-around is a reboot. I suspect that reloading
	the driver would do it, but I have pcm in my kernel at this
	time. Will try a kernel without PCI when I get some time.

	I will admit that I can see nothing in the driver's resume
	code that seems likely to cause this, but I'm none too
	familiar with the code and probably missed something.

>Release-Note:
>Audit-Trail:

From: "Kevin Oberman" <oberman@es.net>
To: freebsd-gnats-submit@freebsd.org
Cc: orion@freebsd.org
Subject: Re:kern/55395:ICH sampling rate changes after resume from suspend
Date: Mon, 01 Sep 2003 19:45:36 -0700

 A bit more information:
 
 Modifying hw.snd.ac97rate makes not difference at all. I measured the
 speed-up as about 10% or the equivalent of 52.3 KHz.
 -- 
 R. Kevin Oberman, Network Engineer
 Energy Sciences Network (ESnet)
 Ernest O. Lawrence Berkeley National Laboratory (Berkeley Lab)
 E-mail: oberman@es.net			Phone: +1 510 486-8634

From: Orion Hodson <orion@freebsd.org>
To: "Kevin Oberman" <oberman@es.net>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/55395:ICH sampling rate changes after resume from suspend 
Date: Mon, 01 Sep 2003 21:58:06 -0700

 This is a multipart MIME message.
 
 --==_Exmh_-18846300150
 Content-Type: text/plain; charset=us-ascii
 
 /-- "Kevin Oberman" wrote:
 | A bit more information:
 | 
 | Modifying hw.snd.ac97rate makes not difference at all. I measured the
 | speed-up as about 10% or the equivalent of 52.3 KHz.
 
 Ah, okay, it's coming back up and using the wrong clock source.  We've had a 
 general issue with this on the ICH.  This is probably a function of how the 
 existing ich code effects resets, though don't have an ich box that manifests 
 the problem to verify this first hand.  Can you try the attached patch and see 
 if it improves the situation?
 
 Thanks
 - Orion
 
 --==_Exmh_-18846300150
 Content-Type: application/x-patch ; name="ich.reset.patch"
 Content-Description: ich.reset.patch
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="ich.reset.patch"
 
 Index: sys/dev/sound/pci/ich.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /home/ncvs/src/sys/dev/sound/pci/ich.c,v
 retrieving revision 1.3.2.13
 diff -u -u -r1.3.2.13 ich.c
 --- sys/dev/sound/pci/ich.c	18 Aug 2003 15:41:01 -0000	1.3.2.13
 +++ sys/dev/sound/pci/ich.c	2 Sep 2003 04:49:20 -0000
 @@ -32,7 +32,7 @@
  #include <pci/pcireg.h>
  #include <pci/pcivar.h>
  =
 
 -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/ich.c,v 1.3.2.13 2003/=
 08/18 15:41:01 orion Exp $");
 +SND_DECLARE_FILE("$FreeBSD$");
  =
 
  /* -------------------------------------------------------------------- =
 */
  =
 
 @@ -565,13 +565,22 @@
  static int
  ich_init(struct sc_info *sc)
  {
 -	u_int32_t stat;
 +	u_int32_t cnt, stat;
  	int sz;
  =
 
 -	ich_wr(sc, ICH_REG_GLOB_CNT, ICH_GLOB_CTL_COLD, 4);
 +	/* Effect a cold reset (XXX todo warm reset) */
 +	/* assert COLD_RESET# lo */
 +	cnt =3D ich_rd(sc, ICH_REG_GLOB_CNT, 4);
 +	cnt &=3D ~ICH_GLOB_CTL_COLD;
 +	ich_wr(sc, ICH_REG_GLOB_CNT, cnt, 4);
  	DELAY(600000);
 -	stat =3D ich_rd(sc, ICH_REG_GLOB_STA, 4);
  =
 
 +	/* assert COLD_RESET# hi */
 +	cnt =3D ich_rd(sc, ICH_REG_GLOB_CNT, 4);
 +	cnt |=3D ICH_GLOB_CTL_COLD;
 +	ich_wr(sc, ICH_REG_GLOB_CNT, ICH_GLOB_CTL_COLD, 4);
 +
 +	stat =3D ich_rd(sc, ICH_REG_GLOB_STA, 4);
  	if ((stat & ICH_GLOB_STA_PCR) =3D=3D 0) {
  		/* ICH4/ICH5 may fail when busmastering is enabled. Continue */
  		if ((pci_get_devid(sc->dev) !=3D ICH4ID) &&
 
 --==_Exmh_-18846300150--
 
 

From: "Kevin Oberman" <oberman@es.net>
To: Orion Hodson <orion@freebsd.org>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/55395:ICH sampling rate changes after resume from suspend 
Date: Tue, 02 Sep 2003 15:33:01 -0700

 > From: Orion Hodson <orion@freebsd.org>
 > Date: Mon, 01 Sep 2003 21:58:06 -0700
 > Sender: hodson@icir.org
 > 
 > This is a multipart MIME message.
 > 
 > --==_Exmh_-18846300150
 > Content-Type: text/plain; charset=us-ascii
 > 
 > /-- "Kevin Oberman" wrote:
 > | A bit more information:
 > | 
 > | Modifying hw.snd.ac97rate makes not difference at all. I measured the
 > | speed-up as about 10% or the equivalent of 52.3 KHz.
 > 
 > Ah, okay, it's coming back up and using the wrong clock source.  We've had a 
 > general issue with this on the ICH.  This is probably a function of how the 
 > existing ich code effects resets, though don't have an ich box that manifests 
 > the problem to verify this first hand.  Can you try the attached patch and see 
 > if it improves the situation?
 
 Thanks for the patch, but it results in a kernel that fails during the
 device probe. It fires off multiple panics and I can't seem to get
 anything useful to work at the db> prompt, just another panic.
 
 Let me know if you would like the detials of the panic and I'll
 transcribe them for you.
 
 The patch was to a freshly cvsuped sources as of about 14:30 PDT (-7)
 today. I'm still running installworld after backing out the
 patch. I'll build another kernel with the patch for debugging once I
 feel that the CURRENT is otherwise "stable".
 
 Thanks again!
 -- 
 R. Kevin Oberman, Network Engineer
 Energy Sciences Network (ESnet)
 Ernest O. Lawrence Berkeley National Laboratory (Berkeley Lab)
 E-mail: oberman@es.net			Phone: +1 510 486-8634

From: Orion Hodson <orion@freebsd.org>
To: "Kevin Oberman" <oberman@es.net>
Cc: Orion Hodson <orion@freebsd.org>,
	freebsd-gnats-submit@freebsd.org
Subject: Re: kern/55395:ICH sampling rate changes after resume from suspend 
Date: Tue, 02 Sep 2003 16:38:54 -0700

 /-- "Kevin Oberman" wrote:
 | 
 | Thanks for the patch, but it results in a kernel that fails during the
 | device probe. It fires off multiple panics and I can't seem to get
 | anything useful to work at the db> prompt, just another panic.
 
 Ouch, that turned out much worse than expected :-(  I'm going to hold off thinking about this for a week as I'm about to move my development set up to the office and can appropriate machines (including ich) for bouts of testing there.
 
 Kind Regards
 - Orion
 
Responsible-Changed-From-To: freebsd-bugs->njl 
Responsible-Changed-By: njl 
Responsible-Changed-When: Wed Oct 29 12:50:06 PST 2003 
Responsible-Changed-Why:  
I'm handling this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55395 
Responsible-Changed-From-To: njl->mat 
Responsible-Changed-By: njl 
Responsible-Changed-When: Mon Jan 12 10:14:33 PST 2004 
Responsible-Changed-Why:  
I'm sending this over to mat@, who is our new sound guru.  :)  Perhaps he 
can do something with it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55395 
Responsible-Changed-From-To: mat->matk 
Responsible-Changed-By: njl 
Responsible-Changed-When: Wed Jan 14 10:59:37 PST 2004 
Responsible-Changed-Why:  
Pass this to the right person. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55395 

Adding to audit trail:

a better fix may be in kern/81013.
State-Changed-From-To: open->feedback 
State-Changed-By: linimon 
State-Changed-When: Wed Apr 5 04:32:34 UTC 2006 
State-Changed-Why:  
Is this still a problem with recent versions of FreeBSD? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55395 
State-Changed-From-To: feedback->closed 
State-Changed-By: linimon 
State-Changed-When: Wed Apr 5 19:44:20 UTC 2006 
State-Changed-Why:  
Submitter notes that this was fixed by a jhb commit some time ago. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=55395 
>Unformatted:
