Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Dec 2003 15:20:22 +0100
From:      Maxime Henrion <mux@freebsd.org>
To:        Jesse Guardiani <jesse@wingnet.net>
Cc:        freebsd-current@freebsd.org
Subject:   Re: 5.2-BETA dsp.c duplicate lock
Message-ID:  <20031201142022.GK8404@elvis.mu.org>
In-Reply-To: <bqfgsc$qmu$1@sea.gmane.org>
References:  <bq68t8$c8n$2@sea.gmane.org> <bqfgsc$qmu$1@sea.gmane.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--/WwmFnJnmDyWGHa4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Jesse Guardiani wrote:
> Jesse Guardiani wrote:
> 
> > I get this every time I `startx`. I didn't see it in
> > the archive either:
> > 
> > 
> > acquiring duplicate lock of same type: "pcm channel"
> >  1st pcm0:record:0 @ /usr/src/sys/dev/sound/pcm/dsp.c:144
> >  2nd pcm0:virtual:0 @ /usr/src/sys/dev/sound/pcm/dsp.c:146
> > Stack backtrace:
> > backtrace(c089b7e5,c3c96a54,c0a8f35a,92,200246) at backtrace+0x17
> > witness_lock(c3c6aa80,8,c0a8f35a,92,20000002) at witness_lock+0x672
> > _mtx_lock_flags(c3c6aa80,0,c0a8f35a,92,c4) at _mtx_lock_flags+0xba
> > getchns(c3d07700,e473faf0,e473faf4,30000000,c3b86980) at getchns+0x1b5
> > dsp_poll(c3d07700,c4,c403e640,c097fce0,0) at dsp_poll+0x46
> > spec_poll(e473fb48,e473fb68,c06d600c,e473fb48,c0937ca0) at spec_poll+0x180
> > spec_vnoperate(e473fb48,c0937ca0,c438db2c,c4,c4361a80) at
> > spec_vnoperate+0x18 vn_poll(c4599110,c4,c4361a80,c403e640,c4361a80) at
> > vn_poll+0x3c pollscan(c403e640,e473fbd8,3,3e1,18) at pollscan+0xb3
> > poll(c403e640,e473fd14,c08b631d,3ee,3) at poll+0x252
> > syscall(2f,2f,2f,ffffffff,bfbfe748) at syscall+0x2c0
> > Xint0x80_syscall() at Xint0x80_syscall+0x1d
> > --- syscall (209), eip = 0x2869322f, esp = 0xbfbfe70c, ebp = 0xbfbfe768
> > ---
> > 
> 
> I this a known LOR? Or do I need to submit a pr?

This isn't a LOR at all.  Could you please try the attached patch?  It
should fix your problem.

To the sound guys : I believe it's expected that the pcm code will
sometimes acquire several channels lock at once, but I am not 100% sure.
If it's not, this patch isn't a fix but a workaround.

Cheers,
Maxime

--/WwmFnJnmDyWGHa4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pcm.patch"

Index: isa/ad1816.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/isa/ad1816.c,v
retrieving revision 1.29
diff -u -p -r1.29 ad1816.c
--- isa/ad1816.c	7 Sep 2003 16:28:02 -0000	1.29
+++ isa/ad1816.c	1 Dec 2003 14:11:45 -0000
@@ -593,7 +593,8 @@ ad1816_attach(device_t dev)
 	ad1816 = (struct ad1816_info *)malloc(sizeof *ad1816, M_DEVBUF, M_NOWAIT | M_ZERO);
 	if (!ad1816) return ENXIO;
 
-	ad1816->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	ad1816->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc",
+	    0);
 	ad1816->io_rid = 2;
 	ad1816->irq_rid = 0;
 	ad1816->drq1_rid = 0;
Index: isa/mss.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/isa/mss.c,v
retrieving revision 1.86
diff -u -p -r1.86 mss.c
--- isa/mss.c	7 Sep 2003 16:28:02 -0000	1.86
+++ isa/mss.c	1 Dec 2003 14:11:53 -0000
@@ -1667,7 +1667,7 @@ mss_doattach(device_t dev, struct mss_in
     	int pdma, rdma, flags = device_get_flags(dev);
     	char status[SND_STATUSLEN], status2[SND_STATUSLEN];
 
-	mss->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	mss->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc", 0);
 	mss->bufsize = pcm_getbuffersize(dev, 4096, MSS_DEFAULT_BUFSZ, 65536);
     	if (!mss_alloc_resources(mss, dev)) goto no;
     	mss_init(mss, dev);
Index: isa/sbc.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/isa/sbc.c,v
retrieving revision 1.38
diff -u -p -r1.38 sbc.c
--- isa/sbc.c	7 Feb 2003 14:05:33 -0000	1.38
+++ isa/sbc.c	1 Dec 2003 14:12:03 -0000
@@ -116,7 +116,8 @@ static void sb_setmixer(struct resource 
 static void
 sbc_lockinit(struct sbc_softc *scp)
 {
-	scp->lock = snd_mtxcreate(device_get_nameunit(scp->dev), "sound softc");
+	scp->lock = snd_mtxcreate(device_get_nameunit(scp->dev), "sound softc",
+	    0);
 }
 
 static void
Index: pci/cmi.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pci/cmi.c,v
retrieving revision 1.23
diff -u -p -r1.23 cmi.c
--- pci/cmi.c	2 Sep 2003 17:30:37 -0000	1.23
+++ pci/cmi.c	1 Dec 2003 14:12:15 -0000
@@ -842,7 +842,7 @@ cmi_attach(device_t dev)
 		return ENXIO;
 	}
 
-	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc", 0);
 	data = pci_read_config(dev, PCIR_COMMAND, 2);
 	data |= (PCIM_CMD_PORTEN|PCIM_CMD_BUSMASTEREN);
 	pci_write_config(dev, PCIR_COMMAND, data, 2);
Index: pci/ds1.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pci/ds1.c,v
retrieving revision 1.36
diff -u -p -r1.36 ds1.c
--- pci/ds1.c	2 Sep 2003 17:30:37 -0000	1.36
+++ pci/ds1.c	1 Dec 2003 14:12:26 -0000
@@ -942,7 +945,7 @@ ds_pci_attach(device_t dev)
 		return ENXIO;
 	}
 
-	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc", 0);
 	sc->dev = dev;
 	subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev);
 	sc->type = ds_finddev(pci_get_devid(dev), subdev);
Index: pci/emu10k1.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pci/emu10k1.c,v
retrieving revision 1.41
diff -u -p -r1.41 emu10k1.c
--- pci/emu10k1.c	7 Sep 2003 16:28:03 -0000	1.41
+++ pci/emu10k1.c	1 Dec 2003 14:12:35 -0000
@@ -1468,7 +1468,7 @@ emu_pci_attach(device_t dev)
 		return ENXIO;
 	}
 
-	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc", 0);
 	sc->dev = dev;
 	sc->type = pci_get_devid(dev);
 	sc->rev = pci_get_revid(dev);
Index: pci/t4dwave.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pci/t4dwave.c,v
retrieving revision 1.40
diff -u -p -r1.40 t4dwave.c
--- pci/t4dwave.c	7 Sep 2003 16:28:03 -0000	1.40
+++ pci/t4dwave.c	1 Dec 2003 14:12:42 -0000
@@ -811,7 +811,7 @@ tr_pci_attach(device_t dev)
 
 	tr->type = pci_get_devid(dev);
 	tr->rev = pci_get_revid(dev);
-	tr->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
+	tr->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc", 0);
 
 	data = pci_read_config(dev, PCIR_COMMAND, 2);
 	data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
Index: pcm/ac97.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pcm/ac97.c,v
retrieving revision 1.49
diff -u -p -r1.49 ac97.c
--- pcm/ac97.c	11 Nov 2003 22:15:17 -0000	1.49
+++ pcm/ac97.c	1 Dec 2003 14:10:11 -0000
@@ -672,7 +672,7 @@ ac97_create(device_t dev, void *devinfo,
 		return NULL;
 
 	snprintf(codec->name, AC97_NAMELEN, "%s:ac97", device_get_nameunit(dev));
-	codec->lock = snd_mtxcreate(codec->name, "ac97 codec");
+	codec->lock = snd_mtxcreate(codec->name, "ac97 codec", 0);
 	codec->methods = kobj_create(cls, M_AC97, M_WAITOK);
 	if (codec->methods == NULL) {
 		snd_mtxlock(codec->lock);
Index: pcm/channel.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pcm/channel.c,v
retrieving revision 1.91
diff -u -p -r1.91 channel.c
--- pcm/channel.c	9 Nov 2003 09:17:22 -0000	1.91
+++ pcm/channel.c	1 Dec 2003 14:10:11 -0000
@@ -69,7 +69,7 @@ static int chn_buildfeeder(struct pcm_ch
 static void
 chn_lockinit(struct pcm_channel *c)
 {
-	c->lock = snd_mtxcreate(c->name, "pcm channel");
+	c->lock = snd_mtxcreate(c->name, "pcm channel", MTX_DUPOK);
 }
 
 static void
Index: pcm/mixer.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pcm/mixer.c,v
retrieving revision 1.33
diff -u -p -r1.33 mixer.c
--- pcm/mixer.c	11 Nov 2003 05:38:28 -0000	1.33
+++ pcm/mixer.c	1 Dec 2003 14:10:11 -0000
@@ -194,7 +194,7 @@ mixer_init(device_t dev, kobj_class_t cl
 
 	m = (struct snd_mixer *)kobj_create(cls, M_MIXER, M_WAITOK | M_ZERO);
 	snprintf(m->name, MIXER_NAMELEN, "%s:mixer", device_get_nameunit(dev));
-	m->lock = snd_mtxcreate(m->name, "pcm mixer");
+	m->lock = snd_mtxcreate(m->name, "pcm mixer", 0);
 	m->type = cls->name;
 	m->devinfo = devinfo;
 	m->busy = 0;
Index: pcm/sound.c
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pcm/sound.c,v
retrieving revision 1.85
diff -u -p -r1.85 sound.c
--- pcm/sound.c	7 Sep 2003 16:28:03 -0000	1.85
+++ pcm/sound.c	1 Dec 2003 14:10:01 -0000
@@ -88,7 +88,7 @@ snd_sysctl_tree_top(device_t dev)
 }
 
 void *
-snd_mtxcreate(const char *desc, const char *type)
+snd_mtxcreate(const char *desc, const char *type, int opts)
 {
 #ifdef USING_MUTEX
 	struct mtx *m;
@@ -96,7 +96,7 @@ snd_mtxcreate(const char *desc, const ch
 	m = malloc(sizeof(*m), M_DEVBUF, M_WAITOK | M_ZERO);
 	if (m == NULL)
 		return NULL;
-	mtx_init(m, desc, type, MTX_RECURSE);
+	mtx_init(m, desc, type, MTX_RECURSE | opts);
 	return m;
 #else
 	return (void *)0xcafebabe;
@@ -641,7 +641,7 @@ pcm_register(device_t dev, void *devinfo
 		return EINVAL;
 	}
 
-	d->lock = snd_mtxcreate(device_get_nameunit(dev), "sound cdev");
+	d->lock = snd_mtxcreate(device_get_nameunit(dev), "sound cdev", 0);
 
 	d->flags = 0;
 	d->dev = dev;
Index: pcm/sound.h
===================================================================
RCS file: /space2/ncvs/src/sys/dev/sound/pcm/sound.h,v
retrieving revision 1.52
diff -u -p -r1.52 sound.h
--- pcm/sound.h	7 Sep 2003 16:28:03 -0000	1.52
+++ pcm/sound.h	1 Dec 2003 14:13:25 -0000
@@ -237,7 +237,7 @@ void *pcm_getdevinfo(device_t dev);
 int snd_setup_intr(device_t dev, struct resource *res, int flags,
 		   driver_intr_t hand, void *param, void **cookiep);
 
-void *snd_mtxcreate(const char *desc, const char *type);
+void *snd_mtxcreate(const char *desc, const char *type, int opts);
 void snd_mtxfree(void *m);
 void snd_mtxassert(void *m);
 #define	snd_mtxlock(m) mtx_lock(m)

--/WwmFnJnmDyWGHa4--



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