| Message ID | 20260522095401.72915-4-phucduc.bui@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-23606-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mxe881.netcup.net (Postfix) with ESMTPS id 614291C07FA
for <noreply@patchwork.local>; Fri, 22 May 2026 11:56:54 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 172.234.253.10)
smtp.mailfrom=linux-sunxi+bounces-23606-noreply=patchwork.local@lists.linux.dev
smtp.helo=sea.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates
172.234.253.10 as permitted sender) client-ip=172.234.253.10;
envelope-from=linux-sunxi+bounces-23606-noreply=patchwork.local@lists.linux.dev;
helo=sea.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by sea.lore.kernel.org (Postfix) with ESMTP id D31A63051D2D
for <noreply@patchwork.local>; Fri, 22 May 2026 09:54:37 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id B18FE3B52E1;
Fri, 22 May 2026 09:54:37 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b="m3vz9O+K"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com
[209.85.210.171])
(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 17F7E3C4572
for <linux-sunxi@lists.linux.dev>; Fri, 22 May 2026 09:54:34 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=209.85.210.171
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1779443677; cv=none;
b=DniAwfps1BQ6d0MjTywsQIY4PLq1335cFRmyirC+JDs9Zq7+AoKAeW4ZCrPpB+j3i7IiV82p6CIS4Zzx0zBSTzo2EBaK3neCi7ZbmUHvfyk+qVU9YI4MSkb15AJBsZaw4YwMBCfqY4Ku1EW2TwI4V1JPPEpFTlaVY3X+EiezBoo=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1779443677; c=relaxed/simple;
bh=qbDGhHNnk9OCLZQ1PGxrrKjrGTP1fFlGw+ruMcn44HU=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version;
b=Fqw/6theIKMVR/+TiA9J4/BLhnYFeXlt6Z2xaIL3OsgC5B9x0YmzBBQR1k9MK5dWXleblzUY7QPpOWVMnYCTPdutOpVkLT3mSxE/q0CqKYry7zUSyszsDTCbKilOH0Yh1av6Cd8nfn9HuA45uN3ymLTWfLtxxs1JShjNB1mgzAU=
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=m3vz9O+K; arc=none smtp.client-ip=209.85.210.171
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-f171.google.com with SMTP id
d2e1a72fcca58-82f9fdfc965so3327705b3a.1
for <linux-sunxi@lists.linux.dev>;
Fri, 22 May 2026 02:54:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1779443674; x=1780048474;
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=OZzUxIkdaJ6gBxa9mowChRFjkNJFrAHd972GUGZ8zKk=;
b=m3vz9O+KzpIGoC8nrzwg0BrIBZBJou5Ys66qkHFPM7/5gxoXDEW5+wf3sCtctTfajL
eG4hQhGgroGnMy8p+KpLRkhY5ab188lMm1mtoPQinRFn3HRZKmWvxQUOzCIND2oAfMzP
/HvHJrNNWEjHgg+Bv7NSkRvw7ksVYdjkve3sDRXiov+QBMvatpTypskbckVD5sUzf9L/
Vz+X24TQl4pDCk2+L4rw5/rKb7KoSK5J3OCuitjBcMp6qtP/HxtfA/2AaSWikBHWubAX
MojYnqHrBBvqGvlx+f/+UpXU6EMGg428+H6iYfrJxLtVXJ7Z9OEGEyUJpwvAeGhIdCle
Qcwg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1779443674; x=1780048474;
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=OZzUxIkdaJ6gBxa9mowChRFjkNJFrAHd972GUGZ8zKk=;
b=NNk5YgZ0tvkkUJME8bTzCbfjN8loi3XLKo/jl3uSDpi8zGid1lV0PwARnAknT0PUzs
fToNbI2Bk+Dxv5kVdLh4A0/dG0PAYJURzlLuwUBSMfq8g7Egf+WJEipRxnr27hezPrJF
IjKOUllfxp90JSkb2qYXI0o+tT155M1s4U2fcTvST92GZJTAYAHTj2POuWZ5FGBLT7IL
bjXOkyvsRTswlPj97l5bwqHnN5Hp8dJk6gUzLrtwjUAUVgdbXosS0qH7vQPmbQNdf/u0
Tc2Q1Me2pOMJCOmpJtbpNQrShcKUCxA/HFqXlxHx39km2QyLXMWIfzsT5MbNfErdHveK
pvgg==
X-Forwarded-Encrypted: i=1;
AFNElJ/G430Bdr+MQORM5sln2IGCwZlUODEwkzebuLundo5xUvIO3V/vFq2cD6m7pCbinEfl7lEOf2N2aK+Q1A==@lists.linux.dev
X-Gm-Message-State: AOJu0YxATvmvBvlH3iIkiP73MEUUzNxItWhzD7EAyjrwJmWk1v4HPnM6
NEy+sbWHFT1E6R4nnbLGQlNVQVE2T6/Dht/mhG0zsqnXvllEd563ATkW
X-Gm-Gg: Acq92OG8uU5JDs8NKD+hwkZ9aYrtx+CyXNETGGULmEK+eqx0OWhJekgbhM8Sq1OaBPq
+J5MBhS5mFEUZrwuruq/F2GBDcPwofoHtbP6Yge9MhPjObI3X0rzg+o9qeLWHjbgqg8b6iu2K0Q
YU3EURcTtr7rw3/7g6RxPzt8be/cPp8FF7jtkAEKz3VbPINnG516/XE+qKo7L7SRAzRLSdm/OOw
EmtlAdff/lQhM1cC4Zxu6RIQv4lLro2mdLo503bDqc+CXrLFb+pywPG7jaNo7Sh8jsW2pGMGNLh
I1Ne5pJ70L563qsYNKIQNiFclJ4Gxhk6e7osLacTRx0rm3s7KVIeIsGeKXxUDOfY6RGoy4cdSET
MPhIqdbwUc5Kj2SwCWJOphDDFklySPoVDJtvCfh74QlNxT6ykRN0tsMc877qUWe/tnjAgp3zr0f
sPC5My0vG2MXehmXAOaDY//Xh+UxH+J/3XYNvYcpgbAg/UO15M5B2KW8I4ZQ==
X-Received: by 2002:a05:6a00:17a4:b0:82f:5726:be23 with SMTP id
d2e1a72fcca58-8415f3f68ccmr3185755b3a.49.1779443674325;
Fri, 22 May 2026 02:54:34 -0700 (PDT)
Received: from phuc-desktop.. ([183.91.15.56])
by smtp.gmail.com with ESMTPSA id
d2e1a72fcca58-84164aed7c9sm1757366b3a.13.2026.05.22.02.54.30
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 22 May 2026 02:54:33 -0700 (PDT)
From: phucduc.bui@gmail.com
To: broonie@kernel.org
Cc: codekipper@gmail.com,
jernej.skrabec@gmail.com,
lgirdwood@gmail.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-sound@vger.kernel.org,
linux-sunxi@lists.linux.dev,
nichen@iscas.ac.cn,
perex@perex.cz,
samuel@sholland.org,
tiwai@suse.com,
wens@kernel.org,
bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH v2 3/3] ASoC: sunxi: sun4i-spdif: Reorder clock enable
sequence
Date: Fri, 22 May 2026 16:54:01 +0700
Message-ID: <20260522095401.72915-4-phucduc.bui@gmail.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20260522095401.72915-1-phucduc.bui@gmail.com>
References: <20260522095401.72915-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)[99.99%];
RBL_SENDERSCORE(2.00)[172.234.253.10: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];
BAD_REP_POLICIES(0.10)[];
MIME_GOOD(-0.10)[text/plain];
HAS_LIST_UNSUB(-0.01)[];
FROM_NO_DN(0.00)[];
R_SPF_ALLOW(0.00)[+ip4:172.234.253.10];
RCPT_COUNT_TWELVE(0.00)[14];
DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:rdns,sea.lore.kernel.org:helo];
TO_DN_SOME(0.00)[];
FUZZY_BLOCKED(0.00)[rspamd.com];
FORGED_SENDER_MAILLIST(0.00)[];
FREEMAIL_CC(0.00)[gmail.com,lists.infradead.org,vger.kernel.org,lists.linux.dev,iscas.ac.cn,perex.cz,sholland.org,suse.com,kernel.org];
TAGGED_RCPT(0.00)[];
PRECEDENCE_BULK(0.00)[];
FREEMAIL_FROM(0.00)[gmail.com];
RCVD_TLS_LAST(0.00)[];
MIME_TRACE(0.00)[0:+];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1];
MID_RHS_MATCH_FROM(0.00)[];
ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG];
TAGGED_FROM(0.00)[bounces-23606-noreply=patchwork.local];
RCVD_COUNT_FIVE(0.00)[6];
FROM_NEQ_ENVFROM(0.00)[phucducbui@gmail.com,linux-sunxi@lists.linux.dev];
RCVD_VIA_SMTP_AUTH(0.00)[]
X-Rspamd-Queue-Id: 614291C07FA
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
May 22, 2026, 9:54 a.m. UTC
From: bui duc phuc <phucduc.bui@gmail.com> Enable the APB bus clock before the SPDIF module clock during runtime resume, as register accesses depend on the bus clock being enabled first. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> --- sound/soc/sunxi/sun4i-spdif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: Pre-existing issues: - [High] This problem wasn't introduced by this patch, but the devres cleanup order for ALSA components triggers a kernel crash during module unload or driver unbind. - [High] This problem wasn't introduced by this patch, but the driver incorrectly handles the 3-byte audio format `SNDRV_PCM_FORMAT_S20_3LE`, causing severe audio corruption. -- commit 1f13dc88fc812744e12c7e297ac44bb8e304a727 Author: bui duc phuc <phucduc.bui@gmail.com> ASoC: sunxi: sun4i-spdif: Reorder clock enable sequence This commit reorders the clock enable sequence during runtime resume. It enables the APB bus clock before the SPDIF module clock to ensure register accesses do not fail. > 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) > { > - 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); [Severity: High] This isn't a bug introduced by this patch, but the devres cleanup order for ALSA components appears to trigger a kernel crash during module unload or driver unbind. In sun4i_spdif_probe(), the ALSA component and DMA engine are registered via devm_snd_soc_register_component() and devm_snd_dmaengine_pcm_register(). The devres teardown runs after the driver's sun4i_spdif_remove() function returns. However, sun4i_spdif_remove() explicitly calls pm_runtime_disable() and sun4i_spdif_runtime_suspend(), which disable the apb_clk bus clock. When the devres teardown later unregisters the ASoC component, it forces any active PCM streams to stop, invoking sun4i_spdif_trigger() with SNDRV_PCM_TRIGGER_STOP. This calls sun4i_snd_txctrl_off(), which writes to hardware registers via regmap. Because the APB clock has already been disabled by the remove function, do these regmap accesses hit unclocked hardware and result in a synchronous external abort (kernel panic) on sunxi platforms? [Severity: High] This is a pre-existing issue, but does the driver incorrectly handle the 3-byte audio format SNDRV_PCM_FORMAT_S20_3LE, causing severe audio corruption? The driver advertises support for SNDRV_PCM_FMTBIT_S20_3LE in SUN4I_FORMATS, which means 20-bit audio samples are tightly packed into exactly 3 bytes in memory. However, in sun4i_spdif_hw_params(), the DMA slave bus width (dma_params_tx.addr_width) is left at DMA_SLAVE_BUSWIDTH_4_BYTES for this format. This configures the dst_addr_width of the DMA controller to 4 bytes. In the ALSA generic DMA engine code and sunxi-dma driver, the undefined src_addr_width defaults to match the 4-byte destination width. Because the memory buffer contains tightly packed 3-byte samples, does commanding the DMA controller to perform 4-byte memory reads misalign the stream immediately (reading part of the next sample on every fetch), leading to complete data corruption and unusable audio output? > > return ret; > }
On Fri, May 22, 2026 at 12:54 PM <phucduc.bui@gmail.com> wrote: > > From: bui duc phuc <phucduc.bui@gmail.com> > > Enable the APB bus clock before the SPDIF module clock > during runtime resume, as register accesses depend on the > bus clock being enabled first. That does not even matter here. Access will only happen once the runtime PM callbacks return. > Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> > --- > sound/soc/sunxi/sun4i-spdif.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > 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; > } > -- > 2.43.0 >
Hi Chen-yu, Thanks for your feedback On Sat, May 23, 2026 at 2:20 AM Chen-Yu Tsai <wens@kernel.org> wrote: > > Enable the APB bus clock before the SPDIF module clock > > during runtime resume, as register accesses depend on the > > bus clock being enabled first. > > That does not even matter here. Access will only happen once the runtime > PM callbacks return. > I understand your point that sun4i-spdif doesn't immediately access registers within the current runtime_resume path, so the order might not trigger a failure right now. However, if we look at the peer driver for the same Sunxi SoC family, sun4i-i2s.c: Links: https://elixir.bootlin.com/linux/v7.0-rc5/source/sound/soc/sunxi/sun4i-i2s.c#L1296 In sun4i_i2s_runtime_resume(), the sequence is strictly enforced as: 1. Enable bus clock 2. Access and restore/sync I2S registers 3. Enable module clock Since both IP blocks belong to the same Sunxi platform and share similar bus/module clock relationships, shouldn't we maintain architectural consistency across these drivers? Enforcing the "bus clock before module clock" order keeps the dependency ordering aligned with the actual hardware roles, where the bus clock is required for register access while the module clock drives the functional audio path. Wouldn't keeping this order also make the runtime PM behavior more consistent and easier to follow across the Sunxi audio drivers? Best Regards, Phuc
On Sat, May 23, 2026 at 3:11 PM Bui Duc Phuc <phucduc.bui@gmail.com> wrote: > > Hi Chen-yu, > > Thanks for your feedback > > On Sat, May 23, 2026 at 2:20 AM Chen-Yu Tsai <wens@kernel.org> wrote: > > > Enable the APB bus clock before the SPDIF module clock > > > during runtime resume, as register accesses depend on the > > > bus clock being enabled first. > > > > That does not even matter here. Access will only happen once the runtime > > PM callbacks return. > > > > I understand your point that sun4i-spdif doesn't immediately access > registers within the current runtime_resume path, so the order might > not trigger a failure right now. > > However, if we look at the peer driver for the same Sunxi SoC family, > sun4i-i2s.c: > Links: > https://elixir.bootlin.com/linux/v7.0-rc5/source/sound/soc/sunxi/sun4i-i2s.c#L1296 > In sun4i_i2s_runtime_resume(), the sequence is strictly enforced as: > > 1. Enable bus clock > 2. Access and restore/sync I2S registers > 3. Enable module clock > > Since both IP blocks belong to the same Sunxi platform and share similar > bus/module clock relationships, shouldn't we maintain architectural > consistency across these drivers? > > Enforcing the "bus clock before module clock" order keeps the dependency > ordering aligned with the actual hardware roles, where the bus clock is > required for register access while the module clock drives the functional > audio path. > > Wouldn't keeping this order also make the runtime PM behavior more > consistent and easier to follow across the Sunxi audio drivers? This should be your primary motivation for the patch, i.e. what you put in the commit message as the reason for this patch. What you currently have doesn't make sense, as I already mentioned. Some background though, sunxi is done mostly by volunteers, so we're not overly concerned with rigidness or aligning different drivers, unless they share a common library, such as all the clk or pinctrl drivers. ChenYu
On Sun, May 24, 2026 at 9:41 AM Chen-Yu Tsai <wens@kernel.org> wrote: > > On Sat, May 23, 2026 at 3:11 PM Bui Duc Phuc <phucduc.bui@gmail.com> wrote: > > > > Hi Chen-yu, > > > > Thanks for your feedback > > > > On Sat, May 23, 2026 at 2:20 AM Chen-Yu Tsai <wens@kernel.org> wrote: > > > > Enable the APB bus clock before the SPDIF module clock > > > > during runtime resume, as register accesses depend on the > > > > bus clock being enabled first. > > > > > > That does not even matter here. Access will only happen once the runtime > > > PM callbacks return. > > > > > > > I understand your point that sun4i-spdif doesn't immediately access > > registers within the current runtime_resume path, so the order might > > not trigger a failure right now. > > > > However, if we look at the peer driver for the same Sunxi SoC family, > > sun4i-i2s.c: > > Links: > > https://elixir.bootlin.com/linux/v7.0-rc5/source/sound/soc/sunxi/sun4i-i2s.c#L1296 > > In sun4i_i2s_runtime_resume(), the sequence is strictly enforced as: > > > > 1. Enable bus clock > > 2. Access and restore/sync I2S registers > > 3. Enable module clock > > > > Since both IP blocks belong to the same Sunxi platform and share similar > > bus/module clock relationships, shouldn't we maintain architectural > > consistency across these drivers? > > > > Enforcing the "bus clock before module clock" order keeps the dependency > > ordering aligned with the actual hardware roles, where the bus clock is > > required for register access while the module clock drives the functional > > audio path. > > > > Wouldn't keeping this order also make the runtime PM behavior more > > consistent and easier to follow across the Sunxi audio drivers? > > This should be your primary motivation for the patch, i.e. what you > put in the commit message as the reason for this patch. What you > currently have doesn't make sense, as I already mentioned. > > Some background though, sunxi is done mostly by volunteers, so we're > not overly concerned with rigidness or aligning different drivers, > unless they share a common library, such as all the clk or pinctrl > drivers. Oh, and you could also add that the resume order should (normally) be the reverse of the suspend order. ChenYu
Hi Chen-yu, > Oh, and you could also add that the resume order should (normally) be > the reverse of the suspend order. Thank you for the feedback and clarification. I can certainly rewrite the commit message around the idea that the resume ordering should normally mirror the suspend ordering. However, I am still slightly unsure about which ordering should be considered the preferred one in this case. If the reasoning is purely based on suspend/resume symmetry, I wonder if changing the suspend path itself to disable the APB clock before the SPDIF module clock would be an option, which would then naturally lead to enabling the SPDIF module clock first during resume. >From the hardware perspective, I originally assumed the APB clock acts as the prerequisite for register access while the module clock mainly drives the functional audio logic, which is why the "bus before module" ordering initially seemed more intuitive to me. So I would like to better understand which ordering is considered the preferred model for the Sunxi audio blocks here: preserving the existing suspend/resume symmetry, or enforcing the bus/module dependency ordering. Thanks, Phuc
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; }