All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97"
@ 2009-03-16 14:26 Atsushi Nemoto
  2009-03-16 14:32 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Atsushi Nemoto @ 2009-03-16 14:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: Manuel Lauss, Takashi Iwai, linux-kernel

The commit 14fa43f53ff3a9c3d8b9662574b7369812a31a97 ("ASoC: Only
register AC97 bus if it's not done already") added a condition for
calling of soc_ac97_dev_register() but not added for calling of
soc_ac97_dev_unregister().  This patch adds same condition for
soc_ac97_dev_unregister().  Without this fix, kernel crashes when
unloading an asoc driver.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
I found this problem when I start debugging a new asoc driver.  While
the driver is in very early stage, it should lack many things and have
many bugs.  So I'm not sure this is asoc's bug or my driver's bug.

 sound/soc/soc-core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ec3f8bb..fec57a3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1435,7 +1435,8 @@ void snd_soc_free_pcms(struct snd_soc_device *socdev)
 #ifdef CONFIG_SND_SOC_AC97_BUS
 	for (i = 0; i < codec->num_dai; i++) {
 		codec_dai = &codec->dai[i];
-		if (codec_dai->ac97_control && codec->ac97) {
+		if (codec_dai->ac97_control && codec->ac97 &&
+		    strcmp(codec->name, "AC97") != 0) {
 			soc_ac97_dev_unregister(codec);
 			goto free_card;
 		}
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97"
  2009-03-16 14:26 [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97" Atsushi Nemoto
@ 2009-03-16 14:32 ` Takashi Iwai
  2009-03-16 15:00   ` Atsushi Nemoto
  2009-03-16 16:01   ` Mark Brown
  0 siblings, 2 replies; 6+ messages in thread
From: Takashi Iwai @ 2009-03-16 14:32 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: Mark Brown, Manuel Lauss, linux-kernel

At Mon, 16 Mar 2009 23:26:20 +0900 (JST),
Atsushi Nemoto wrote:
> 
> The commit 14fa43f53ff3a9c3d8b9662574b7369812a31a97 ("ASoC: Only
> register AC97 bus if it's not done already") added a condition for
> calling of soc_ac97_dev_register() but not added for calling of
> soc_ac97_dev_unregister().  This patch adds same condition for
> soc_ac97_dev_unregister().  Without this fix, kernel crashes when
> unloading an asoc driver.

Hm, codec->ac97->dev.bus should be NULL unless it's registered,
so calling soc_ac97_dev_unregister() should be harmless...

Maybe I miss something?


thanks,

Takashi


> 
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
> I found this problem when I start debugging a new asoc driver.  While
> the driver is in very early stage, it should lack many things and have
> many bugs.  So I'm not sure this is asoc's bug or my driver's bug.
> 
>  sound/soc/soc-core.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index ec3f8bb..fec57a3 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1435,7 +1435,8 @@ void snd_soc_free_pcms(struct snd_soc_device *socdev)
>  #ifdef CONFIG_SND_SOC_AC97_BUS
>  	for (i = 0; i < codec->num_dai; i++) {
>  		codec_dai = &codec->dai[i];
> -		if (codec_dai->ac97_control && codec->ac97) {
> +		if (codec_dai->ac97_control && codec->ac97 &&
> +		    strcmp(codec->name, "AC97") != 0) {
>  			soc_ac97_dev_unregister(codec);
>  			goto free_card;
>  		}
> -- 
> 1.5.6.3
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97"
  2009-03-16 14:32 ` Takashi Iwai
@ 2009-03-16 15:00   ` Atsushi Nemoto
  2009-03-16 16:01   ` Mark Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Atsushi Nemoto @ 2009-03-16 15:00 UTC (permalink / raw)
  To: tiwai; +Cc: broonie, mano, linux-kernel

On Mon, 16 Mar 2009 15:32:50 +0100, Takashi Iwai <tiwai@suse.de> wrote:
> > The commit 14fa43f53ff3a9c3d8b9662574b7369812a31a97 ("ASoC: Only
> > register AC97 bus if it's not done already") added a condition for
> > calling of soc_ac97_dev_register() but not added for calling of
> > soc_ac97_dev_unregister().  This patch adds same condition for
> > soc_ac97_dev_unregister().  Without this fix, kernel crashes when
> > unloading an asoc driver.
> 
> Hm, codec->ac97->dev.bus should be NULL unless it's registered,
> so calling soc_ac97_dev_unregister() should be harmless...
> 
> Maybe I miss something?

Well, ac97_codec.c:snd_ac97_dev_register() was called on loading my
asoc driver.  I thought it was called from somewhere during
ac97_soc_probe(), but not sure...

The crash happened in sysfs_remove_group() and
snd_ac97_dev_disconnect() was on callstack.

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97"
  2009-03-16 14:32 ` Takashi Iwai
  2009-03-16 15:00   ` Atsushi Nemoto
@ 2009-03-16 16:01   ` Mark Brown
  2009-03-17  1:18     ` Atsushi Nemoto
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2009-03-16 16:01 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Atsushi Nemoto, Manuel Lauss, linux-kernel

On Mon, Mar 16, 2009 at 03:32:50PM +0100, Takashi Iwai wrote:

> Hm, codec->ac97->dev.bus should be NULL unless it's registered,
> so calling soc_ac97_dev_unregister() should be harmless...

Atsushi, are you using ac97.c as your codec driver?  Could you please
post the actual backtrace you're seeing?

> Maybe I miss something?

There's some fun and games here due to ac97.c which provides the ability
to use the standard ALSA AC97 functionality as a codec driver (that's
why there's the check on init) - I suspect there may be a double free.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97"
  2009-03-16 16:01   ` Mark Brown
@ 2009-03-17  1:18     ` Atsushi Nemoto
  2009-03-17 13:58       ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Atsushi Nemoto @ 2009-03-17  1:18 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, mano, linux-kernel

On Mon, 16 Mar 2009 16:01:37 +0000, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> > Hm, codec->ac97->dev.bus should be NULL unless it's registered,
> > so calling soc_ac97_dev_unregister() should be harmless...
> 
> Atsushi, are you using ac97.c as your codec driver?  Could you please
> post the actual backtrace you're seeing?

Yes.  I'm using ac97.c and here is the backtrace.  The first argument
of sysfs_get_dirent (dir_sd) was NULL.  The bottom
platform_device_unregister call is for "soc-audio" device.

[<801fac24>] sysfs_get_dirent+0x24/0xd0
[<801fcb60>] sysfs_remove_group+0x34/0x144
[<802cd3b0>] device_del+0x48/0x178
[<802cd4f4>] device_unregister+0x14/0x28
[<c01afa88>] snd_ac97_dev_disconnect+0x24/0x34 [snd_ac97_codec]
[<c00d1b4c>] snd_device_disconnect+0x48/0x9c [snd]
[<c00d1be0>] snd_device_disconnect_all+0x40/0x80 [snd]
[<c00ccc30>] snd_card_disconnect+0x25c/0x2e0 [snd]
[<c00ccce4>] snd_card_free+0x30/0xf0 [snd]
[<c014c68c>] snd_soc_free_pcms+0xcc/0x110 [snd_soc_core]
[<c01ce0ec>] ac97_soc_remove+0x2c/0x60 [snd_soc_ac97]
[<c014b8b8>] soc_remove+0x64/0x128 [snd_soc_core]
[<802cfad8>] __device_release_driver+0x80/0xb8
[<802cfc40>] device_release_driver+0x28/0x40
[<802cef34>] bus_remove_device+0xc0/0x100
[<802cd490>] device_del+0x128/0x178
[<802d13d4>] platform_device_del+0x2c/0x9c
[<802d1944>] platform_device_unregister+0x14/0x28

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97"
  2009-03-17  1:18     ` Atsushi Nemoto
@ 2009-03-17 13:58       ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2009-03-17 13:58 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: tiwai, mano, linux-kernel

On Tue, Mar 17, 2009 at 10:18:38AM +0900, Atsushi Nemoto wrote:

> Yes.  I'm using ac97.c and here is the backtrace.  The first argument
> of sysfs_get_dirent (dir_sd) was NULL.  The bottom
> platform_device_unregister call is for "soc-audio" device.

OK, I've confirmed the problem and applied your patch - thanks.  The
issue is that the standard AC97 support doesn't play too nicely with
ASoC so we need to jump through a couple of hoops to fit in with what
it's doing.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-17 13:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-16 14:26 [PATCH] ASoC: Only deregister AC97 dev if it's name was not "AC97" Atsushi Nemoto
2009-03-16 14:32 ` Takashi Iwai
2009-03-16 15:00   ` Atsushi Nemoto
2009-03-16 16:01   ` Mark Brown
2009-03-17  1:18     ` Atsushi Nemoto
2009-03-17 13:58       ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.