Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262288AbTKYKeL (ORCPT ); Tue, 25 Nov 2003 05:34:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262291AbTKYKeL (ORCPT ); Tue, 25 Nov 2003 05:34:11 -0500 Received: from ns.suse.de ([195.135.220.2]:33238 "EHLO Cantor.suse.de") by vger.kernel.org with ESMTP id S262288AbTKYKeE (ORCPT ); Tue, 25 Nov 2003 05:34:04 -0500 Date: Tue, 25 Nov 2003 11:33:59 +0100 Message-ID: From: Takashi Iwai To: Andrew Morton Cc: Torrey Hoffman , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: 2.6.-test10: bad "__might_sleep" in ALSA sound drivers In-Reply-To: <20031124180017.70d58566.akpm@osdl.org> References: <1069718546.2268.9.camel@moria.arnor.net> <20031124180017.70d58566.akpm@osdl.org> User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 MULE XEmacs/21.4 (patch 13) (Rational FORTRAN) (i386-suse-linux) MIME-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: multipart/mixed; boundary="Multipart_Tue_Nov_25_11:33:59_2003-1" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3303 Lines: 99 --Multipart_Tue_Nov_25_11:33:59_2003-1 Content-Type: text/plain; charset=US-ASCII Hi, At Mon, 24 Nov 2003 18:00:17 -0800, Andrew Morton wrote: > > Torrey Hoffman wrote: > > > > I get this every time I boot 2.6.0-test10. I think this problem has > > been around for a while. > > > > Debug: sleeping function called from invalid context at > > include/asm/semaphore.h:119 > > in_atomic():1, irqs_disabled():0 > > Call Trace: > > [] __might_sleep+0xab/0xc9 > > [] ap_cs8427_sendbytes+0x38/0xd2 [snd_ice1712] > > [] snd_i2c_sendbytes+0x22/0x26 [snd_i2c] > > [] snd_cs8427_reg_read+0x2c/0x8c [snd_cs8427] > > [] snd_cs8427_create+0xa4/0x347 [snd_cs8427] > > [] snd_device_new+0x20/0x6a > > [] snd_ice1712_init_cs8427+0x2f/0x6f [snd_ice1712] > > [] snd_ice1712_delta_init+0x230/0x2b9 [snd_ice1712] > > [] snd_ice1712_probe+0x323/0x34c [snd_ice1712] > > snd_cs8427_create() does: > > snd_i2c_lock(bus); > if ((err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER)) != CS8427_VER8427A) { > > the first statement takes a spinlock. snd_cs8427_reg_read() then calls > ap_cs8427_sendbytes() which downs a semaphore. > > > It might be more appropriate to use a semaphore for ice1712_t.gpio_mutex? the attached patch fixes this, simply replacing spinlock with mutex. it's already in ALSA 1.0.0pre release. -- Takashi Iwai ALSA Developer - www.alsa-project.org --Multipart_Tue_Nov_25_11:33:59_2003-1 Content-Type: text/plain; charset=US-ASCII diff -ru linux/include/sound linux/include/sound --- linux/include/sound/i2c.h 23 Apr 2002 13:20:58 -0000 1.3 +++ linux/include/sound/i2c.h 13 Nov 2003 11:18:12 -0000 1.4 @@ -58,7 +58,7 @@ snd_card_t *card; /* card which I2C belongs to */ char name[32]; /* some useful label */ - spinlock_t lock; + struct semaphore lock_mutex; snd_i2c_bus_t *master; /* master bus when SCK/SCL is shared */ struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */ @@ -84,15 +84,15 @@ static inline void snd_i2c_lock(snd_i2c_bus_t *bus) { if (bus->master) - spin_lock(&bus->master->lock); + down(&bus->master->lock_mutex); else - spin_lock(&bus->lock); + down(&bus->lock_mutex); } static inline void snd_i2c_unlock(snd_i2c_bus_t *bus) { if (bus->master) - spin_unlock(&bus->master->lock); + up(&bus->master->lock_mutex); else - spin_unlock(&bus->lock); + up(&bus->lock_mutex); } int snd_i2c_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); diff -ru linux/sound linux/sound --- linux/sound/i2c/i2c.c 2 Jun 2003 10:04:44 -0000 1.7 +++ linux/sound/i2c/i2c.c 13 Nov 2003 11:18:25 -0000 1.8 @@ -84,7 +84,7 @@ bus = (snd_i2c_bus_t *)snd_magic_kcalloc(snd_i2c_bus_t, 0, GFP_KERNEL); if (bus == NULL) return -ENOMEM; - spin_lock_init(&bus->lock); + init_MUTEX(&bus->lock_mutex); INIT_LIST_HEAD(&bus->devices); INIT_LIST_HEAD(&bus->buses); bus->card = card; --Multipart_Tue_Nov_25_11:33:59_2003-1-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/