From: Takashi Iwai Subject: Re: [PATCH] alsa-driver: Support for ESI Miditerminal 4140 (#3) Date: Tue, 02 May 2006 13:48:59 +0200 Message-ID: References: <87r73c4ryj.fsf@zebra.localdomain> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <87r73c4ryj.fsf@zebra.localdomain> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Matthias Koenig Cc: alsa-devel@lists.sourceforge.net, Jaroslav Kysela , Lee Revell List-Id: alsa-devel@alsa-project.org At Tue, 02 May 2006 12:54:44 +0200, Matthias Koenig wrote: > > Some locking has been added to the get/put callbacks > of the control elements as "Writing an ALSA driver" states that > these are non atomic. In most cases a spin_lock should be adequate > because the accessed members of the protected structure are not > accessed in the IRQ handler. The problem is not the member field to be accessed but just a spinlock. mts->lock is still held in snd_mts64_interrupt(), so a spin_lock() would cause a deadlock. You should use spin_lock_irq() in get/put callbacks. Otherwise, only a couple of minor glitches as below: > --- a/drivers/Makefile Fri Apr 21 12:40:49 2006 +0200 > +++ b/drivers/Makefile Tue May 02 12:48:12 2006 +0200 > @@ -10,12 +10,13 @@ snd-serialmidi-objs := serialmidi.o > snd-serialmidi-objs := serialmidi.o > snd-aloop-objs := aloop.o > snd-portman2x4-objs := portman2x4.o > +snd-mts64-objs := mts64.o > > obj-$(CONFIG_SND) += pcsp/ > > obj-$(CONFIG_SND_SERIALMIDI) += snd-serialmidi.o > obj-$(CONFIG_SND_LOOPBACK) += snd-aloop.o > -obj-$(CONFIG_SND_PORTMAN2X4) += snd-portman2x4.o I guess it's not intentional? > +obj-$(CONFIG_SND_MTS64) += snd-mts64.o > +static int __devinit snd_mts64_ctl_create(struct snd_card *card, > + struct mts64 *mts) > +{ > + int err, i; > + struct snd_kcontrol_new *control[] = { Make it static. > +static int __devinit snd_mts64_probe(struct platform_device *pdev) (snip) > + pardev = parport_register_device(p, /* port */ > + DRIVER_NAME, /* name */ > + NULL, /* preempt */ > + NULL, /* wakeup */ > + snd_mts64_interrupt, /* ISR */ > + PARPORT_DEV_EXCL, /* flags */ > + (void *)card); /* private */ > + if (pardev == NULL) { > + snd_printd("Cannot register pardevice\n"); > + err = -EIO; > + goto __err; This error path is problematic, unfortunately, because card->private_data isn't initialized yet. So, don't set card->private_free yet to avoid the access to mts and mts->pardev. > + } > + > + if ((err = snd_mts64_create(card, pardev, &mts)) < 0) { > + snd_printd("Cannot create main component\n"); Release pardev manually here (since private_free doesn't work)... > + goto __err; > + } > + card->private_data = mts; ... and set card->private_free here. Thanks, Takashi ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642