From joe@pavilion.net  Thu Aug  3 01:50:02 2000
Return-Path: <joe@pavilion.net>
Received: from genius.systems.pavilion.net (genius.systems.pavilion.net [212.74.1.100])
	by hub.freebsd.org (Postfix) with ESMTP id AC4B437B596
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  3 Aug 2000 01:49:59 -0700 (PDT)
	(envelope-from joe@pavilion.net)
Received: by genius.systems.pavilion.net (Postfix, from userid 100)
	id 3BBA89B28; Thu,  3 Aug 2000 01:44:39 +0100 (BST)
Message-Id: <20000803004439.3BBA89B28@genius.systems.pavilion.net>
Date: Thu,  3 Aug 2000 01:44:39 +0100 (BST)
From: joe@tao.org.uk
Reply-To: joe@tao.org.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: APM doesn't work properly!  Suspend/resume/suspend/hang
X-Send-Pr-Version: 3.2

>Number:         20375
>Category:       kern
>Synopsis:       APM doesn't work properly!  Suspend/resume/suspend/hang
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 03 02:00:01 PDT 2000
>Closed-Date:    Sun May 12 14:56:47 PDT 2002
>Last-Modified:  Sun May 12 14:56:47 PDT 2002
>Originator:     Joe Karthauser
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
FreeBSD.Org
>Environment:

Sony Vaio F290 laptop.

% uname -a
FreeBSD genius.systems.pavilion.net 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Thu Aug  3 01:24:23 BST 2000     root@genius.systems.pavilion.net:/usr/src/sys/compile/CUTDOWN  i386

% dmesg 
Copyright (c) 1992-2000 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD 5.0-CURRENT #0: Thu Aug  3 01:24:23 BST 2000
    root@genius.systems.pavilion.net:/usr/src/sys/compile/CUTDOWN
Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (397.90-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x66d  Stepping = 13
  Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR>
real memory  = 201261056 (196544K bytes)
avail memory = 192909312 (188388K bytes)
Preloaded elf kernel "kernel" at 0xc0267000.
Pentium Pro MTRR support enabled
npx0: <math processor> on motherboard
npx0: INT 16 interface
apm0: <APM BIOS> on motherboard
apm: found APM BIOS v1.2, connected at v1.2
pcib0: <Intel 82443BX host to PCI bridge (AGP disabled)> on motherboard
pci0: <PCI bus> on pcib0
pci0: <Intel 82443BX host to PCI bridge (AGP disabled)> at 0.0
isab0: <Intel 82371AB PCI to ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel PIIX4 ATA33 controller> port 0xfcd0-0xfcdf at device 7.1 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
pci0: <Intel 82371AB/EB (PIIX4) USB controller> at 7.2 irq 9
pci0: <Intel 82371AB Power management controller> at 7.3
pci0: <NeoMagic MagicMedia 256AV SVGA controller> at 8.0 irq 9
pci0: <NeoMagic MagicMedia 256AX Audio controller> at 8.1 irq 9
pci0: <Sony CXD1947A FireWire Host Controller> at 9.0 irq 9
pci0: <PCI to CardBus bridge (vendor=1180 device=0478)> at 10.0
pci0: <PCI to CardBus bridge (vendor=1180 device=0478)> at 10.1
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sc0: <System console> on isa0
sc0: VGA <16 virtual consoles, flags=0x200>
fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model GlidePoint, device ID 0
unknown: <PNP0303> can't assign resources
unknown: <PNP0700> can't assign resources
unknown: <PNP0f13> can't assign resources
ata1-slave: ata_command: timeout waiting for intr
ata1-slave: identify failed
ad0: 19077MB <IBM-DJSA-220> [38760/16/63] at ata0-master using UDMA33
Mounting root from ufs:/dev/ad0s2a

% cat /sys/i386/conf/CUTDOWN

machine		i386
cpu		I586_CPU
cpu		I686_CPU
ident		CUTDOWN
maxusers	128

hints		"CUTDOWN.hints"		#Default places to look for devices.

makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
options		DDB

options 	INET			#InterNETworking
options 	FFS			#Berkeley Fast Filesystem
options 	FFS_ROOT		#FFS usable as root device [keep this!]
options 	PROCFS			#Process filesystem
options 	COMPAT_43		#Compatible with BSD 4.3 [KEEP THIS!]

device		isa
device		pci
options		COMPAT_OLDISA		# compatability shims for lnc, fe, le
options		COMPAT_OLDPCI		# compatability shims for lnc, vx

# Floppy drives
device		fdc

# ATA and ATAPI devices
device		ata
device		atadisk			# ATA disk drives

# atkbdc0 controls both the keyboard and the PS/2 mouse
device		atkbdc	1
device		atkbd
device		psm

device		vga

# splash screen/screen saver
device		splash

# syscons is the default console driver, resembling an SCO console
device		sc	1
options		SC_HISTORY_SIZE=2000	# number of history buffer lines        

# Floating point support - do not disable.
device		npx

# Power management support (see LINT for more options)
device		apm

# Pseudo devices - the number indicates how many units to allocated.
device		loop		# Network loopback
device		pty		# Pseudo-ttys (telnet etc)

>Description:

	Something has recently broken APM support for me.

	If I suspend, I can resume, but the machine freezes upon
	a further suspend.

	I've tried cutting the kernel config down to remove the
	possiblity that it's a pccard or pcm problem.

>How-To-Repeat:

	Compile the supplied kernel config on a laptop and
	try suspend/resume/suspend/resume and see whether you
	get a hang or not.

>Fix:

	Don't know - I'm going to go back in time and see if I can
	work out when it broke.  It's been broken for a couple of
	weeks I believe.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: sheldonh 
State-Changed-When: Thu Aug 3 02:52:25 PDT 2000 
State-Changed-Why:  
Recently broken looks like something you might be able to track 
down by rolling back apm.c revision by revision. :-) 

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

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Josef Karthauser <joe@pavilion.net>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang 
Date: Mon, 07 Aug 2000 15:52:59 +0200

 On Mon, 07 Aug 2000 14:37:39 +0100, Josef Karthauser wrote:
 
 > It would help if I could get some feedback as to whether this
 > is a local problem or is affecting others as well.
 
 That's really not what the GNATS database is for.  There are mailing
 lists for that purpose.  Perhaps you could close the PR and submit a new
 one once you're more certain that this is not a local problem?  That's
 what I'd do, at any rate.
 
 I'll leave the PR in feedback state until you close it, ask me to close
 it, or send more feedback. :-)
 
 Ciao,
 Sheldon.
 
State-Changed-From-To: feedback->open 
State-Changed-By: sheldonh 
State-Changed-When: Fri Aug 11 03:43:08 PDT 2000 
State-Changed-Why:  
We've got feedback.  Joe, you want to ask Soren to take 
a look, or are you now convinced that this isn't an ata-specific 
problem? 

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

From: Brian Somers <brian@Awfulhak.org>
To: Josef Karthauser <joe@pavilion.net>
Cc: Brian Somers <brian@Awfulhak.org>, freebsd-bugs@FreeBSD.ORG,
	sheldonh@FreeBSD.ORG, brian@Awfulhak.org
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang 
Date: Fri, 11 Aug 2000 11:51:58 +0100

 What happens if you change the tsleep to DELAY() ?  It should sort 
 out the panic, but do you still die in the second suspend ?
 
 The bit I'm *really* interested in is why this hasn't happened for 
 you 'till now ?  It's been happening to me since FreeBSDCon (well, 
 for the entire life of this laptop) !!!
 
 Index: ata-all.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/ata/ata-all.c,v
 retrieving revision 1.62
 diff -u -r1.62 ata-all.c
 --- ata-all.c	2000/08/08 14:57:36	1.62
 +++ ata-all.c	2000/08/11 10:49:54
 @@ -1281,10 +1281,7 @@
  	if (*mask == 0x03)      /* wait for both master & slave */
  	    if (!(status0 & ATA_S_BUSY) && !(status1 & ATA_S_BUSY))
  		break;
 -	if (ata_delayed_attach)
 -	    DELAY(100);
 -	else
 -	    tsleep(&ata_delayed_attach, PRIBIO, "atarst", 1);
 +	DELAY(100);
      }	
      DELAY(1);
      outb(scp->altioaddr, ATA_A_4BIT);
 
 
 > On Thu, Aug 10, 2000 at 12:22:15PM +0100, Josef Karthauser wrote:
 > > On Thu, Aug 10, 2000 at 12:12:17PM +0100, Brian Somers wrote:
 > > > 
 > > > With the dodgy call to tsleep (passing a NULL as the first arg) I was 
 > > > getting a panic in the KASSERT in tsleep(), but once that was fixed 
 > > > I'm back where I can suspend, resume then lock up when I try to suspend 
 > > > again.
 > > > 
 > > > It'd be worth looking at a crash trace if you can get one.
 > > 
 > > Mine was working once _until_ the tsleep fix!  I'll recompile the
 > > kernel again afresh and check again.  My guess is that this tsleep
 > > is independant to my original report.
 > 
 > To repeat - even though it looks like the KASSERT in tsleep fixed the
 > ata code for you, it's still broken for me on the head branch.  Upon
 > a resume the debugger kicks in at tsleep within atareset.
 >  
 > > My original problem is the same as what you report above.  I've
 > > tried with a cutdown kernel, to remove the possibility that it's
 > > pcm, etc, but it does appear to be more fundamental than that.  I
 > > don't get a crash, just a hang, so no coredump or back trace is
 > > available. :(
 > 
 > I've gone back to 1/Aug/2000 for the ata code to get around that local
 > problem which isn't necessarily the direct cause of the suspend/resume
 > hang that you mention, and which appears to be the same as the one that
 > I opened this PR under.
 > 
 > My suspicion is that something isn't resuming properly and when asked
 > to suspend a second time it's hanging the system.  I wish that I could
 > find our where the hang is occuring.
 > 
 > Joe
 > 
 
 -- 
 Brian <brian@Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
       <http://www.Awfulhak.org>                   <brian@[uk.]OpenBSD.org>
 Don't _EVER_ lose your sense of humour !
 
 
 
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Josef Karthauser <joe@pavilion.net>
Cc: freebsd-gnats-submit@FreeBSD.org, n_hibma@FreeBSD.org,
	dfr@FreeBSD.org
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang 
Date: Fri, 11 Aug 2000 14:21:11 +0200

 On Fri, 11 Aug 2000 12:29:37 +0100, Josef Karthauser wrote:
 
 > Yes I'm convinced.  The ATA problem was a red herring.  Suspend/Resume
 > has worked fine for me since the beginning of the year under 5.0.
 > Something has changed and now it's broken.
 
 Something changed and brok after February this year?  Perhaps we could
 ask Nick Hibma and Doug Rabson to take a look at this, given their
 involvement in rev 1.114 of apm.c?
 
 Ciao,
 Sheldon.
 

From: Josef Karthauser <joe@pavilion.net>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: freebsd-gnats-submit@FreeBSD.org, n_hibma@FreeBSD.org,
	dfr@FreeBSD.org
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang
Date: Fri, 11 Aug 2000 13:25:39 +0100

 On Fri, Aug 11, 2000 at 02:21:11PM +0200, Sheldon Hearn wrote:
 > 
 > 
 > On Fri, 11 Aug 2000 12:29:37 +0100, Josef Karthauser wrote:
 > 
 > > Yes I'm convinced.  The ATA problem was a red herring.  Suspend/Resume
 > > has worked fine for me since the beginning of the year under 5.0.
 > > Something has changed and now it's broken.
 > 
 > Something changed and brok after February this year?  Perhaps we could
 > ask Nick Hibma and Doug Rabson to take a look at this, given their
 > involvement in rev 1.114 of apm.c?
 
 That'd good.
 
 I believe that it broke sometime in the last couple of months.
 
 If I could get a trace that'd find the culprit, but unfortunately
 the machine hangs hard - power reset required.  Maybe some debug
 output to stderr would catch the problem.  Is there somewhere in
 the bus code that I can add some debug that'll show each device
 being suspended?
 
 Joe
 

From: Josef Karthauser <joe@pavilion.net>
To: freebsd-bugs@FreeBSD.ORG
Cc:  
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang
Date: Sat, 12 Aug 2000 17:47:28 +0100

 On Fri, Aug 11, 2000 at 05:30:09AM -0700, Josef Karthauser wrote:
 >  
 >  I believe that it broke sometime in the last couple of months.
 >  
 >  If I could get a trace that'd find the culprit, but unfortunately
 >  the machine hangs hard - power reset required.  Maybe some debug
 >  output to stderr would catch the problem.  Is there somewhere in
 >  the bus code that I can add some debug that'll show each device
 >  being suspended?
 >  
 
 Ok, more updates.
 
 There _is_ a sysctl (debug.apm_debug) recently added for debugging.
 
 Using the kernel debugger I've determined that the freeze is almost
 definitely in the bios32 call:
 
 	apm_do_suspend
 	    apm_suspend_system
 	        apm_bioscall
 		    bios32
 			HANG
 
 This happens on the second suspend only, the first time through it
 succeeds, and returns after a resume event (keypress, etc.).
 
 Who's our APM wizard?  I've no idea what the bios interaction should
 be.
 
 Joe
 
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
 
 

From: Josef Karthauser <joe@pavilion.net>
To: Nick Hibma <n_hibma@qubesoft.com>
Cc: freebsd-bugs@FreeBSD.ORG
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang
Date: Tue, 15 Aug 2000 11:06:31 +0100

 On Tue, Aug 15, 2000 at 10:04:23AM +0100, Nick Hibma wrote:
 > > Right, my problems were unrelated. After a pretty long goose chase, my
 > > laptop crashing was my own fault.
 > > 
 > > And after that I can get it to crash when suspending or resuming.
 > 
 > Argh. can -> can't as in cannot.
 
 So your suspend/resume/suspend/resume is hang free?
 
 My guess is that on Brian's and my Vaio something isn't being registered
 in the bios as being resumed properly and so when the second suspend
 is called it hangs.
 
 Joe
 
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
 
 
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Sat Aug 25 16:18:43 PDT 2001 
State-Changed-Why:  

Nothing has been added to the audit trail in over a year - does this 
problem still exist? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=20375 

From: Ian Dowse <iedowse@maths.tcd.ie>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/20375: APM doesn't work properly! Suspend/resume/suspend/hang
Date: Wed, 29 Aug 2001 00:30:07 +0100

 Adding to the audit trail:
 
 ------------------
 Date:    Tue, 28 Aug 2001 14:56:06 BST
 From:    Josef Karthauser <joe@tao.org.uk>
 
 Joe> I don't know whether the problem still exists as I don't have a Sony any
 Joe> more.  I would imagine that it does.  Brian Somers is the one to ask
 Joe> (brian@freebsd.org), as he's also got a Sony that had trouble.
 Joe> 
 Joe> Joe
 ------------------
 
 ------------------
 Date: Tue, 28 Aug 2001 15:50:45 +0100
 From: Brian Somers <brian@Awfulhak.org>
 
 Brian> Hi,
 Brian> 
 Brian> It's kind of difficult to tell if the problem is still there right 
 Brian> now.  When I suspend & resume, I seem to lose all interrupt routing 
 Brian> at the moment (the keyboard doesn't respond, but if I drop into ddb 
 Brian> and back out again, I get to see what I've typed).
 Brian> 
 Brian> The problem was certainly there about a month ago when I last tried 
 Brian> it though, so let's assume nothing's changed :*)
 ------------------
State-Changed-From-To: feedback->open 
State-Changed-By: iedowse 
State-Changed-When: Tue Aug 28 16:56:32 PDT 2001 
State-Changed-Why:  

This problem still exists. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=20375 

From: Hiten Pandya <hiten@uk.FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc: joe@FreeBSD.org
Subject: Re: kern/20375 (close request)
Date: Fri, 29 Mar 2002 02:09:10 +0000

 Does this problem still exist?  If not, we can clost this 
 PR I think.  Joe is a committer, so he can probably change the state to
 something like suspended.
 
 -- 
 Hiten Pandya
 http://jfs4bsd.sf.net - JFS for FreeBSD (JFS4BSD)
 http://www.FreeBSD.org - The Power to Serve
 
 Public Key: http://www.pittgoth.com/~hiten/pubkey.asc
 --- 4FB9 C4A9 4925 CF97 9BF3  ADDA 861D 5DBD E4E3 03C3 ---

From: Josef Karthauser <joe@tao.org.uk>
To: Hiten Pandya <hiten@uk.FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/20375 (close request)
Date: Fri, 29 Mar 2002 10:23:46 +0000

 --Q68bSM7Ycu6FN28Q
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Fri, Mar 29, 2002 at 02:09:10AM +0000, Hiten Pandya wrote:
 > Does this problem still exist?  If not, we can clost this=20
 > PR I think.  Joe is a committer, so he can probably change the state to
 > something like suspended.
 
 I've no idea whether the problem still exists.  I've not had the afore
 mentioned sony for 18 months.
 
 Joe
 
 --Q68bSM7Ycu6FN28Q
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iEYEARECAAYFAjykQLEACgkQXVIcjOaxUBaRBgCg6M7huPgDYMb5nX3lW3mYH4OL
 G1AAoLF/Vh63t3koUBStkf8R/4Hbe587
 =1f5k
 -----END PGP SIGNATURE-----
 
 --Q68bSM7Ycu6FN28Q--

From: Hiten Pandya <hitmaster2k@yahoo.com>
To: Josef Karthauser <joe@tao.org.uk>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/20375 (close request)
Date: Sat, 11 May 2002 14:19:21 -0700 (PDT)

 --- Josef Karthauser <joe@tao.org.uk> wrote:
 > I've no idea whether the problem still exists.  I've not had the afore
 > mentioned sony for 18 months.
 
 Could you possibly close the PR, as I don't think there has been another PR
 which mentions this problem as far as I am aware.
 
 Thanks.
 
   -- Hiten
 
 
 __________________________________________________
 Do You Yahoo!?
 LAUNCH - Your Yahoo! Music Experience
 http://launch.yahoo.com
State-Changed-From-To: open->closed 
State-Changed-By: joe 
State-Changed-When: Sun May 12 14:56:05 PDT 2002 
State-Changed-Why:  
I've not had this laptop for a couple of years, and no-one else has 
reported the problem. 

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