Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 May 2009 08:48:03 +0200
From:      Magnus Kling <klingfon@gmail.com>
To:        freebsd-acpi@freebsd.org
Subject:   Re: Fwd: Kernel panic on 7.2-RC1 when booting with ACPI enabled  kernel.
Message-ID:  <43b1bb350905142348u7b8385acjd2ff4ca1ac4da9d5@mail.gmail.com>
In-Reply-To: <200905111425.01887.jhb@freebsd.org>
References:  <43b1bb350904230622u4b7790f0p9f665b649c97a3b@mail.gmail.com> <200905011450.13899.jhb@freebsd.org> <43b1bb350905011230p1372e1ffw5ab61985e7672e19@mail.gmail.com> <200905111425.01887.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2009/5/11 John Baldwin <jhb@freebsd.org>

> On Friday 01 May 2009 3:30:28 pm Magnus Kling wrote:
> > 2009/5/1 John Baldwin <jhb@freebsd.org>
> >
> > > On Friday 01 May 2009 2:30:28 pm Magnus Kling wrote:
> > > > 2009/4/30 John Baldwin <jhb@freebsd.org>
> > > >
> > > > > On Saturday 25 April 2009 6:27:23 am Magnus Kling wrote:
> > > > > > 2009/4/24 John Baldwin <jhb@freebsd.org>
> > > > > > > Can you do 'frame 10' followed by 'p *(struct acpi_pci_devinf=
o
> > > > > > > *)child->ivars'
> > > > > > >
> > > > > > > --
> > > > > > > John Baldwin
> > > > > >
> > > > > >
> > > > > > Sure, no problem. This is a none critical server so I can do al=
ot
> of
> > > > > > debugging and testing if that is needed.
> > > > > >
> > > > > >
> > > > > > (kgdb) frame 10
> > > > > > #10 0xc0db4ca8 in acpi_pci_child_location_str_method
> > > (cbdev=3D0xc2212680,
> > > > > >     child=3D0xc2243400, buf=3D0xc22c2400 "slot=3D0 function=3D0=
 handle=3D",
> > > > > > buflen=3D1024)
> > > > > >     at
> > > /usr/src/sys/modules/acpi/acpi/../../../dev/acpica/acpi_pci.c:150
> > > > > > 150             strlcat(buf, acpi_name(dinfo->ap_handle),
> buflen);
> > > > > >
> > > > > > (kgdb)  p *(struct acpi_pci_devinfo *)child->ivars
> > > > > > $1 =3D {ap_dinfo =3D {pci_links =3D {stqe_next =3D 0xc0b00f8c},=
 resources
> =3D {
> > > > > >       stqh_first =3D 0xc0b00f8c, stqh_last =3D 0x1030000}, cfg =
=3D {dev
> =3D
> > > 0x0,
> > > > > >       bar =3D {4, 0, 0, 3257136600, 0, 0}, bios =3D 0, subvendo=
r =3D 0,
> > > > > >       subdevice =3D 0, vendor =3D 0, device =3D 0, cmdreg =3D 0=
, statreg
> =3D 0,
> > > > > >       baseclass =3D 0 '\0', subclass =3D 0 '\0', progif =3D 0 '=
\0',
> revid =3D
> > > 0
> > > > >
> > > > > Hmm, this is all completely wrong and trashed.  What if you do 'p
> > > *child'?
> > > > >
> > > > > --
> > > > > John Baldwin
> > > > >
> > > > (kgdb) p *child
> > > > $2 =3D {ops =3D 0xc2161800, link =3D {tqe_next =3D 0xc2243380, tqe_=
prev =3D
> > > > 0xc2243484}, devlink =3D {tqe_next =3D 0xc2243380, tqe_prev =3D
> 0xc224348c},
> > > >   parent =3D 0xc2212680, children =3D {tqh_first =3D 0xc2262880, tq=
h_last =3D
> > > > 0xc2262704}, driver =3D 0xc0b7066c, devclass =3D 0xc211e240, unit =
=3D 0,
> > > >   nameunit =3D 0xc2241640 "atapci0", desc =3D 0xc223f900 "Promise
> PDC20621
> > > > UDMA100 controller", busy =3D 0, state =3D DS_ATTACHED, devflags =
=3D 0,
> > > >   flags =3D 13, order =3D 0 '\0', pad =3D 0 '\0', ivars =3D 0xc223f=
5c0, softc
> =3D
> > > > 0xc2244800, sysctl_ctx =3D {tqh_first =3D 0xc2264380, tqh_last =3D
> 0xc2241594},
> > > >   sysctl_tree =3D 0xc223f840}
> > > > (kgdb)
> > >
> > > Maybe try adding KTR traces for all calls to device_set_ivars().  I
> wonder
> > > if
> > > something is trashing this device's ivars.
> > >
> > > Oh, dear.  The ata(4) driver overwrites the ivars of some PCI devices
> it
> > > attaches to.  This is very, very wrong.  Which ATA controller do you
> have?
> > >
> > > --
> > > John Baldwin
> > >
> >
> > Aha, I=B4m using a Promise Fasttrack SX4000 for a RAID1 setup. And the =
one
> > included on the motherboard for the OS.
> > And yes, I can confirm that without the Fasttrack SX4000 the system boo=
ts
> up
> > correctly. (Pulled out the card and edited fstab.)
> > So you are right regarding that the ata driver messes something up. Do
> you
> > contact someone that is responsible for ata driver?
> >
> > Thank you for taking the time to "correct" this,
>
> Can you please try this patch?
>
> --- //depot/vendor/freebsd/src/sys/dev/ata/ata-pci.h    2009/03/30 22:20:=
14
> +++ //depot/user/jhb/acpipci/dev/ata/ata-pci.h  2009/05/08 20:27:43
> @@ -66,6 +66,7 @@
>     void                (*function)(void *);
>     void                *argument;
>     } interrupt[8];     /* XXX SOS max ch# for now */
> +    void                *chipset_data;
>  };
>
>  /* defines for known chipset PCI id's */
> --- //depot/vendor/freebsd/src/sys/dev/ata/chipsets/ata-acard.c 2009/02/1=
9
> 00:35:16
> +++ //depot/user/jhb/acpipci/dev/ata/chipsets/ata-acard.c       2009/05/0=
8
> 20:27:43
> @@ -51,6 +51,12 @@
>  #include <dev/ata/ata-pci.h>
>  #include <ata_if.h>
>
> +struct ata_serialize {
> +    struct mtx  locked_mtx;
> +    int         locked_ch;
> +    int         restart_ch;
> +};
> +
>  /* local prototypes */
>  static int ata_acard_chipinit(device_t dev);
>  static int ata_acard_ch_attach(device_t dev);
> @@ -58,6 +64,7 @@
>  static void ata_acard_850_setmode(device_t dev, int mode);
>  static void ata_acard_86X_setmode(device_t dev, int mode);
>  static int ata_serialize(device_t dev, int flags);
> +static void ata_serialize_init(struct ata_serialize *serial);
>
>  /* misc defines */
>  #define ATP_OLD                1
> @@ -93,6 +100,7 @@
>  ata_acard_chipinit(device_t dev)
>  {
>     struct ata_pci_controller *ctlr =3D device_get_softc(dev);
> +    struct ata_serialize *serial;
>
>     if (ata_setup_interrupt(dev, ata_generic_intr))
>        return ENXIO;
> @@ -100,8 +108,12 @@
>     ctlr->ch_attach =3D ata_acard_ch_attach;
>     ctlr->ch_detach =3D ata_pci_ch_detach;
>     if (ctlr->chip->cfg1 =3D=3D ATP_OLD) {
> -       ctlr->setmode =3D ata_acard_850_setmode;
> +       ctlr->setmode =3D ata_acard_850_setmode;
>        ctlr->locking =3D ata_serialize;
> +       serial =3D malloc(sizeof(struct ata_serialize),
> +                             M_TEMP, M_WAITOK | M_ZERO);
> +       ata_serialize_init(serial);
> +       ctlr->chipset_data =3D serial;
>     }
>     else
>        ctlr->setmode =3D ata_acard_86X_setmode;
> @@ -225,11 +237,14 @@
>     /* we could set PIO mode timings, but we assume the BIOS did that */
>  }
>
> -struct ata_serialize {
> -    struct mtx  locked_mtx;
> -    int         locked_ch;
> -    int         restart_ch;
> -};
> +static void
> +ata_serialize_init(struct ata_serialize *serial)
> +{
> +
> +    mtx_init(&serial->locked_mtx, "ATA serialize lock", NULL, MTX_DEF);
> +    serial->locked_ch =3D -1;
> +    serial->restart_ch =3D -1;
> +}
>
>  static int
>  ata_serialize(device_t dev, int flags)
> @@ -237,20 +252,9 @@
>     struct ata_pci_controller *ctlr =3D
> device_get_softc(device_get_parent(dev));
>     struct ata_channel *ch =3D device_get_softc(dev);
>     struct ata_serialize *serial;
> -    static int inited =3D 0;
>     int res;
>
> -    if (!inited) {
> -       serial =3D malloc(sizeof(struct ata_serialize),
> -                             M_TEMP, M_NOWAIT | M_ZERO);
> -       mtx_init(&serial->locked_mtx, "ATA serialize lock", NULL, MTX_DEF=
);
> -       serial->locked_ch =3D -1;
> -       serial->restart_ch =3D -1;
> -       device_set_ivars(ctlr->dev, serial);
> -       inited =3D 1;
> -    }
> -    else
> -       serial =3D device_get_ivars(ctlr->dev);
> +    serial =3D ctlr->chipset_data;
>
>     mtx_lock(&serial->locked_mtx);
>     switch (flags) {
> --- //depot/vendor/freebsd/src/sys/dev/ata/chipsets/ata-promise.c
> 2009/03/30 22:20:14
> +++ //depot/user/jhb/acpipci/dev/ata/chipsets/ata-promise.c     2009/05/0=
8
> 20:27:43
> @@ -283,7 +283,7 @@
>            mtx_init(&hpkt->mtx, "ATA promise HPKT lock", NULL, MTX_DEF);
>            TAILQ_INIT(&hpkt->queue);
>            hpkt->busy =3D 0;
> -           device_set_ivars(dev, hpkt);
> +           ctlr->chipset_data =3D hpkt;
>            ctlr->ch_attach =3D ata_promise_mio_ch_attach;
>            ctlr->ch_detach =3D ata_promise_mio_ch_detach;
>            ctlr->reset =3D ata_promise_mio_reset;
> @@ -730,7 +730,7 @@
>     case PR_SX4X:
>
>        /* softreset channel ATA module */
> -       hpktp =3D device_get_ivars(ctlr->dev);
> +       hpktp =3D ctlr->chipset_data;
>        ATA_OUTL(ctlr->r_res2, 0xc0260 + (ch->unit << 7), ch->unit + 1);
>        ata_udelay(1000);
>        ATA_OUTL(ctlr->r_res2, 0xc0260 + (ch->unit << 7),
> @@ -1208,7 +1208,7 @@
>  static void
>  ata_promise_queue_hpkt(struct ata_pci_controller *ctlr, u_int32_t hpkt)
>  {
> -    struct ata_promise_sx4 *hpktp =3D device_get_ivars(ctlr->dev);
> +    struct ata_promise_sx4 *hpktp =3D ctlr->chipset_data;
>
>     mtx_lock(&hpktp->mtx);
>     if (hpktp->busy) {
> @@ -1227,7 +1227,7 @@
>  static void
>  ata_promise_next_hpkt(struct ata_pci_controller *ctlr)
>  {
> -    struct ata_promise_sx4 *hpktp =3D device_get_ivars(ctlr->dev);
> +    struct ata_promise_sx4 *hpktp =3D ctlr->chipset_data;
>     struct host_packet *hp;
>
>     mtx_lock(&hpktp->mtx);
>
> --
> John Baldwin
>

This is only a response to everyone that is following this thread and have
had the same errors as I have... and are looking for a solution.

The patch will NOT work for FreeBSD 7.0 or 7.1.
This patch www.freebsd.org/~jhb/patches/ata_ivars_7.patch<http://www.freebs=
d.org/%7Ejhb/patches/ata_ivars_7.patch>.
will WORK for FreeBSD 7. I have tried it with 7.1-RC2 and it works.

John Baldwin will commit the bits to source at a later stage. (Said in an
non-list email).

/Magnus



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