public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets
@ 2026-04-15  8:19 Chancel Liu
  2026-04-15  8:19 ` [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts Chancel Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Chancel Liu @ 2026-04-15  8:19 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, Frank.Li, s.hauer, kernel, shumingf,
	rander.wang, pierre-louis.bossart, linux-sound, linux-kernel,
	linuxppc-dev, imx, linux-arm-kernel

Some audio systems require specific DAPM widgets to remain powered
during system suspend. Introduce a generic and reusable mechanism in
the ASoC core to mark selected DAPM widgets as ignore_suspend.

The unified mechanism consists of two parts:
1. Parse and store the name list of widgets to ignore suspend in
struct snd_soc_card

The list of widgets can be provided either by the machine driver or
parsed from Device Tree. Different machines have different routing and
power requirements. Each machine can specify its own widgets to ignore
suspend through DT property. It enables flexible policy without hard
code. A new helper, snd_soc_of_parse_ignore_suspend_widgets() is added
for this purpose.

2. Apply ignore_suspend flags during snd_soc_bind_card()

After all components have been probed and all DAPM widgets have been
registered, snd_soc_bind_card() performs a unified lookup of the
configured widget names across all DAPM contexts of the card and marks
the matching widgets with ignore_suspend = 1.

Switch to use core ignore-suspend-widgets support for imx-rpmsg driver.

This v2 series is a rework of the previous "[PATCH] ASoC: imx-rpmsg:
Fix ignore-suspend-widgets only applied to codec DAPM".
Changes in v2:
- Rework to use a unified core mechanism instead of machine driver
specific code

Chancel Liu (3):
  ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts
  ASoC: soc-core: Add core support for ignoring suspend on selected DAPM
    widgets
  ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support

 include/sound/soc-dapm.h  |  1 +
 include/sound/soc.h       |  5 +++++
 sound/soc/fsl/imx-rpmsg.c | 26 ++++++++---------------
 sound/soc/soc-core.c      | 43 +++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-dapm.c      | 43 ++++++++++++++++++++++++++++-----------
 5 files changed, 89 insertions(+), 29 deletions(-)

--
2.50.1



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

* [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts
  2026-04-15  8:19 [PATCH v2 0/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
@ 2026-04-15  8:19 ` Chancel Liu
  2026-04-17 11:03   ` Frank Li
  2026-04-15  8:19 ` [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
  2026-04-15  8:19 ` [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support Chancel Liu
  2 siblings, 1 reply; 10+ messages in thread
From: Chancel Liu @ 2026-04-15  8:19 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, Frank.Li, s.hauer, kernel, shumingf,
	rander.wang, pierre-louis.bossart, linux-sound, linux-kernel,
	linuxppc-dev, imx, linux-arm-kernel

Currently dapm_find_widget() manually constructs a prefixed widget name
based on the provided DAPM context and compares it using strcmp(). This
happens to work in most cases because callers usually know which DAPM
context the target widget belongs to and pass in the matching DAPM
context.

However, this assumption breaks when search_other_contexts is enabled.
In such cases, callers may intentionally pass a different DAPM context,
while searching for a widget that actually belongs to another DAPM
context.

For example, when searching for a "DAC" widget, the widget belongs to
the codec DAPM and be registered with a codec prefix, while the caller
passes card->dapm and intends to search across all DAPM contexts. The
current implementation incorrectly applies the caller card DAPM causing
the lookup to fail even though the widget exists on the card.

Use snd_soc_dapm_widget_name_cmp() instead, which compares widget names
using the widget's own DAPM context and prefix. It fixes widget lookup
failures when searching across different DAPM contexts on the card.

Fixes: ae4fc532244b ("ASoC: dapm: use component prefix when checking widget names")
Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
Assisted-by: Cody:Claude-3.5-Sonnet
---
 sound/soc/soc-dapm.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d6192204e613..c5b80d9ed64b 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2906,20 +2906,9 @@ static struct snd_soc_dapm_widget *dapm_find_widget(
 {
 	struct snd_soc_dapm_widget *w;
 	struct snd_soc_dapm_widget *fallback = NULL;
-	char prefixed_pin[80];
-	const char *pin_name;
-	const char *prefix = dapm_prefix(dapm);
-
-	if (prefix) {
-		snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
-			 prefix, pin);
-		pin_name = prefixed_pin;
-	} else {
-		pin_name = pin;
-	}
 
 	for_each_card_widgets(dapm->card, w) {
-		if (!strcmp(w->name, pin_name)) {
+		if (!snd_soc_dapm_widget_name_cmp(w, pin)) {
 			if (w->dapm == dapm)
 				return w;
 			else
-- 
2.50.1



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

* [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets
  2026-04-15  8:19 [PATCH v2 0/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
  2026-04-15  8:19 ` [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts Chancel Liu
@ 2026-04-15  8:19 ` Chancel Liu
  2026-04-17 11:14   ` Frank Li
  2026-04-15  8:19 ` [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support Chancel Liu
  2 siblings, 1 reply; 10+ messages in thread
From: Chancel Liu @ 2026-04-15  8:19 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, Frank.Li, s.hauer, kernel, shumingf,
	rander.wang, pierre-louis.bossart, linux-sound, linux-kernel,
	linuxppc-dev, imx, linux-arm-kernel

Some audio systems require specific DAPM widgets to remain powered
during system suspend. Introduce a generic and reusable mechanism in
the ASoC core to mark selected DAPM widgets as ignore_suspend.

The unified mechanism consists of two parts:
1. Parse and store the name list of widgets to ignore suspend in
struct snd_soc_card

The list of widgets can be provided either by the machine driver or
parsed from Device Tree. Different machines have different routing and
power requirements. Each machine can specify its own widgets to ignore
suspend through DT property. It enables flexible policy without hard
code. A new helper, snd_soc_of_parse_ignore_suspend_widgets() is added
for this purpose.

2. Apply ignore_suspend flags during snd_soc_bind_card()

After all components have been probed and all DAPM widgets have been
registered, snd_soc_bind_card() performs a unified lookup of the
configured widget names across all DAPM contexts of the card and marks
the matching widgets with ignore_suspend = 1.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 include/sound/soc-dapm.h |  1 +
 include/sound/soc.h      |  5 +++++
 sound/soc/soc-core.c     | 43 ++++++++++++++++++++++++++++++++++++++++
 sound/soc/soc-dapm.c     | 30 ++++++++++++++++++++++++++++
 4 files changed, 79 insertions(+)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 4f8fb7622a13..39c290e0eb7f 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -636,6 +636,7 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, struct snd_s
 void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w);
 int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
 void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
+int snd_soc_dapm_ignore_suspend_widgets(struct snd_soc_card *card);
 
 int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
 			    struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 5e3eb617d832..7d6fa79f48e3 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1057,10 +1057,14 @@ struct snd_soc_card {
 	int num_dapm_widgets;
 	const struct snd_soc_dapm_route *dapm_routes;
 	int num_dapm_routes;
+	const char **ignore_suspend_widgets;
+	int num_ignore_suspend_widgets;
 	const struct snd_soc_dapm_widget *of_dapm_widgets;
 	int num_of_dapm_widgets;
 	const struct snd_soc_dapm_route *of_dapm_routes;
 	int num_of_dapm_routes;
+	const char **of_ignore_suspend_widgets;
+	int num_of_ignore_suspend_widgets;
 
 	/* lists of probed devices belonging to this card */
 	struct list_head component_dev_list;
@@ -1339,6 +1343,7 @@ void snd_soc_of_parse_node_prefix(struct device_node *np,
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 				   const char *propname);
 int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname);
+int snd_soc_of_parse_ignore_suspend_widgets(struct snd_soc_card *card, const char *propname);
 
 unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt);
 unsigned int snd_soc_daifmt_clock_provider_from_bitmap(unsigned int bit_frame);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3fecf9fc903c..705181dae472 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2289,6 +2289,10 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
 	if (ret < 0)
 		goto probe_end;
 
+	ret = snd_soc_dapm_ignore_suspend_widgets(card);
+	if (ret < 0)
+		goto probe_end;
+
 	snd_soc_dapm_new_widgets(card);
 	snd_soc_card_fixup_controls(card);
 
@@ -3294,6 +3298,45 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
 
+int snd_soc_of_parse_ignore_suspend_widgets(struct snd_soc_card *card,
+					    const char *propname)
+{
+	struct device_node *np = card->dev->of_node;
+	int num_widgets;
+	const char **widgets;
+	int i;
+
+	num_widgets = of_property_count_strings(np, propname);
+	if (num_widgets < 0) {
+		dev_err(card->dev,
+			"ASoC: Property '%s' does not exist\n", propname);
+		return -EINVAL;
+	}
+
+	widgets = devm_kcalloc(card->dev, num_widgets, sizeof(char *), GFP_KERNEL);
+	if (!widgets)
+		return -ENOMEM;
+
+	for (i = 0; i < num_widgets; i++) {
+		const char *name;
+		int ret = of_property_read_string_index(np, propname, i, &name);
+
+		if (ret) {
+			dev_err(card->dev,
+				"ASoC: Property '%s' could not be read: %d\n",
+				propname, ret);
+			return -EINVAL;
+		}
+		widgets[i] = name;
+	}
+
+	card->num_of_ignore_suspend_widgets = num_widgets;
+	card->of_ignore_suspend_widgets = widgets;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_ignore_suspend_widgets);
+
 unsigned int snd_soc_daifmt_clock_provider_flipped(unsigned int dai_fmt)
 {
 	unsigned int inv_dai_fmt = dai_fmt & ~SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index c5b80d9ed64b..209f86b9add6 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -4595,6 +4595,36 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card)
 	}
 }
 
+int snd_soc_dapm_ignore_suspend_widgets(struct snd_soc_card *card)
+{
+	struct snd_soc_dapm_widget *w;
+	int i;
+
+	for (i = 0; i < card->num_ignore_suspend_widgets; i++) {
+		w = dapm_find_widget(snd_soc_card_to_dapm(card),
+				     card->ignore_suspend_widgets[i], true);
+		if (!w) {
+			dev_err(card->dev, "ASoC: DAPM unknown ignore suspend widget %s\n",
+				card->ignore_suspend_widgets[i]);
+			return -EINVAL;
+		}
+		w->ignore_suspend = 1;
+	}
+
+	for (i = 0; i < card->num_of_ignore_suspend_widgets; i++) {
+		w = dapm_find_widget(snd_soc_card_to_dapm(card),
+				     card->of_ignore_suspend_widgets[i], true);
+		if (!w) {
+			dev_err(card->dev, "ASoC: DAPM unknown ignore suspend widget %s\n",
+				card->of_ignore_suspend_widgets[i]);
+			return -EINVAL;
+		}
+		w->ignore_suspend = 1;
+	}
+
+	return 0;
+}
+
 static void dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, int event)
 {
 	struct snd_soc_dai *dai;
-- 
2.50.1



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

* [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support
  2026-04-15  8:19 [PATCH v2 0/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
  2026-04-15  8:19 ` [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts Chancel Liu
  2026-04-15  8:19 ` [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
@ 2026-04-15  8:19 ` Chancel Liu
  2026-04-28  8:48   ` Mark Brown
  2 siblings, 1 reply; 10+ messages in thread
From: Chancel Liu @ 2026-04-15  8:19 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, Frank.Li, s.hauer, kernel, shumingf,
	rander.wang, pierre-louis.bossart, linux-sound, linux-kernel,
	linuxppc-dev, imx, linux-arm-kernel

The imx-rpmsg machine driver currently implements its own logic to
parse ignore-suspend-widgets from Device Tree and manually traverse
DAPM widgets to mark them as ignore_suspend.

It also has a potential issue that some widgets listed in the property
(e.g. "Headphone Jack") belong to card or CPU DAI DAPM context.

Switch to use snd_soc_of_parse_ignore_suspend_widgets() with the
introduction of a generic ignore-suspend-widgets mechanism in the ASoC
core.

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/fsl/imx-rpmsg.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/sound/soc/fsl/imx-rpmsg.c b/sound/soc/fsl/imx-rpmsg.c
index 40e0043cfe15..15b0733f1524 100644
--- a/sound/soc/fsl/imx-rpmsg.c
+++ b/sound/soc/fsl/imx-rpmsg.c
@@ -87,7 +87,6 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
 	int ret;
 
 	if (data->lpa) {
-		struct snd_soc_component *codec_comp;
 		struct device_node *codec_np;
 		struct device_driver *codec_drv;
 		struct device *codec_dev = NULL;
@@ -107,22 +106,6 @@ static int imx_rpmsg_late_probe(struct snd_soc_card *card)
 			}
 		}
 		if (codec_dev) {
-			codec_comp = snd_soc_lookup_component_nolocked(codec_dev, NULL);
-			if (codec_comp) {
-				int i, num_widgets;
-				const char *widgets;
-				struct snd_soc_dapm_context *dapm;
-
-				num_widgets = of_property_count_strings(data->card.dev->of_node,
-									"ignore-suspend-widgets");
-				for (i = 0; i < num_widgets; i++) {
-					of_property_read_string_index(data->card.dev->of_node,
-								      "ignore-suspend-widgets",
-								      i, &widgets);
-					dapm = snd_soc_component_to_dapm(codec_comp);
-					snd_soc_dapm_ignore_suspend(dapm, widgets);
-				}
-			}
 			codec_drv = codec_dev->driver;
 			if (codec_drv->pm) {
 				memcpy(&lpa_pm, codec_drv->pm, sizeof(lpa_pm));
@@ -274,6 +257,15 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
 		}
 	}
 
+	if (data->lpa && of_property_present(np, "ignore-suspend-widgets")) {
+		ret = snd_soc_of_parse_ignore_suspend_widgets(&data->card,
+							      "ignore-suspend-widgets");
+		if (ret) {
+			dev_err(&pdev->dev, "failed to parse ignore-suspend-widgets: %d\n", ret);
+			return ret;
+		}
+	}
+
 	platform_set_drvdata(pdev, &data->card);
 	snd_soc_card_set_drvdata(&data->card, data);
 	ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
-- 
2.50.1



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

* Re: [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts
  2026-04-15  8:19 ` [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts Chancel Liu
@ 2026-04-17 11:03   ` Frank Li
  2026-04-23  3:03     ` Chancel Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Li @ 2026-04-17 11:03 UTC (permalink / raw)
  To: Chancel Liu
  Cc: lgirdwood, broonie, perex, tiwai, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, s.hauer, kernel, shumingf, rander.wang,
	pierre-louis.bossart, linux-sound, linux-kernel, linuxppc-dev,
	imx, linux-arm-kernel

On Wed, Apr 15, 2026 at 05:19:40PM +0900, Chancel Liu wrote:

subject suggest change to

ASoC: dapm: Use snd_soc_dapm_widget_name_cmp() to fix widget lookup failures

Frank
> Currently dapm_find_widget() manually constructs a prefixed widget name
> based on the provided DAPM context and compares it using strcmp(). This
> happens to work in most cases because callers usually know which DAPM
> context the target widget belongs to and pass in the matching DAPM
> context.
>
> However, this assumption breaks when search_other_contexts is enabled.
> In such cases, callers may intentionally pass a different DAPM context,
> while searching for a widget that actually belongs to another DAPM
> context.
>
> For example, when searching for a "DAC" widget, the widget belongs to
> the codec DAPM and be registered with a codec prefix, while the caller
> passes card->dapm and intends to search across all DAPM contexts. The
> current implementation incorrectly applies the caller card DAPM causing
> the lookup to fail even though the widget exists on the card.
>
> Use snd_soc_dapm_widget_name_cmp() instead, which compares widget names
> using the widget's own DAPM context and prefix. It fixes widget lookup
> failures when searching across different DAPM contexts on the card.
>
> Fixes: ae4fc532244b ("ASoC: dapm: use component prefix when checking widget names")
> Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> Assisted-by: Cody:Claude-3.5-Sonnet
> ---
>  sound/soc/soc-dapm.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index d6192204e613..c5b80d9ed64b 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -2906,20 +2906,9 @@ static struct snd_soc_dapm_widget *dapm_find_widget(
>  {
>  	struct snd_soc_dapm_widget *w;
>  	struct snd_soc_dapm_widget *fallback = NULL;
> -	char prefixed_pin[80];
> -	const char *pin_name;
> -	const char *prefix = dapm_prefix(dapm);
> -
> -	if (prefix) {
> -		snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
> -			 prefix, pin);
> -		pin_name = prefixed_pin;
> -	} else {
> -		pin_name = pin;
> -	}
>
>  	for_each_card_widgets(dapm->card, w) {
> -		if (!strcmp(w->name, pin_name)) {
> +		if (!snd_soc_dapm_widget_name_cmp(w, pin)) {
>  			if (w->dapm == dapm)
>  				return w;
>  			else
> --
> 2.50.1
>


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

* Re: [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets
  2026-04-15  8:19 ` [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
@ 2026-04-17 11:14   ` Frank Li
  2026-04-23  3:11     ` Chancel Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Li @ 2026-04-17 11:14 UTC (permalink / raw)
  To: Chancel Liu
  Cc: lgirdwood, broonie, perex, tiwai, shengjiu.wang, Xiubo.Lee,
	festevam, nicoleotsuka, s.hauer, kernel, shumingf, rander.wang,
	pierre-louis.bossart, linux-sound, linux-kernel, linuxppc-dev,
	imx, linux-arm-kernel

On Wed, Apr 15, 2026 at 05:19:41PM +0900, Chancel Liu wrote:
> Some audio systems require specific DAPM widgets to remain powered
> during system suspend. Introduce a generic and reusable mechanism in
> the ASoC core to mark selected DAPM widgets as ignore_suspend.
>
> The unified mechanism consists of two parts:
> 1. Parse and store the name list of widgets to ignore suspend in
> struct snd_soc_card
>
> The list of widgets can be provided either by the machine driver or
> parsed from Device Tree. Different machines have different routing and
> power requirements. Each machine can specify its own widgets to ignore
> suspend through DT property. It enables flexible policy without hard
> code. A new helper, snd_soc_of_parse_ignore_suspend_widgets() is added
> for this purpose.
>
> 2. Apply ignore_suspend flags during snd_soc_bind_card()
>
> After all components have been probed and all DAPM widgets have been
> registered, snd_soc_bind_card() performs a unified lookup of the
> configured widget names across all DAPM contexts of the card and marks
> the matching widgets with ignore_suspend = 1.
>
> Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> ---
...
> @@ -3294,6 +3298,45 @@ int snd_soc_of_parse_aux_devs(struct snd_soc_card *card, const char *propname)
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
>
> +int snd_soc_of_parse_ignore_suspend_widgets(struct snd_soc_card *card,
> +					    const char *propname)

propname is fixed value "ignore-suspend-widgets",needn't this agument.
you funciton include "ignore_suspend_widgets", suppose only parse property.
ignore_suspend_widgets

Frank


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

* RE: [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts
  2026-04-17 11:03   ` Frank Li
@ 2026-04-23  3:03     ` Chancel Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Chancel Liu @ 2026-04-23  3:03 UTC (permalink / raw)
  To: Frank Li
  Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com,
	festevam@gmail.com, nicoleotsuka@gmail.com,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	shumingf@realtek.com, rander.wang@linux.intel.com,
	pierre-louis.bossart@linux.dev, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org

> subject suggest change to
> 
> ASoC: dapm: Use snd_soc_dapm_widget_name_cmp() to fix widget lookup
> failures
> 
> Frank

OK, this looks more simplified and clearer.

Regards, 
Chancel Liu

> > Currently dapm_find_widget() manually constructs a prefixed widget name
> > based on the provided DAPM context and compares it using strcmp(). This
> > happens to work in most cases because callers usually know which DAPM
> > context the target widget belongs to and pass in the matching DAPM
> > context.
> >
> > However, this assumption breaks when search_other_contexts is enabled.
> > In such cases, callers may intentionally pass a different DAPM context,
> > while searching for a widget that actually belongs to another DAPM
> > context.
> >
> > For example, when searching for a "DAC" widget, the widget belongs to
> > the codec DAPM and be registered with a codec prefix, while the caller
> > passes card->dapm and intends to search across all DAPM contexts. The
> > current implementation incorrectly applies the caller card DAPM causing
> > the lookup to fail even though the widget exists on the card.
> >
> > Use snd_soc_dapm_widget_name_cmp() instead, which compares widget
> names
> > using the widget's own DAPM context and prefix. It fixes widget lookup
> > failures when searching across different DAPM contexts on the card.
> >
> > Fixes: ae4fc532244b ("ASoC: dapm: use component prefix when checking
> widget names")
> > Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> > Assisted-by: Cody:Claude-3.5-Sonnet
> > ---
> >  sound/soc/soc-dapm.c | 13 +------------
> >  1 file changed, 1 insertion(+), 12 deletions(-)
> >
> > diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> > index d6192204e613..c5b80d9ed64b 100644
> > --- a/sound/soc/soc-dapm.c
> > +++ b/sound/soc/soc-dapm.c
> > @@ -2906,20 +2906,9 @@ static struct snd_soc_dapm_widget
> *dapm_find_widget(
> >  {
> >  	struct snd_soc_dapm_widget *w;
> >  	struct snd_soc_dapm_widget *fallback = NULL;
> > -	char prefixed_pin[80];
> > -	const char *pin_name;
> > -	const char *prefix = dapm_prefix(dapm);
> > -
> > -	if (prefix) {
> > -		snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
> > -			 prefix, pin);
> > -		pin_name = prefixed_pin;
> > -	} else {
> > -		pin_name = pin;
> > -	}
> >
> >  	for_each_card_widgets(dapm->card, w) {
> > -		if (!strcmp(w->name, pin_name)) {
> > +		if (!snd_soc_dapm_widget_name_cmp(w, pin)) {
> >  			if (w->dapm == dapm)
> >  				return w;
> >  			else
> > --
> > 2.50.1
> >


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

* RE: [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets
  2026-04-17 11:14   ` Frank Li
@ 2026-04-23  3:11     ` Chancel Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Chancel Liu @ 2026-04-23  3:11 UTC (permalink / raw)
  To: Frank Li
  Cc: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com,
	festevam@gmail.com, nicoleotsuka@gmail.com,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	shumingf@realtek.com, rander.wang@linux.intel.com,
	pierre-louis.bossart@linux.dev, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org

> > Some audio systems require specific DAPM widgets to remain powered
> > during system suspend. Introduce a generic and reusable mechanism in
> > the ASoC core to mark selected DAPM widgets as ignore_suspend.
> >
> > The unified mechanism consists of two parts:
> > 1. Parse and store the name list of widgets to ignore suspend in
> > struct snd_soc_card
> >
> > The list of widgets can be provided either by the machine driver or
> > parsed from Device Tree. Different machines have different routing and
> > power requirements. Each machine can specify its own widgets to ignore
> > suspend through DT property. It enables flexible policy without hard
> > code. A new helper, snd_soc_of_parse_ignore_suspend_widgets() is added
> > for this purpose.
> >
> > 2. Apply ignore_suspend flags during snd_soc_bind_card()
> >
> > After all components have been probed and all DAPM widgets have been
> > registered, snd_soc_bind_card() performs a unified lookup of the
> > configured widget names across all DAPM contexts of the card and marks
> > the matching widgets with ignore_suspend = 1.
> >
> > Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
> > ---
> ...
> > @@ -3294,6 +3298,45 @@ int snd_soc_of_parse_aux_devs(struct
> > snd_soc_card *card, const char *propname)  }
> > EXPORT_SYMBOL_GPL(snd_soc_of_parse_aux_devs);
> >
> > +int snd_soc_of_parse_ignore_suspend_widgets(struct snd_soc_card *card,
> > +					    const char *propname)
> 
> propname is fixed value "ignore-suspend-widgets",needn't this agument.
> you funciton include "ignore_suspend_widgets", suppose only parse property.
> ignore_suspend_widgets
> 
> Frank

The motivation for keeping the propname argument is to align with
existing snd_soc_of_parse_*() helper prototypes, which always take
(struct snd_soc_card *card, const char *propname).

I agree that in this case the property name is fixed to
"ignore-suspend-widgets". We can simplify the helper by removing it if
preferred.

Regards, 
Chancel Liu


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

* Re: [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support
  2026-04-15  8:19 ` [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support Chancel Liu
@ 2026-04-28  8:48   ` Mark Brown
  2026-04-28  9:53     ` Chancel Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2026-04-28  8:48 UTC (permalink / raw)
  To: Chancel Liu
  Cc: lgirdwood, perex, tiwai, shengjiu.wang, Xiubo.Lee, festevam,
	nicoleotsuka, Frank.Li, s.hauer, kernel, shumingf, rander.wang,
	pierre-louis.bossart, linux-sound, linux-kernel, linuxppc-dev,
	imx, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 596 bytes --]

On Wed, Apr 15, 2026 at 05:19:42PM +0900, Chancel Liu wrote:

> @@ -274,6 +257,15 @@ static int imx_rpmsg_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +	if (data->lpa && of_property_present(np, "ignore-suspend-widgets")) {
> +		ret = snd_soc_of_parse_ignore_suspend_widgets(&data->card,
> +							      "ignore-suspend-widgets");
> +		if (ret) {
> +			dev_err(&pdev->dev, "failed to parse ignore-suspend-widgets: %d\n", ret);
> +			return ret;
> +		}
> +	}
> +

The other error handling paths here have a goto fail to do cleanup of
the of_node in the platform device.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: Re: [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support
  2026-04-28  8:48   ` Mark Brown
@ 2026-04-28  9:53     ` Chancel Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Chancel Liu @ 2026-04-28  9:53 UTC (permalink / raw)
  To: Mark Brown
  Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com,
	nicoleotsuka@gmail.com, Frank Li, s.hauer@pengutronix.de,
	kernel@pengutronix.de, shumingf@realtek.com,
	rander.wang@linux.intel.com, pierre-louis.bossart@linux.dev,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org

> > @@ -274,6 +257,15 @@ static int imx_rpmsg_probe(struct platform_device
> *pdev)
> >  		}
> >  	}
> >
> > +	if (data->lpa && of_property_present(np, "ignore-suspend-widgets"))
> {
> > +		ret = snd_soc_of_parse_ignore_suspend_widgets(&data-
> >card,
> > +							      "ignore-suspend-
> widgets");
> > +		if (ret) {
> > +			dev_err(&pdev->dev, "failed to parse ignore-suspend-
> widgets: %d\n", ret);
> > +			return ret;
> > +		}
> > +	}
> > +
> 
> The other error handling paths here have a goto fail to do cleanup of the
> of_node in the platform device.

Will fix it in next version.

Regards, 
Chancel Liu


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

end of thread, other threads:[~2026-04-28  9:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15  8:19 [PATCH v2 0/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
2026-04-15  8:19 ` [PATCH v2 1/3] ASoC: dapm: Fix widget lookup with prefixed names across DAPM contexts Chancel Liu
2026-04-17 11:03   ` Frank Li
2026-04-23  3:03     ` Chancel Liu
2026-04-15  8:19 ` [PATCH v2 2/3] ASoC: soc-core: Add core support for ignoring suspend on selected DAPM widgets Chancel Liu
2026-04-17 11:14   ` Frank Li
2026-04-23  3:11     ` Chancel Liu
2026-04-15  8:19 ` [PATCH v2 3/3] ASoC: fsl: imx-rpmsg: Switch to core ignore-suspend-widgets support Chancel Liu
2026-04-28  8:48   ` Mark Brown
2026-04-28  9:53     ` Chancel Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox