Skip to contentSkip to conversation

ASoC: remove a card from the list, if instantiation failed

PATCH Superseded Guennadi Liakhovetski 2 participants 4 messages Mar 17, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: remove a card from the list, if instantiation failed

If instantiation of a card failed, we have to remove it from the card list. This fixes an Oops on Migo-R, triggering, when after a failed firmware load attempt the driver modules are removed and re-inserted again.

---

Should also be good for stable.

sound/soc/soc-core.c +2 -0
index c8b0556..307eea0 100644
@@ -2361,6 +2361,8 @@ static int snd_soc_register_card(struct snd_soc_card *card)
 	mutex_lock(&client_mutex);
 	list_add(&card->list, &card_list);
 	snd_soc_instantiate_cards();
+	if (!card->instantiated)
+		list_del(&card->list);
 	mutex_unlock(&client_mutex);
 
 	dev_dbg(card->dev, "Registered card '%s'\n", card->name);
#1 lore raw
Quoted 4 lines · Guennadi Liakhovetski

If instantiation of a card failed, we have to remove it from the card list. This fixes an Oops on Migo-R, triggering, when after a failed firmware load attempt the driver modules are removed and re-inserted again.

This looks like the wrong fix - if the card failed to instantiate because the component drivers weren't ready then it ought to hang around so it can be instantiated once they appear. Presumably some part of the instantiation attempt is failing and not being unwound properly?

Quoted 19 lines

---

Should also be good for stable.

sound/soc/soc-core.c +2 -0
index c8b0556..307eea0 100644
@@ -2361,6 +2361,8 @@ static int snd_soc_register_card(struct  
 snd_soc_card *card)
   mutex_lock(&client_mutex);
   list_add(&card->list, &card_list);
   snd_soc_instantiate_cards();
+    if (!card->instantiated)
+        list_del(&card->list);
   mutex_unlock(&client_mutex);
 
   dev_dbg(card->dev, "Registered card '%s'\n", card->name);
#2 lore raw
Quoted 11 lines · Mark Brown
Quoted 4 lines · Guennadi Liakhovetski

If instantiation of a card failed, we have to remove it from the card list. This fixes an Oops on Migo-R, triggering, when after a failed firmware load attempt the driver modules are removed and re-inserted again.

This looks like the wrong fix - if the card failed to instantiate because the component drivers weren't ready then it ought to hang around so it can be instantiated once they appear. Presumably some part of the instantiation attempt is failing and not being unwound properly?

If snd_soc_instantiate_card() fails, when called from snd_soc_register_card(), the card currently stays on the list, but the instantiated flag is not set. If you then unload drivers and unregister the soc-audio platform device, snd_soc_unregister_card() is called, but since instantiated is not set, nothing is done and the card stays on the list. What's the proper unwind way in such a case then?

Thanks
Guennadi

Quoted 19 lines
Quoted 19 lines

---

Should also be good for stable.

sound/soc/soc-core.c +2 -0
index c8b0556..307eea0 100644
@@ -2361,6 +2361,8 @@ static int snd_soc_register_card(struct snd_soc_card
 *card)
  mutex_lock(&client_mutex);
  list_add(&card->list, &card_list);
  snd_soc_instantiate_cards();
+    if (!card->instantiated)
+        list_del(&card->list);
  mutex_unlock(&client_mutex);
 
Quoted 1 line
Quoted 1 line
  dev_dbg(card->dev, "Registered card '%s'\n", card->name);

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

#3 lore raw
Quoted 19 lines · Guennadi Liakhovetski
Quoted 9 lines · Mark Brown

On 17 Mar 2010, at 21:06, Guennadi Liakhovetski <[email protected]

Quoted 7 lines

wrote:

If instantiation of a card failed, we have to remove it from the card
list. This fixes an Oops on Migo-R, triggering, when after a failed firmware load attempt the driver modules are removed and re-inserted again.

Quoted 7 lines

This looks like the wrong fix - if the card failed to instantiate because the
component drivers weren't ready then it ought to hang around so it can be
instantiated once they appear. Presumably some part of the instantiation
attempt is failing and not being unwound properly?

Quoted 9 lines

If snd_soc_instantiate_card() fails, when called from snd_soc_register_card(), the card currently stays on the list, but the instantiated flag is not set. If you then unload drivers and unregister
the soc-audio platform device, snd_soc_unregister_card() is called, but
since instantiated is not set, nothing is done and the card stays on the
list. What's the proper unwind way in such a case then?

The card should be removed on unregistration either way.

Quoted 30 lines

Thanks
Guennadi

Quoted 20 lines
Quoted 20 lines

---

Should also be good for stable.

sound/soc/soc-core.c +0 -0
index c8b0556..307eea0 100644
@@ -2361,6 +2361,8 @@ static int snd_soc_register_card(struct  

snd_soc_card
*card)
mutex_lock(&client_mutex);
list_add(&card->list, &card_list);
snd_soc_instantiate_cards();

sound/soc/soc-core.c +2 -0
+    if (!card->instantiated)
+        list_del(&card->list);
 mutex_unlock(&client_mutex);
Quoted 1 line
Quoted 1 line

dev_dbg(card->dev, "Registered card '%s'\n", card->name);

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/