Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Apr 2006 22:55:50 +0200
From:      Fabian Keil <freebsd-listen@fabiankeil.de>
To:        Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
Cc:        current@freebsd.org, =?ISO-8859-1?Q?S=F8ren?= Schmidt <sos@freebsd.org>
Subject:   [PATCH] Panic in acd_geom_detach if device got lost (was: CFR: ACPI Dock driver)
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>

next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_e0nZIiIFw=yh+gBU5lZ+TW1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Gavin Atkinson <gavin.atkinson@ury.york.ac.uk> 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 <HL-DT-STCD-RW/DVD DRIVE GCC-4241N/1.04> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060415225550.1d697100>