All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Cezary Rojewski <cezary.rojewski@intel.com>, broonie@kernel.org
Cc: tiwai@suse.com, perex@perex.cz, amade@asmblr.net,
	kuninori.morimoto.gx@renesas.com, linux-sound@vger.kernel.org,
	"Liao, Bard" <bard.liao@intel.com>,
	"Vehmanen, Kai" <kai.vehmanen@intel.com>
Subject: Re: [PATCH] ASoC: core: Move all users to deferrable card binding
Date: Fri, 22 May 2026 13:16:10 +0300	[thread overview]
Message-ID: <01d1d642-bf24-4ef4-a30d-56884300407f@linux.intel.com> (raw)
In-Reply-To: <20260430140752.766130-1-cezary.rojewski@intel.com>

Hi Cezary,

On 30/04/2026 17:07, Cezary Rojewski wrote:
> Commit a3375522bb5e2 ("ASoC: core: Complete support for card rebinding")
> completed the feature and at the same time divided ASoC users into two
> groups:
> 
> 1) cards that fail to enumerate the moment one of the components is
>    not available
> 2) cards that succeed to enumerate even if some of their components
>    become available late
> 
> Given the component-based nature of ASoC, approach 2) is preferred and
> can be used by all ASoC users.  By dropping 1) the card binding code can
> also be simplified.
> 
> Flatten code that is currently conditional based on ->devres_dev and
> convert snd_soc_rebind_card() to call_soc_bind_card().  The latter is a
> selector between managed and unmanaged card-binding behaviour to keep
> non-devm users happy.
> 
> With rebinding being the default, devm_snd_soc_register_card() takes
> form of its deferrable friend - all the devm job is already done by
> devm_snd_soc_bind_card().

This patch showed up in sof-dev kernel after a recent upstream merge and
broke audio card probing on some devices.

There are no errors in kernel log, the card just does not form.
Reverting only this patch fixes the card binding.

The affected device have 2x sndw speaker amps, 	1x headset codec and 3x
HDMI PCMs.

It is likely that one of the codec's probe happens after the card
probed, the card is not created for some reason and nothing happens.

rmmod snd_soc_sof_sdw
modprobe snd_soc_sof_sdw

will create the card, so it is likely that going ahead without waiting
for all components can and might break audio on system boot.
> Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
> ---
> 
> This is a direct continuation of subject [1] begun by Kuninori with goal
> of simplifying the code related to card rebinding.
> 
> [1]: https://lore.kernel.org/linux-sound/87eck7k868.wl-kuninori.morimoto.gx@renesas.com/
> 
>  include/sound/soc.h    |  2 +-
>  sound/soc/soc-core.c   | 44 ++++++++++++++----------------------------
>  sound/soc/soc-devres.c | 28 +--------------------------
>  3 files changed, 17 insertions(+), 57 deletions(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index a30f95ff7d86..f0935523c8df 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -425,7 +425,7 @@ struct snd_soc_jack_pin;
>  int snd_soc_register_card(struct snd_soc_card *card);
>  void snd_soc_unregister_card(struct snd_soc_card *card);
>  int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
> -int devm_snd_soc_register_deferrable_card(struct device *dev, struct snd_soc_card *card);
> +#define devm_snd_soc_register_deferrable_card(d, c) devm_snd_soc_register_card(d, c)
>  #ifdef CONFIG_PM_SLEEP
>  int snd_soc_suspend(struct device *dev);
>  int snd_soc_resume(struct device *dev);
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index e70bf22db5c9..ec141b810b50 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2165,6 +2165,7 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
>  	snd_soc_fill_dummy_dai(card);
>  
>  	snd_soc_dapm_init(dapm, card, NULL);
> +	list_del_init(&card->list);
>  
>  	/* check whether any platform is ignore machine FE and using topology */
>  	soc_check_tplg_fes(card);
> @@ -2308,6 +2309,10 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
>  probe_end:
>  	if (ret < 0)
>  		soc_cleanup_card_resources(card);
> +	if (ret == -EPROBE_DEFER) {
> +		list_add(&card->list, &unbind_card_list);
> +		ret = 0;
> +	}
>  	snd_soc_card_mutex_unlock(card);
>  
>  	return ret;
> @@ -2323,12 +2328,15 @@ static int devm_snd_soc_bind_card(struct device *dev, struct snd_soc_card *card)
>  	struct snd_soc_card **ptr;
>  	int ret;
>  
> +	/* The procedure may be called many times during the lifetime of the card. */
> +	devres_destroy(dev, devm_card_bind_release, NULL, NULL);
> +
>  	ptr = devres_alloc(devm_card_bind_release, sizeof(*ptr), GFP_KERNEL);
>  	if (!ptr)
>  		return -ENOMEM;
>  
>  	ret = snd_soc_bind_card(card);
> -	if (ret == 0 || ret == -EPROBE_DEFER) {
> +	if (ret == 0) {
>  		*ptr = card;
>  		devres_add(dev, ptr);
>  	} else {
> @@ -2338,21 +2346,11 @@ static int devm_snd_soc_bind_card(struct device *dev, struct snd_soc_card *card)
>  	return ret;
>  }
>  
> -static int snd_soc_rebind_card(struct snd_soc_card *card)
> +static int call_soc_bind_card(struct snd_soc_card *card)
>  {
> -	int ret;
> -
> -	if (card->devres_dev) {
> -		devres_destroy(card->devres_dev, devm_card_bind_release, NULL, NULL);
> -		ret = devm_snd_soc_bind_card(card->devres_dev, card);
> -	} else {
> -		ret = snd_soc_bind_card(card);
> -	}
> -
> -	if (ret != -EPROBE_DEFER)
> -		list_del_init(&card->list);
> -
> -	return ret;
> +	if (card->devres_dev)
> +		return devm_snd_soc_bind_card(card->devres_dev, card);
> +	return snd_soc_bind_card(card);
>  }
>  
>  /* probes a new socdev */
> @@ -2550,8 +2548,6 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
>   */
>  int snd_soc_register_card(struct snd_soc_card *card)
>  {
> -	int ret;
> -
>  	if (!card->name || !card->dev)
>  		return -EINVAL;
>  
> @@ -2578,17 +2574,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
>  
>  	guard(mutex)(&client_mutex);
>  
> -	if (card->devres_dev) {
> -		ret = devm_snd_soc_bind_card(card->devres_dev, card);
> -		if (ret == -EPROBE_DEFER) {
> -			list_add(&card->list, &unbind_card_list);
> -			ret = 0;
> -		}
> -	} else {
> -		ret = snd_soc_bind_card(card);
> -	}
> -
> -	return ret;
> +	return call_soc_bind_card(card);
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_register_card);
>  
> @@ -2909,7 +2895,7 @@ int snd_soc_add_component(struct snd_soc_component *component,
>  	list_add(&component->list, &component_list);
>  
>  	list_for_each_entry_safe(card, c, &unbind_card_list, list)
> -		snd_soc_rebind_card(card);
> +		call_soc_bind_card(card);
>  
>  err_cleanup:
>  	if (ret < 0)
> diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
> index d33f83ec24f2..718165ba84ac 100644
> --- a/sound/soc/soc-devres.c
> +++ b/sound/soc/soc-devres.c
> @@ -49,11 +49,6 @@ int devm_snd_soc_register_component(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
>  
> -static void devm_card_release(struct device *dev, void *res)
> -{
> -	snd_soc_unregister_card(*(struct snd_soc_card **)res);
> -}
> -
>  /**
>   * devm_snd_soc_register_card - resource managed card registration
>   * @dev: Device used to manage card
> @@ -63,32 +58,11 @@ static void devm_card_release(struct device *dev, void *res)
>   * unregistered.
>   */
>  int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
> -{
> -	struct snd_soc_card **ptr;
> -	int ret;
> -
> -	ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL);
> -	if (!ptr)
> -		return -ENOMEM;
> -
> -	ret = snd_soc_register_card(card);
> -	if (ret == 0) {
> -		*ptr = card;
> -		devres_add(dev, ptr);
> -	} else {
> -		devres_free(ptr);
> -	}
> -
> -	return ret;
> -}
> -EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
> -
> -int devm_snd_soc_register_deferrable_card(struct device *dev, struct snd_soc_card *card)
>  {
>  	card->devres_dev = dev;
>  	return snd_soc_register_card(card);
>  }
> -EXPORT_SYMBOL_GPL(devm_snd_soc_register_deferrable_card);
> +EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
>  
>  #ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
>  

-- 
Péter


  parent reply	other threads:[~2026-05-22 10:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 14:07 [PATCH] ASoC: core: Move all users to deferrable card binding Cezary Rojewski
2026-05-11  1:06 ` Mark Brown
2026-05-11  1:34 ` Kuninori Morimoto
2026-05-12  8:14   ` Rojewski, Cezary
2026-05-20  9:55 ` Alexander Stein
2026-05-20 10:33   ` Cezary Rojewski
2026-05-21  6:42     ` Alexander Stein
2026-05-21  8:13       ` Cezary Rojewski
2026-05-21 10:11         ` Alexander Stein
2026-05-21 14:41           ` Cezary Rojewski
2026-05-21 14:47             ` Alexander Stein
2026-05-22 11:21             ` Alexander Stein
2026-05-22 10:16 ` Péter Ujfalusi [this message]
2026-05-22 14:32   ` Cezary Rojewski
2026-05-22 14:58     ` Mark Brown
2026-05-22 15:08       ` Cezary Rojewski
2026-05-25 12:48       ` Péter Ujfalusi
2026-05-25 15:06         ` Mark Brown
2026-05-26  5:45           ` Péter Ujfalusi
2026-05-26 11:21             ` Péter Ujfalusi
2026-05-26 11:28               ` Péter Ujfalusi
2026-05-26 16:02             ` Mark Brown
2026-05-27  5:22               ` Péter Ujfalusi
2026-05-27 10:35                 ` Mark Brown
2026-05-25 10:44     ` Pierre-Louis Bossart
2026-05-25 21:10       ` Cezary Rojewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=01d1d642-bf24-4ef4-a30d-56884300407f@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=amade@asmblr.net \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=kai.vehmanen@intel.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.