From owner-freebsd-current@FreeBSD.ORG Thu Oct 28 18:34:37 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD63916A4CE; Thu, 28 Oct 2004 18:34:37 +0000 (GMT) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A51543D58; Thu, 28 Oct 2004 18:34:37 +0000 (GMT) (envelope-from glebius@freebsd.org) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.11/8.12.8) with ESMTP id i9SIYY13053464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 28 Oct 2004 22:34:35 +0400 (MSD) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.sick.ru (8.12.11/8.12.11/Submit) id i9SIYYNW053463; Thu, 28 Oct 2004 22:34:34 +0400 (MSD) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.sick.ru: glebius set sender to glebius@freebsd.org using -f Date: Thu, 28 Oct 2004 22:34:34 +0400 From: Gleb Smirnoff To: Anders Odberg , mdodd@freebsd.org, sos@freebsd.org Message-ID: <20041028183434.GA53441@cell.sick.ru> References: <200410111810.i9BIATXr023507@Espresso.NEEBU.Net> <20041019164557.GA84168@cell.sick.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="XsQoSWH+UP9D9v3l" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i cc: freebsd-current@freebsd.org cc: Jake Khuon Subject: Re: broken APM on IBM-T30 with 6.0-CURRENT X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2004 18:34:38 -0000 --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=koi8-r Content-Disposition: inline On Thu, Oct 28, 2004 at 08:29:17PM +0200, Anders Odberg wrote: A> | | I recently CVSup'd and noticed I can no longer APM suspend properly. A> | | The system just freezes while going into suspend. I don't know if A> | | I'm getting a panic or not. There's no trace or anything. Anyone A> | | got any ideas? The problem occurs in multiuser and singleuser mode A> | | and regardless of whether I'm in X or not. I'm not evern sure where A> | | to begin looking. A> | A> | can you try out attached hack? A> A> I can confirm that the patch you attached solved my long-standing problems A> with APM suspend/resume on a Thinkpad T40 and A21e when applied to todays A> RELENG_5 cvsup. All versions of RELENG_5 I've tried since the end of August A> have caused my Thinkpads to freeze either when suspending or when resuming. This hack was a dirty one. A better solution provided by Matthew Dodd is attached. However, it may not apply cleanly, since some things have already changed in source (at least in HEAD). For more information contact Matthew, who have investigated this problem and Soren, who is our ATA maintainer. I've Cc'ed both of them. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="ata-all.patch" Index: ata-all.c =================================================================== RCS file: /home/cvs/ncvs/src/sys/dev/ata/ata-all.c,v retrieving revision 1.232 diff -u -u -r1.232 ata-all.c --- ata-all.c 13 Oct 2004 15:16:35 -0000 1.232 +++ ata-all.c 19 Oct 2004 19:30:59 -0000 @@ -86,6 +86,7 @@ static struct intr_config_hook *ata_delayed_attach = NULL; static int ata_dma = 1; static int atapi_dma = 1; +static int ata_resuming = 0; /* sysctl vars */ SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters"); @@ -337,20 +352,21 @@ ata_suspend(device_t dev) { struct ata_channel *ch; - int gotit = 0; if (!dev || !(ch = device_get_softc(dev))) return ENXIO; - while (!gotit) { + while (1) { mtx_lock(&ch->state_mtx); if (ch->state == ATA_IDLE) { ch->state = ATA_ACTIVE; - gotit = 1; + mtx_unlock(&ch->state_mtx); + goto out; } mtx_unlock(&ch->state_mtx); - tsleep(&gotit, PRIBIO, "atasusp", hz/10); + tsleep(ch, PRIBIO, "atasusp", hz/10); } +out: ch->locking(ch, ATA_LF_UNLOCK); return 0; } @@ -364,8 +380,10 @@ if (!dev || !(ch = device_get_softc(dev))) return ENXIO; + ata_resuming = 1; error = ata_reinit(ch); ata_start(ch); + ata_resuming = 0; return error; } @@ -838,7 +944,7 @@ void ata_udelay(int interval) { - if (interval < (1000000/hz) || ata_delayed_attach) + if (interval < (1000000/hz) || ata_delayed_attach || ata_resuming) DELAY(interval); else tsleep(&interval, PRIBIO, "ataslp", interval/(1000000/hz)); --XsQoSWH+UP9D9v3l--