From owner-freebsd-bugs Sun Jun 10 19:40:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C26A837B401 for ; Sun, 10 Jun 2001 19:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5B2e1Z17686; Sun, 10 Jun 2001 19:40:01 -0700 (PDT) (envelope-from gnats) Received: from CRWdog.demon.co.uk (crwdog.demon.co.uk [193.237.46.84]) by hub.freebsd.org (Postfix) with ESMTP id 0600837B403 for ; Sun, 10 Jun 2001 19:30:51 -0700 (PDT) (envelope-from andy@CRWdog.demon.co.uk) Received: by CRWdog.demon.co.uk (Postfix, from userid 1001) id 5B8A03E96; Mon, 11 Jun 2001 03:30:48 +0100 (BST) Message-Id: <20010611023048.5B8A03E96@CRWdog.demon.co.uk> Date: Mon, 11 Jun 2001 03:30:48 +0100 (BST) From: spadger@best.com Reply-To: spadger@best.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/28026: Rage 128 Suspend issues Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 28026 >Category: bin >Synopsis: Graphics mode suspend causes weird hang on laptop with Rage card >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jun 10 19:40:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Andy Sparrow >Release: FreeBSD 4.3-RELEASE i386 >Organization: >Environment: System: FreeBSD omni.geek4food.org 4.3-RELEASE FreeBSD 4.3-RELEASE #52: Sat Jun 9 23:31:24 BST 2001 root@omni.geek4food.org:/usr/src/sys/compile/o6k i386 Omnibook 6000, Compaq Armada, multiple machines with Rage Mobility chipset (maybe others), believed most (all?) versions of FreeBSD 4.x with XFree86 3.3.x (at least 4.[23]-STABLE, 4.3-RELEASE with 3.3.6) >Description: On machines that support suspend-to-ram or suspend-to-disk (not as extensively tested), it has been observed that suspending (via either the 'apm' binary or closing the lid, pressing suspend button etc.) whilst in graphics mode (e.g. running an X server, either XF86_SVGA or XF86_Mach64) will put the machine in a strange state, where the display is very dim (but still barely visible), but machine will not respond to keyboard, power button or network, and the machine is still using mucho power (e.g. gets v.hot in bag). The only recourse then is to reset, with the attendant loss of uptime and filesystem checks. Sometimes, it can be harder to find a paperclip than you think... Switching to a text mode VT first avoids this problem, the machine will suspend and resume as expected. >How-To-Repeat: On such a machine as described (laptop with APM enabled and Rage Mobility chipset), suspend the machine, either via hardware or via 'apm', whilst running X. >Fix: It is possible to hack around the problem by calling a binary (e.g. from 'rc.suspend') that switches to text mode first, before issuing the suspend call. This obviously leaves two files that need to be maintained, particularly when cvsup'ing regularly it is inevitable that this extra step will be overlooked sooner or later. Also, a better way to address this issue (if not in the X server itself), seems to be in the 'apm' binary, which should DTRT. I attach for your consideration some example patches to 'apm' and its Makefile, and some (commented-out) options with descriptive commands for 'etc/defaults/make.conf' (intended to be activated in '/etc/make.conf', naturally). In this way, it is as unobtrusive as possible on machine/systems that don't need this, yet fixes the problems for machines that do. Thanks. *** usr.sbin/apm/apm.c.orig Tue Apr 17 23:53:48 2001 --- usr.sbin/apm/apm.c Mon Apr 30 23:55:31 2001 *************** *** 36,41 **** --- 36,47 ---- #define APMDEV "/dev/apm" + #ifdef WANT_TEXTMODE_SUSPEND + #define VGADEV "/dev/vga" + #include + #include + #endif + #define xh(a) (((a) & 0xff00) >> 8) #define xl(a) ((a) & 0xff) #define APMERR(a) xh(a) *************** *** 126,131 **** --- 132,168 ---- err(1, "ioctl(APMIO_STANDBY)"); } + #ifdef WANT_TEXTMODE_SUSPEND + void + apm_wrapper(int fd, void (*fptr)(int)) + { + int myfd, vt, status; + + myfd = open(VGADEV, O_RDONLY); + if(myfd < 0) + err(1, "open %s", VGADEV); + if(ioctl(myfd, VT_GETACTIVE, &vt) < 0) + err(1, "ioctl VT_GETACTIVE"); + if(ioctl(myfd, VT_ACTIVATE, 1) < 0) + err(1, "ioctl VT_ACTIVATE"); + + switch(fork()) { + case -1: + err(1, "fork"); + case 0: + fptr (fd); + break; + default: + wait(&status); + if(!WIFEXITED(status) || WEXITSTATUS(status)) + errx(1, "apm -z failed"); + } + sleep(2); + if(ioctl(myfd, VT_ACTIVATE, vt) < 0) + err(1, "ioctl VT_ACTIVATE"); + } + #endif + void apm_getinfo(int fd, apm_info_t aip) { *************** *** 483,492 **** --- 520,535 ---- apm_haltcpu(fd, haltcpu); if (delta) apm_set_timer(fd, delta); + #ifdef WANT_TEXTMODE_SUSPEND + if (sleep || standby) { + apm_wrapper( fd, (sleep?apm_suspend:apm_standby) ); + } + #else if (sleep) apm_suspend(fd); else if (standby) apm_standby(fd); + #endif else if (delta == 0) { struct apm_info info; *** usr.sbin/apm/Makefile.orig Wed Apr 18 00:45:22 2001 --- usr.sbin/apm/Makefile Wed Apr 18 01:05:41 2001 *************** *** 5,8 **** --- 5,20 ---- MAN8= apm.8 MLINKS= apm.8 apmconf.8 apm.8 zzz.8 + + .if defined(WANT_TEXTMODE_SUSPEND) + CFLAGS+= -DWANT_TEXTMODE_SUSPEND + .endif + + .if defined(NOSUID) || !defined(ALLOW_USER_SUSPEND) + BINMODE=555 + .else + BINMODE=4555 + BINOWN= root + .endif + .include *** etc/defaults/make.conf.orig Thu Apr 19 15:16:43 2001 --- etc/defaults/make.conf Thu Apr 19 15:24:49 2001 *************** *** 140,145 **** --- 140,159 ---- #NOMANCOMPRESS= true # # + # Some machines (e.g. laptops) with certain graphics devices (notably + # ATI Rage Mobility) react badly to being suspended when in graphics + # mode (e.g. in X) and lock the machine entirely. If you suffer from + # this, try uncommenting the following: + # + #WANT_TEXTMODE_SUSPEND= true + # + # + # If you uncomment the above, you might want/need to uncomment the + # following to permit suspends by users. (Makes apm(8) SUID root). + # + #ALLOW_USER_SUSPEND= true + # + # # If you want the "compat" shared libraries installed as part of your normal # builds, uncomment these: # >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message