mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: sreekuttan2156239@gmail.com, cix-kernel-upstream@cixtech.com,
	fugang.duan@cixtech.com, gary.yang@cixtech.com, perex@perex.cz,
	tiwai@suse.de
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org
Subject: [PATCH v3] ALSA: hda: cix-ipbloq: Fix runtime PM handling on probe failure
Date: Wed,  2 Dec 2026 10:35:18 +0000	[thread overview]
Message-ID: <20261202103518.4945-1-sreekuttan2156239@gmail.com> (raw)
In-Reply-To: <20261202094026.4432-1-sreekuttan2156239@gmail.com>

The driver enables runtime PM before calling
pm_runtime_resume_and_get().

If cix_ipbloq_hda_init() or cix_ipbloq_hda_probe_codec()
fails, the runtime PM usage reference must be released.

However, calling pm_runtime_put_sync() before freeing the
ALSA device can trigger runtime suspend and disable the
controller clocks. The ALSA device cleanup may then access
controller registers while the clocks are disabled.

Disable runtime PM first and keep the controller clocks
enabled while freeing the ALSA device and card. Then balance
the runtime PM reference without triggering runtime suspend
and disable the clocks explicitly.

Also disable runtime PM if pm_runtime_resume_and_get()
fails.

Fixes: d91e9bd10125 ("ALSA: hda: add CIX IPBLOQ HDA controller support")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v3:
 - Add the missing changelog for v2.
v2:
 - Fix runtime PM cleanup ordering to avoid unclocked MMIO
   accesses during ALSA device cleanup.
 - Balance the runtime PM reference using pm_runtime_put_noidle()
   after freeing the ALSA device and card.
 - Keep controller clocks enabled during ALSA cleanup and
   disable them afterward.
 - Handle runtime PM cleanup when pm_runtime_resume_and_get()
   fails.

 sound/hda/controllers/cix-ipbloq.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/sound/hda/controllers/cix-ipbloq.c b/sound/hda/controllers/cix-ipbloq.c
index f73d6216bce3..10ae8729c312 100644
--- a/sound/hda/controllers/cix-ipbloq.c
+++ b/sound/hda/controllers/cix-ipbloq.c
@@ -237,6 +237,7 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
 	struct cix_ipbloq_hda *hda;
 	struct snd_card *card;
 	struct azx *chip;
+	bool pm_ref = false;
 	int err;
 
 	hda = devm_kzalloc_obj(&pdev->dev, *hda);
@@ -284,21 +285,37 @@ static int cix_ipbloq_hda_probe(struct platform_device *pdev)
 	err = pm_runtime_resume_and_get(hda->dev);
 	if (err < 0) {
 		dev_err(hda->dev, "runtime resume and get failed, err = %d\n", err);
-		goto out_free_device;
+		goto out_pm_disable;
 	}
 
+	pm_ref = true;
+
 	err = cix_ipbloq_hda_init(hda, chip, pdev);
 	if (err < 0)
-		goto out_free_device;
+		goto out_pm_cleanup;
 
 	err = cix_ipbloq_hda_probe_codec(hda);
 	if (err < 0)
-		goto out_free_device;
+		goto out_pm_cleanup;
 
 	pm_runtime_put(hda->dev);
 
 	return 0;
 
+out_pm_cleanup:
+	pm_runtime_disable(hda->dev);
+	snd_device_free(card, chip);
+	snd_card_free(card);
+	if (pm_ref) {
+		pm_runtime_put_noidle(hda->dev);
+		clk_bulk_disable_unprepare(hda->nclocks, hda->clocks);
+	}
+	return err;
+
+out_pm_disable:
+	pm_runtime_disable(hda->dev);
+	goto out_free_device;
+
 out_free_device:
 	snd_device_free(card, chip);
 out_free_card:
-- 
2.55.0


  parent reply	other threads:[~2026-12-02 10:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:40 [PATCH] " Sreeraj S Kurup
2026-12-02 10:23 ` [PATCH v2] " Sreeraj S Kurup
2026-12-02 10:35 ` Sreeraj S Kurup [this message]
2026-12-02 11:58   ` [PATCH v3] " Sreeraj S Kurup

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=20261202103518.4945-1-sreekuttan2156239@gmail.com \
    --to=sreekuttan2156239@gmail.com \
    --cc=cix-kernel-upstream@cixtech.com \
    --cc=fugang.duan@cixtech.com \
    --cc=gary.yang@cixtech.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /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®