KIYOHARA Takashi | 5 Dec 2011 16:23
Picon

panic mutex

Hi! all,

I encounter a (compiler?) bug?
My bebox panics on mutex_enter() in joyattach().
mtxm_owner (or mtxp_a) is initialized in mutex_init().  However, it
becomes dirty when seting the address to sc->sc_lock.

Index: joy_isa.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/joy_isa.c,v
retrieving revision 1.13
diff -u -r1.13 joy_isa.c
--- joy_isa.c	23 Nov 2011 23:07:32 -0000	1.13
+++ joy_isa.c	5 Dec 2011 14:57:28 -0000
 <at>  <at>  -117,7 +117,10  <at>  <at> 
 	}

 	mutex_init(&isc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+printf("%s: mutex=%d, 0x%x, 0x%x, 0x%x\n", __func__, sizeof(isc->sc_lock),
isc->sc_lock.u.p.mtxp_a, isc->sc_lock.u.p.mtxp_b[0], isc->sc_lock.u.p.mtxp_b[1]);
 	sc->sc_lock = &isc->sc_lock;
+printf("%s: Re: sc mutex=%p, 0x%x, 0x%x, 0x%x\n", __func__, sc->sc_lock, sc->sc_lock->u.p.mtxp_a,
sc->sc_lock->u.p.mtxp_b[0], sc->sc_lock->u.p.mtxp_b[1]);
+printf("%s: Re: isc mutex=%p, 0x%x, 0x%x, 0x%x\n", __func__, &isc->sc_lock,
isc->sc_lock.u.p.mtxp_a, isc->sc_lock.u.p.mtxp_b[0], isc->sc_lock.u.p.mtxp_b[1]);

 	joyattach(sc);
 }

joy_isa_attach: mutex=12, 0x0, 0x0, 0x0
(Continue reading)

Frank Wille | 5 Dec 2011 20:03
Picon

Re: panic mutex

KIYOHARA Takashi wrote:

> mtxm_owner (or mtxp_a) is initialized in mutex_init().  However, it
> becomes dirty when seting the address to sc->sc_lock.
> [...]
> Can I resolve this problem?

Yes. There seems to be a bug in joy_isa_attach():

static void
joy_isa_attach(device_t parent, device_t self, void *aux)
{
        struct joy_softc *sc = device_private(self);
        struct joy_isa_softc *isc = device_private(self);
[...]
       sc->sc_lock = &isc->sc_lock;
        joyattach(sc);
}

sc and isc share the same address. This cannot be right.

This is the reason why assigning sc->sc_lock changes something in isc. From
the offset of sc_lock you are likely to hit the kmutex in isc.

I would suggest to fix the joy_isa_softc structure. For example by making
struct joy_softc a part of it:

struct joy_isa_softc {
        struct joy_softc        sc;
        kmutex_t                sc_lock;
(Continue reading)

Christos Zoulas | 5 Dec 2011 21:03

Re: panic mutex

In article <20111206.002317.91311369.kiyohara <at> kk.iij4u.or.jp>,
KIYOHARA Takashi  <kiyohara <at> kk.iij4u.or.jp> wrote:
>Hi! all,
>
>
>I encounter a (compiler?) bug?
>My bebox panics on mutex_enter() in joyattach().
>mtxm_owner (or mtxp_a) is initialized in mutex_init().  However, it
>becomes dirty when seting the address to sc->sc_lock.

cvs update.

christos


Gmane