| Message ID | 20260602114437.50324-4-phucduc.bui@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-23723-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mxe881.netcup.net (Postfix) with ESMTPS id 9F2A01C0084
for <noreply@patchwork.local>; Tue, 2 Jun 2026 13:51:45 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 172.105.105.114)
smtp.mailfrom=linux-sunxi+bounces-23723-noreply=patchwork.local@lists.linux.dev
smtp.helo=tor.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.105.105.114 as permitted sender) client-ip=172.105.105.114;
envelope-from=linux-sunxi+bounces-23723-noreply=patchwork.local@lists.linux.dev;
helo=tor.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id 79F4530A4B66
for <noreply@patchwork.local>; Tue, 2 Jun 2026 11:45:37 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C6CA3DE453;
Tue, 2 Jun 2026 11:45:20 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b="gJWEMzw9"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com
[209.85.210.172])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CA8B3DDDCB
for <linux-sunxi@lists.linux.dev>; Tue, 2 Jun 2026 11:45:11 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=209.85.210.172
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1780400720; cv=none;
b=qVTfjCssAVHqoVNhMFHqvGQqZX+2dROo+u8NP0ZTy3gTuBeMDYWU8ydpeTbJaVbmewVNMdNI7Oxv9gLgFLbJkDSI8mnltpZ//zDBI62R+8zMISXLc1xJ6Lu8lFsnIeM/fHVea5oWMIKupdsXDlCVGdh5+lTPPZCyMicnI+cQ7QE=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1780400720; c=relaxed/simple;
bh=g8eArW1TvBopeg2TBOy3CcQKAvBFhzMIU2WVF3Mqh/I=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version;
b=rpF8lUvvvIVJXwC7tWEhhmzmKJVUxVeUp76MNtastW8VnpT5sTRsWWhL2PlVhmv99SVq/mNijKFENIIsfmnj2MXRv1XffrNk/qgF67B0emSj1qUXisXXJwJgrXh0Cwic+kX4H0tna2BBYF/Y7e/qkgu/h2oBcNgKYuhAvU1RUKY=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b=gJWEMzw9; arc=none smtp.client-ip=209.85.210.172
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=gmail.com
Received: by mail-pf1-f172.google.com with SMTP id
d2e1a72fcca58-8422f148dfcso1316723b3a.3
for <linux-sunxi@lists.linux.dev>;
Tue, 02 Jun 2026 04:45:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1780400710; x=1781005510;
darn=lists.linux.dev;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to;
bh=CFWD1rv/Hg1YLyvj0G8HeVU1rR/ze4TuYTUo6+4aG1k=;
b=gJWEMzw9WHxZ9Gk3xEnQeb8yHVv6/Ep/YhDR9OvQtS9FGGmzVCKtPHmCb/yiGfe2SM
01cGCAJu+zyCUIqRbw8tMeTCsysSY8yh4Om7oDcCocCM4knrMScTNVIQMnrnh9bBrGGE
dXdf3Ro1wUAKpTani6hmzA0ccTknO/rWSTfet6imol7q179STUAbYgE/4hlebDWCOruE
j5COz/9kCL4zw5g6wvyjMtw5aBa1pscktuo6EBqHqO/QNxifqfL0JkRkUIfFM+9m3u/n
y9DUWTDowZXcFcGnZ9OUJU9inn8Xc0iuarP+Tn/pt7L8LT19IVxmR8rp1GQ/Z0wLDmwC
l4aw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1780400710; x=1781005510;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to;
bh=CFWD1rv/Hg1YLyvj0G8HeVU1rR/ze4TuYTUo6+4aG1k=;
b=P1YcS2ccHWBdAPJ2wZ0+1wS+ZfrVa/c80w33pWVwcbXHfxRhX5k1mhKb9bxNW4wIKT
y1X4yQueO+zrCQ7h9VwCf1xgiJQOLwdiDFG3g2OIQkS8wH1I6nuiJuy8rQV5k+DC/Fr2
sHstODAJhaHs4AkYJhxkjmVkmuE+3kB8tsZORrT0JR0DPWjWPGzKbeNzyJFZmEBdMH7N
9bE1fUanZ1KX3UA42rNy3EheyrIPvoaIJWkOB58AvJVadqJ1kbv89IdPV67Lf2lB5Khj
iHPU8xANO9gwgGT/KNsqTudAbvgjKi3N1z8z8BoFzXwshGyBOTo/qsd1wHl+tjxzcyr2
jgAA==
X-Forwarded-Encrypted: i=1;
AFNElJ/cwrRjHtIjSgj97Pm+5qo/cVeajXmjRhthwXSIRZMR4SUGlF5KAr4EefO/j4WwFhOBL1/7g/NEQFkFRA==@lists.linux.dev
X-Gm-Message-State: AOJu0YwPvxg7GZOEAMX8fv6j2JHezzDr5CAwBDtLaelg4xoJWcE2b9n+
ozxVjb0qqF9GrjgwwEYBjFosorRumG1Djpjask29d5Njainw3rzG0gfp
X-Gm-Gg: Acq92OFHlTe1FT+oZJyw7z3K2zncDD8WfuaHuL0gtu3B1xSiQJlYRpCq4/k7Lx4Y4Su
+jcoespbilZMFWtNkgog28bV9SOjLl5LJMIz6yauePkBA5qX15HrJhJ3AHTUlbUOciiicq6jwfp
dhCK+heXLDKzqYDKEqxBtMb0eLPThj3gAiapppqoxO6oLbVAgolkj5Da12u0Ohc8PSPnrQxzP0I
Hj1rAdOHDEovc6vKzeqQZuvuH9qPbA3LfeNaVoTUGBAjDtAXkJfVUffJ69UdeYC/EuVyglMAbTj
zfLlabHCzGg6QEWzgNuPx42mZapc34kG/iaVEyBKL6BNGJVwHZfeHqHj0/HyemxgZa/iYpqZkHA
7lhthB/ELDS53Ut5tNHKOx4ZalVmPTf2c2+SY+bw/SUkifj/44wyVckC5zfJzwshouguGozvItz
Hy71LQ8IpmCqp9vtORMZfW3qwPTSpU9cvUsWNAwnX6u8FSJsentTJcZ5dPhWmguK+vCHVi
X-Received: by 2002:a05:6a00:2d09:b0:842:6004:3fd9 with SMTP id
d2e1a72fcca58-842600445ccmr6078561b3a.29.1780400709999;
Tue, 02 Jun 2026 04:45:09 -0700 (PDT)
Received: from phuc-desktop.. ([183.91.15.56])
by smtp.gmail.com with ESMTPSA id
d2e1a72fcca58-842263539a3sm12025224b3a.44.2026.06.02.04.45.06
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 02 Jun 2026 04:45:09 -0700 (PDT)
From: phucduc.bui@gmail.com
To: Chen-Yu Tsai <wens@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
linux-sound@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev,
linux-kernel@vger.kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH v3 3/3] ASoC: sunxi: sun4i-spdif: Reorder clock enable
sequence
Date: Tue, 2 Jun 2026 18:44:37 +0700
Message-ID: <20260602114437.50324-4-phucduc.bui@gmail.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20260602114437.50324-1-phucduc.bui@gmail.com>
References: <20260602114437.50324-1-phucduc.bui@gmail.com>
Precedence: bulk
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Rspamd-Server: rspamd-worker-8404
X-Spamd-Result: default: False [-0.66 / 15.00];
BAYES_HAM(-5.50)[100.00%];
RBL_SENDERSCORE(2.00)[172.105.105.114:from];
SUSPICIOUS_RECIPS(1.50)[];
DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed),
No valid DKIM,none];
R_MISSING_CHARSET(0.50)[];
MAILLIST(-0.15)[generic];
MIME_GOOD(-0.10)[text/plain];
BAD_REP_POLICIES(0.10)[];
HAS_LIST_UNSUB(-0.01)[];
PRECEDENCE_BULK(0.00)[];
TAGGED_RCPT(0.00)[];
FREEMAIL_CC(0.00)[perex.cz,suse.com,gmail.com,sholland.org,vger.kernel.org,lists.infradead.org,lists.linux.dev];
FORGED_SENDER_MAILLIST(0.00)[];
FROM_NO_DN(0.00)[];
FUZZY_BLOCKED(0.00)[rspamd.com];
DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo];
RCPT_COUNT_TWELVE(0.00)[12];
RCVD_COUNT_FIVE(0.00)[6];
ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG];
R_SPF_ALLOW(0.00)[+ip4:172.105.105.114];
FREEMAIL_TO(0.00)[kernel.org,gmail.com];
FREEMAIL_FROM(0.00)[gmail.com];
TO_DN_SOME(0.00)[];
FROM_NEQ_ENVFROM(0.00)[phucducbui@gmail.com,linux-sunxi@lists.linux.dev];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
RCVD_TLS_LAST(0.00)[];
TAGGED_FROM(0.00)[bounces-23723-noreply=patchwork.local];
MIME_TRACE(0.00)[0:+];
MID_RHS_MATCH_FROM(0.00)[];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1];
RCVD_VIA_SMTP_AUTH(0.00)[]
X-Rspamd-Queue-Id: 9F2A01C0084
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
|
| Series |
ASoC: sunxi: sun4i-spdif: Cleanup and runtime PM improvements
|
|
Commit Message
Bui Duc Phuc
June 2, 2026, 11:44 a.m. UTC
From: bui duc phuc <phucduc.bui@gmail.com> Reorder the runtime resume clock enable sequence to match the hardware dependency and ensure symmetry with the suspend path. The APB bus clock drives the register interface and must be enabled before the functional module clock. This aligns the resume sequence to be the exact reverse of the suspend sequence. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- NOTE: This patch is compile-tested only. Changes in v3: - Clarify in the commit message that the resume sequence becomes the reverse of the suspend sequence. sound/soc/sunxi/sun4i-spdif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: Pre-existing issues: - [High] Unbinding the driver while an audio stream is active will cause a fatal bus fault because hardware is suspended before the ASoC component is unregistered. -- commit 811edbc583bdf36ef4938bd44bba42ed394e19bd Author: bui duc phuc <phucduc.bui@gmail.com> ASoC: sunxi: sun4i-spdif: Reorder clock enable sequence Reorder the runtime resume clock enable sequence to match the hardware dependency and ensure symmetry with the suspend path. The APB bus clock drives the register interface and must be enabled before the functional module clock. This aligns the resume sequence to be the exact reverse of the suspend sequence. > diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c > index f54eb14c9ed86..102db1a2afbb8 100644 > --- a/sound/soc/sunxi/sun4i-spdif.c > +++ b/sound/soc/sunxi/sun4i-spdif.c > @@ -643,15 +643,15 @@ static int sun4i_spdif_runtime_suspend(struct device *dev) > > static int sun4i_spdif_runtime_resume(struct device *dev) > { [ ... ] > - ret = clk_prepare_enable(host->spdif_clk); > - if (ret) > - return ret; > ret = clk_prepare_enable(host->apb_clk); > if (ret) > - clk_disable_unprepare(host->spdif_clk); > + return ret; > + ret = clk_prepare_enable(host->spdif_clk); > + if (ret) > + clk_disable_unprepare(host->apb_clk); > > return ret; > } [Severity: High] This isn't a bug introduced by this patch, but unbinding the driver while an audio stream is active can cause a fatal bus fault. Looking at sun4i_spdif_remove(), it manually disables PM and suspends the hardware: sun4i_spdif_remove() { pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) sun4i_spdif_runtime_suspend(&pdev->dev); } Because devres unregisters the ASoC component after sun4i_spdif_remove() returns, the ALSA core responds to the unregistration by tearing down the active stream. This invokes callbacks like sun4i_spdif_trigger() with SNDRV_PCM_TRIGGER_STOP: sun4i_spdif_trigger() { case SNDRV_PCM_TRIGGER_STOP: ... sun4i_snd_txctrl_off(substream, host); break; } This tries to write to the device registers via regmap to disable transmission. Since the APB bus clock was already disabled in sun4i_spdif_remove(), accessing the registers causes a Data Abort and panics the kernel. Could the PM teardown be managed using devm_add_action_or_reset(), registered immediately after pm_runtime_enable() and before component registration, to ensure the ASoC component is fully unregistered before the clocks are turned off?
diff --git a/sound/soc/sunxi/sun4i-spdif.c b/sound/soc/sunxi/sun4i-spdif.c index f54eb14c9ed8..102db1a2afbb 100644 --- a/sound/soc/sunxi/sun4i-spdif.c +++ b/sound/soc/sunxi/sun4i-spdif.c @@ -643,15 +643,15 @@ static int sun4i_spdif_runtime_suspend(struct device *dev) static int sun4i_spdif_runtime_resume(struct device *dev) { - struct sun4i_spdif_dev *host = dev_get_drvdata(dev); + struct sun4i_spdif_dev *host = dev_get_drvdata(dev); int ret; - ret = clk_prepare_enable(host->spdif_clk); + ret = clk_prepare_enable(host->apb_clk); if (ret) return ret; - ret = clk_prepare_enable(host->apb_clk); + ret = clk_prepare_enable(host->spdif_clk); if (ret) - clk_disable_unprepare(host->spdif_clk); + clk_disable_unprepare(host->apb_clk); return ret; }