From owner-freebsd-current@FreeBSD.ORG Sat Apr 15 20:57:51 2006 Return-Path: X-Original-To: current@freebsd.org 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 ACE1D16A401 for ; Sat, 15 Apr 2006 20:57:51 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from smtprelay01.ispgateway.de (smtprelay01.ispgateway.de [80.67.18.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F86043D81 for ; Sat, 15 Apr 2006 20:57:26 +0000 (GMT) (envelope-from freebsd-listen@fabiankeil.de) Received: (qmail 31770 invoked from network); 15 Apr 2006 20:57:05 -0000 Received: from unknown (HELO localhost) ([pbs]775067@[217.50.149.95]) (envelope-sender ) by smtprelay01.ispgateway.de (qmail-ldap-1.03) with SMTP for ; 15 Apr 2006 20:57:05 -0000 Date: Sat, 15 Apr 2006 22:55:50 +0200 From: Fabian Keil To: Gavin Atkinson Message-ID: <20060415225550.1d697100@localhost> In-Reply-To: <20060415111208.Q34088@ury.york.ac.uk> References: <20060413.012156.56054177.iwasaki@jp.FreeBSD.org> <443F54DF.3080809@root.org> <20060414.180622.30189283.iwasaki@jp.FreeBSD.org> <20060414.233013.41626908.iwasaki@jp.FreeBSD.org> <1145029263.912.4.camel@sos.deepcore.dk> <20060415111208.Q34088@ury.york.ac.uk> X-Mailer: Sylpheed-Claws 2.0.0 (GTK+ 2.8.6; i386-portbld-freebsd6.0) X-PGP-KEY-URL: http://www.fabiankeil.de/gpg-keys/freebsd-listen-2006-08-19.asc Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_e0nZIiIFw=yh+gBU5lZ+TW1"; protocol="application/pgp-signature"; micalg=PGP-SHA1 Cc: current@freebsd.org, =?ISO-8859-1?Q?S=F8ren?= Schmidt Subject: [PATCH] Panic in acd_geom_detach if device got lost (was: CFR: ACPI Dock driver) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 15 Apr 2006 20:57:51 -0000 --Sig_e0nZIiIFw=yh+gBU5lZ+TW1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Gavin Atkinson wrote: > On Fri, 14 Apr 2006, [ISO-8859-1] S=F8ren Schmidt wrote: >=20 > > On Fre, 2006-04-14 at 23:30 +0900, Mitsuru IWASAKI wrote: > >> Hi, Soren. > >> I've found the problem with detached ATA channel suspending. > >> After detaching second channel, the system drops into infinity > >> loop at ata_suspend(). > >> I'll commit the following patches with acpi_dock patches, so > >> please refine these if they have any problem. > > > > Uhm, would this simple patch help you ? > > > > --- ata-all.c 31 Mar 2006 08:09:04 -0000 1.271 > > +++ ata-all.c 14 Apr 2006 15:39:20 -0000 > > @@ -277,8 +277,8 @@ > > if (!dev || !(ch =3D device_get_softc(dev))) > > return ENXIO; > > > > - /* wait for the channel to be IDLE before entering suspend > > mode */ > > - while (1) { > > + /* wait for the channel to be IDLE or detached before > > suspending */ > > + while (ch->r_irq) { > > mtx_lock(&ch->state_mtx); > > if (ch->state =3D=3D ATA_IDLE) { > > ch->state =3D ATA_ACTIVE; > > > > That I'll gladly commit for you instead... >=20 > Is there any chance this will also fix the panic myself and several > others have been seeing with suspend and CD-ROM drives? > http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2005-08/0996.html >=20 > I'll take my laptop to top-of-tree CURRENT in the next day or so to > try it. I tried the above patch on RELENG_6 and it doesn't seem to change my situation (which isn't suspend related anyway). If I remove my ThinkPad's cdrom drive, FreeBSD becomes unresponsive after atacontrol reinit ata1. It seems to freeze in this part of ata-lowlevel.c: 492: /* in some setups we dont want to test for a slave */ 493- if (!(ch->flags & ATA_NO_SLAVE)) { 494- ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_SLAVE); 495- DELAY(10); =20 496- ostat1 =3D ATA_IDX_INB(ch, ATA_STATUS); 497- if ((ostat1 & 0xf8) !=3D 0xf8 && ostat1 !=3D 0xa5) { 498- stat1 =3D ATA_S_BUSY; 499- mask |=3D 0x02; 500- } 501- } 502- More precisely, it doesn't get past the macro in line 494. Any ideas why "ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_SLAV= E);" could cause an unresponsive system? I ruled out a nullpointer, but I haven't found the code the macro leads to yet.=20 If I comment out this whole block, I reach the panic Gavin already analysed in the link above. It can be prevented with the following patch: fk@TP51 /usr/src/sys/dev/ata $diff -uN atapi-cd.c.original atapi-cd.c=20 --- atapi-cd.c.original Sat Apr 15 16:59:46 2006 +++ atapi-cd.c Sat Apr 15 17:12:32 2006 @@ -193,9 +193,12 @@ { =20 struct acd_softc *cdp =3D device_get_ivars(arg); =20 - /* signal geom so we dont get any further requests */ - g_wither_geom(cdp->gp, ENXIO); - + if (cdp !=3D NULL) { =20 + /* signal geom so we dont get any further requests */ + g_wither_geom(cdp->gp, ENXIO); + } else { + printf("acd_geom_detach: Device already detached?\n"); + } /* fail requests on the queue and any thats "in flight" for this devic= e */ ata_fail_requests(arg); Now I can remove my cdrom drive while FreeBSD is running and atacontrol reinit no longer causes the panic: fk@TP51 ~ $sudo atacontrol reinit ata1 Master: acd0 ATA/ATAPI revision 5 Slave: no device present =20 [Removing drive] fk@TP51 ~ $sudo atacontrol reinit ata1 Master: no device present =20 Slave: no device present Fabian --=20 http://www.fabiankeil.de/ --Sig_e0nZIiIFw=yh+gBU5lZ+TW1 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (FreeBSD) iD8DBQFEQV3kjV8GA4rMKUQRAogHAJ4gAAtxaqyGOh1TaiZAJBY9EUTvVgCfTn+g PdodiWeFbqZvjv7w68BCeDM= =2912 -----END PGP SIGNATURE----- --Sig_e0nZIiIFw=yh+gBU5lZ+TW1--