Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: broonie@kernel.org, Cezary Rojewski <cezary.rojewski@intel.com>
Cc: tiwai@suse.com, perex@perex.cz, amade@asmblr.net,
	kuninori.morimoto.gx@renesas.com, linux-sound@vger.kernel.org,
	Cezary Rojewski <cezary.rojewski@intel.com>
Subject: Re: [PATCH] ASoC: core: Move all users to deferrable card binding
Date: Wed, 20 May 2026 11:55:39 +0200	[thread overview]
Message-ID: <3045975.e9J7NaK4W3@steina-w> (raw)
In-Reply-To: <20260430140752.766130-1-cezary.rojewski@intel.com>

Hi,

Am Donnerstag, 30. April 2026, 16:07:52 CEST schrieb Cezary Rojewski:
> 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().
> 
> Suggested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>

This showed up in linux-next and causes a regression on my imx8mp-based
platform (imx8mp-tqma8mpql-mba8mpxl.dts). 

On 7.1.0-rc3-00101-g56ba969925ac eveythings works as expected and sound
cards are registered.

On 7.1.0-rc3-00102-g42d99857d6f0 I'm getting these messages/errors:

fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
tlv320aic32x4 1-0018: ASoC error (-22): at snd_soc_dai_set_sysclk() on tlv320aic32x4-hifi
fsl-asoc-card sound: failed to set sysclk in fsl_asoc_card_late_probe
fsl-asoc-card sound: ASoC error (-22): at snd_soc_card_late_probe() on tqm-tlv320aic32

The clock tree looks like this:
audio_pll1_ref_sel               0       0        0        24000000
   audio_pll1                    0       0        0        393216000
      audio_pll1_bypass          0       0        0        393216000
         audio_pll1_out          0       0        0        393216000
            sai3                 0       0        0        12288000
               sai3_mclk1_sel    0       0        0        12288000
                  sai3_mclk1_cg  0       0        0        12288000
                     pll         0       0        0        49152000
                        codec_clkin 0       0        0        49152000
                           nadc  0       0        0        49152000
                              madc 0       0        0        49152000
                           ndac  0       0        0        49152000
                              mdac 0       0        0        49152000
                                 bdiv 0       0        0        49152000

Adding some debug output the offending call is
tlv320aic32x4 1-0018: set sai3_mclk1_cg to freq: 24000000

Apparently this was not happening before.

best regards,
Alexander
> ---
> 
> 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
>  
> 


-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



  parent reply	other threads:[~2026-05-20  9:55 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 [this message]
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
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=3045975.e9J7NaK4W3@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=amade@asmblr.net \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox