mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>, broonie@kernel.org
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@opensource.cirrus.com, Maxime Ripard <mripard@kernel.org>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	linux-rpi-kernel <linux-rpi-kernel@lists.infradead.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>
Subject: Re: [PATCH v2] ASoC: soc-core: Create device_link to ensure correct suspend order
Date: Sat, 20 Jun 2026 16:57:39 +0100	[thread overview]
Message-ID: <274c6e32-4571-4e74-8e70-53c780cc7e24@opensource.cirrus.com> (raw)
In-Reply-To: <4c9156cb-6508-4fda-8e36-7edc4eb7d6f9@samsung.com>

On 17/6/26 15:10, Marek Szyprowski wrote:
> Dear All,
> 
> On 11.06.2026 13:08, Richard Fitzgerald wrote:
>> In snd_soc_bind_card() create a device_link from card to all components
>> to ensure correct order of system_suspend. The card is the consumer and
>> the components are the supplier, so that the card will system_suspend
>> before any of the components.
>>

<SNIP>

> This patch landed recently in linux-next as commit 0f54ce994b23 ("ASoC:
> soc-core: Create device_link to ensure correct suspend order"). In my
> tests I found that it breaks probing of VC4 DRM subsystem on Raspberry Pi
> 3 and 4 boards due to an issue with hdmi-audio-codec:
> 
> # dmesg | grep vc4
> vc4-drm gpu: bound fe400000.hvs (ops vc4_hvs_ops [vc4])
> vc4_hdmi fef00700.hdmi: Failed to create device link to hdmi-audio-codec.1.auto
> vc4_hdmi fef00700.hdmi: error -EINVAL: Could not register sound card
> vc4-drm gpu: failed to bind fef00700.hdmi (ops vc4_hdmi_ops [vc4]): -22
> vc4-drm gpu: adev bind failed: -22
> vc4-drm gpu: probe with driver vc4-drm failed with error -22
> 
Marek,

Can you try the patch below?

If this works for you, and passes our tests, and nobody has any
objections, I can send it as a proper patch submission.

---

 From 08de5810ef813c9945d01a2ce23cd9dd71cf3d99 Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <rf@opensource.cirrus.com>
Date: Sat, 20 Jun 2026 14:33:18 +0100
Subject: [PATCH] ASoC: soc-core: Don't fail if device_link could not be
  created

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
  include/sound/soc-component.h |  4 ++++
  sound/soc/soc-core.c          | 32 ++++++++++++--------------------
  2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 11bc9527653f..aa423865dbe7 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -10,6 +10,8 @@

  #include <sound/soc.h>

+struct device_link;
+
  /*
   * Component probe and remove ordering levels for components with runtime
   * dependencies.
@@ -216,6 +218,8 @@ struct snd_soc_component {
         struct list_head card_aux_list; /* for auxiliary bound 
components */
         struct list_head card_list;

+       struct device_link *card_device_link;
+
         const struct snd_soc_component_driver *driver;

         struct list_head dai_list;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 86b6c752a56b..8c24049d44d3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1980,19 +1980,15 @@ static void soc_cleanup_card_resources(struct 
snd_soc_card *card)
         }
  }

-static void snd_soc_remove_device_links(struct snd_soc_card *card,
-                                       struct snd_soc_component *stop_at)
+static void snd_soc_remove_device_links(struct snd_soc_card *card)
  {
         struct snd_soc_component *component;

         for_each_card_components(card, component) {
-               if (card->dev == component->dev)
-                       continue;
-
-               device_link_remove(card->dev, component->dev);
-
-               if (component == stop_at)
-                       return;
+               if (component->card_device_link) {
+                       device_link_del(component->card_device_link);
+                       component->card_device_link = NULL;
+               }
         }
  }

@@ -2001,7 +1997,7 @@ static void snd_soc_unbind_card(struct 
snd_soc_card *card)
         if (snd_soc_card_is_instantiated(card)) {
                 card->instantiated = false;

-               snd_soc_remove_device_links(card, NULL);
+               snd_soc_remove_device_links(card);

                 soc_cleanup_card_resources(card);
         }
@@ -2012,7 +2008,6 @@ static int snd_soc_bind_card(struct snd_soc_card 
*card)
         struct snd_soc_pcm_runtime *rtd;
         struct snd_soc_component *component;
         struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
-       struct snd_soc_component *last_devlinked_component = NULL;
         int ret;

         snd_soc_card_mutex_lock_root(card);
@@ -2146,14 +2141,13 @@ static int snd_soc_bind_card(struct snd_soc_card 
*card)
                 if (card->dev == component->dev)
                         continue;

-               if (!device_link_add(card->dev, component->dev, 
DL_FLAG_STATELESS)) {
-                       dev_warn(card->dev, "Failed to create device 
link to %s\n",
+               component->card_device_link = device_link_add(card->dev,
+ 
component->dev,
+ 
DL_FLAG_STATELESS);
+               if (!component->card_device_link) {
+                       dev_warn(card->dev, "Could not create device 
link to %s\n",
                                  dev_name(component->dev));
-                       ret = -EINVAL;
-                       goto probe_end;
                 }
-
-               last_devlinked_component = component;
         }

         ret = snd_soc_card_late_probe(card);
@@ -2185,9 +2179,7 @@ static int snd_soc_bind_card(struct snd_soc_card 
*card)

  probe_end:
         if (ret < 0) {
-               if (last_devlinked_component)
-                       snd_soc_remove_device_links(card, 
last_devlinked_component);
-
+               snd_soc_remove_device_links(card);
                 soc_cleanup_card_resources(card);
         }

--
2.47.3

  parent reply	other threads:[~2026-06-20 15:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11 11:08 Richard Fitzgerald
2026-06-11 19:38 ` Mark Brown
     [not found] ` <CGME20260617141046eucas1p2e85629d57bfc17449b135b16f9230d57@eucas1p2.samsung.com>
2026-06-17 14:10   ` Marek Szyprowski
2026-06-18 11:22     ` Richard Fitzgerald
2026-06-18 12:58       ` Marek Szyprowski
2026-06-18 13:12         ` Marek Szyprowski
2026-06-18 13:12         ` Richard Fitzgerald
2026-06-18 13:22           ` Marek Szyprowski
2026-06-19 13:33             ` Richard Fitzgerald
2026-06-19 15:51               ` Mark Brown
2026-06-19 15:54               ` Charles Keepax
2026-06-19 16:04                 ` Richard Fitzgerald
2026-06-19 17:19                   ` Mark Brown
2026-06-20 15:57     ` Richard Fitzgerald [this message]
2026-06-22  7:07       ` Marek Szyprowski
2026-06-23 10:22         ` Richard Fitzgerald

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=274c6e32-4571-4e74-8e70-53c780cc7e24@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mripard@kernel.org \
    --cc=patches@opensource.cirrus.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

all inboxes | Powered by JetHome®