[PATCH RFC 1/3] ASoC: re-introduce disable_route_checks flag for OF routes

Laurentiu Mihalcea posted 3 patches 7 months, 1 week ago
[PATCH RFC 1/3] ASoC: re-introduce disable_route_checks flag for OF routes
Posted by Laurentiu Mihalcea 7 months, 1 week ago
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

The "disable_route_checks" flag was previously removed via commit
dd2395162c07 ("ASoC: remove disable_route_checks") as it wasn't being
used anywhere.

Re-introduce an OF-specific variant of the flag: "disable_of_route_checks"
as this will be used by audio-graph-card2.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
 include/sound/soc.h  |  1 +
 sound/soc/soc-core.c | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1fffef311c41..e76da038557d 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1077,6 +1077,7 @@ struct snd_soc_card {
 	unsigned int instantiated:1;
 	unsigned int topology_shortname_created:1;
 	unsigned int fully_routed:1;
+	unsigned int disable_of_route_checks:1;
 	unsigned int probed:1;
 	unsigned int component_chaining:1;
 	struct device *devres_dev;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 67bebc339148..b14a52d6f550 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2245,8 +2245,16 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
 
 	ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
 				      card->num_of_dapm_routes);
-	if (ret < 0)
-		goto probe_end;
+	if (ret < 0) {
+		if (card->disable_of_route_checks) {
+			ret = 0;
+			dev_info(card->dev,
+				 "%s: disable_of_route_checks set, ignoring errors on add_routes\n",
+				 __func__);
+		} else {
+			goto probe_end;
+		}
+	}
 
 	/* try to set some sane longname if DMI is available */
 	snd_soc_set_dmi_name(card);
-- 
2.34.1
Re: [PATCH RFC 1/3] ASoC: re-introduce disable_route_checks flag for OF routes
Posted by Kuninori Morimoto 7 months, 1 week ago
Hi Laurentiu

Thank you for the patch

> The "disable_route_checks" flag was previously removed via commit
> dd2395162c07 ("ASoC: remove disable_route_checks") as it wasn't being
> used anywhere.
> 
> Re-introduce an OF-specific variant of the flag: "disable_of_route_checks"
> as this will be used by audio-graph-card2.
> 
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> ---
>  include/sound/soc.h  |  1 +
>  sound/soc/soc-core.c | 12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 1fffef311c41..e76da038557d 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -1077,6 +1077,7 @@ struct snd_soc_card {
>  	unsigned int instantiated:1;
>  	unsigned int topology_shortname_created:1;
>  	unsigned int fully_routed:1;
> +	unsigned int disable_of_route_checks:1;
>  	unsigned int probed:1;
>  	unsigned int component_chaining:1;
>  	struct device *devres_dev;
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 67bebc339148..b14a52d6f550 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -2245,8 +2245,16 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
>  
>  	ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
>  				      card->num_of_dapm_routes);
> -	if (ret < 0)
> -		goto probe_end;
> +	if (ret < 0) {
> +		if (card->disable_of_route_checks) {
> +			ret = 0;
> +			dev_info(card->dev,
> +				 "%s: disable_of_route_checks set, ignoring errors on add_routes\n",
> +				 __func__);
> +		} else {
> +			goto probe_end;
> +		}
> +	}

commit dd2395162c07 removed flag from 3 parts (core x2 / topology), but
this patch get back only one of them.

I think this flag check should be implemented in snd_soc_dapm_add_route()
itself instead of each caller, but what do you think ?

And maybe we want to use more easy-to-understand naming, like
"ignore route check", etc ?

Thank you for your help !!

Best regards
---
Kuninori Morimoto
Re: [PATCH RFC 1/3] ASoC: re-introduce disable_route_checks flag for OF routes
Posted by Mihalcea Laurentiu 7 months, 1 week ago
On 16.05.2025 04:22, Kuninori Morimoto wrote:
> Hi Laurentiu
>
> Thank you for the patch
>
>> The "disable_route_checks" flag was previously removed via commit
>> dd2395162c07 ("ASoC: remove disable_route_checks") as it wasn't being
>> used anywhere.
>>
>> Re-introduce an OF-specific variant of the flag: "disable_of_route_checks"
>> as this will be used by audio-graph-card2.
>>
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>> ---
>>  include/sound/soc.h  |  1 +
>>  sound/soc/soc-core.c | 12 ++++++++++--
>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/sound/soc.h b/include/sound/soc.h
>> index 1fffef311c41..e76da038557d 100644
>> --- a/include/sound/soc.h
>> +++ b/include/sound/soc.h
>> @@ -1077,6 +1077,7 @@ struct snd_soc_card {
>>  	unsigned int instantiated:1;
>>  	unsigned int topology_shortname_created:1;
>>  	unsigned int fully_routed:1;
>> +	unsigned int disable_of_route_checks:1;
>>  	unsigned int probed:1;
>>  	unsigned int component_chaining:1;
>>  	struct device *devres_dev;
>> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
>> index 67bebc339148..b14a52d6f550 100644
>> --- a/sound/soc/soc-core.c
>> +++ b/sound/soc/soc-core.c
>> @@ -2245,8 +2245,16 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
>>  
>>  	ret = snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
>>  				      card->num_of_dapm_routes);
>> -	if (ret < 0)
>> -		goto probe_end;
>> +	if (ret < 0) {
>> +		if (card->disable_of_route_checks) {
>> +			ret = 0;
>> +			dev_info(card->dev,
>> +				 "%s: disable_of_route_checks set, ignoring errors on add_routes\n",
>> +				 __func__);
>> +		} else {
>> +			goto probe_end;
>> +		}
>> +	}
> commit dd2395162c07 removed flag from 3 parts (core x2 / topology), but
> this patch get back only one of them.


hm, so the rationale for introducing this OF-specific flag was because

audio-graph-card2 is the only user for this feature and this user only

needs to disable route checks for OF-based routes. On second thought

though I think it might be better to have this feature for all routes in case

someone might need it for non-OF routes as well? (if we go with the current

approach and it turns out someone needs it for non-OF routes you're going

to need more changes to support that)


>
> I think this flag check should be implemented in snd_soc_dapm_add_route()
> itself instead of each caller, but what do you think ?


good idea, I'll give it a try


>
> And maybe we want to use more easy-to-understand naming, like
> "ignore route check", etc ?


sure


>
> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto