Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 02/11] ASoC: SDCA: export PM helpers keyed on sdca_class_drv
Date: Mon, 07 Sep 2026 08:50:27 +0000	[thread overview]
Message-ID: <20260907085028.110551F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907083727.733705-3-srinivas.kandagatla@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] Exporting `sdca_class_pm_ops` unconditionally with `RUNTIME_PM_OPS` causes dead code retention when CONFIG_PM is disabled.

Pre-existing issues:
- [High] Data race and invalid hardware access between `boot_work` and system suspend.
--

commit 0f2e2cef51e8b87316164c383139022824389918
Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

ASoC: SDCA: export PM helpers keyed on sdca_class_drv

The class PM callbacks pull sdca_class_drv out of drvdata, so the
built-in class_sdw_driver owns the drvdata slot. That works for the
generic case but blocks codec drivers that want to embed sdca_class_drv
in their own private struct. Split the four callbacks into exported
helpers that take a struct sdca_class_drv * directly.

> diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c
> index d7444f442c71c..88a29116a334e 100644
> --- a/sound/soc/sdca/sdca_class.c
> +++ b/sound/soc/sdca/sdca_class.c
[ ... ]
> -static int class_suspend(struct device *dev)
> +/**
> + * sdca_class_system_suspend - SDCA class system suspend helper
> + * @drv: caller-owned sdca_class_drv.
> + *
> + * Codec drivers compose this into their own dev_pm_ops.  Disables the
> + * SoundWire interrupt and forces runtime suspend of the underlying
> + * class regmap.
> + */
> +int sdca_class_system_suspend(struct sdca_class_drv *drv)
>  {
> -	struct sdca_class_drv *drv = dev_get_drvdata(dev);
>  	int ret;
>  
>  	disable_irq(drv->sdw->irq);
>  
> -	ret = pm_runtime_force_suspend(dev);
> +	ret = pm_runtime_force_suspend(drv->dev);
>  	if (ret) {
> -		dev_err(dev, "failed to force suspend: %d\n", ret);
> +		dev_err(drv->dev, "failed to force suspend: %d\n", ret);
>  		return ret;
>  	}
>  
>  	return 0;
>  }
> +EXPORT_SYMBOL_NS_GPL(sdca_class_system_suspend, "SND_SOC_SDCA_CLASS");

[Severity: High]
This is a pre-existing issue, but does sdca_class_system_suspend() fail to
serialize against boot_work?

Because boot_work is queued on system_long_wq (an unbounded, non-freezable
workqueue), it can race with system suspend. If the system initiates suspend
while boot_work is waiting in sdw_slave_wait_for_init(),
sdca_class_system_suspend() will force the device into a suspended state by
disabling interrupts and setting regcache_cache_only(true).

Since sdca_class_system_suspend() does not flush or cancel the pending
initialization work, boot_work will eventually resume, blindly set
regcache_cache_only(false), and attempt hardware access on a physically
suspended bus, which could lead to bus timeouts or crashes.

[ ... ]
> +static int class_pm_runtime_resume(struct device *dev)
> +{
> +	return sdca_class_runtime_resume(dev_get_drvdata(dev));
> +}
>  
> -static const struct dev_pm_ops class_pm_ops = {
> -	SYSTEM_SLEEP_PM_OPS(class_suspend, class_resume)
> -	RUNTIME_PM_OPS(class_runtime_suspend, class_runtime_resume, NULL)
> +const struct dev_pm_ops sdca_class_pm_ops = {
> +	SYSTEM_SLEEP_PM_OPS(class_pm_system_suspend, class_pm_system_resume)
> +	RUNTIME_PM_OPS(class_pm_runtime_suspend, class_pm_runtime_resume, NULL)
>  };
> +EXPORT_SYMBOL_NS_GPL(sdca_class_pm_ops, "SND_SOC_SDCA_CLASS");

[Severity: Low]
Does exporting sdca_class_pm_ops unconditionally with RUNTIME_PM_OPS cause
dead code retention when CONFIG_PM is disabled?

When CONFIG_PM is disabled, runtime PM callbacks are never used and should be
eliminated by the compiler. Because sdca_class_pm_ops is globally exported in
this patch and populated using the unconditional RUNTIME_PM_OPS macro instead
of conditionally-compiled macros, the compiler will retain the structure and
its referenced static functions (class_pm_runtime_suspend and
class_pm_runtime_resume) as dead code in the final binary.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260907083727.733705-1-srinivas.kandagatla@oss.qualcomm.com?part=2

  reply	other threads:[~2026-09-07  8:50 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  8:37 [PATCH v2 00/11] ASoC: SDCA: enable on DT platforms and add Qualcomm WCD9378 (Tambora) codec Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 01/11] ASoC: SDCA: allow building without ACPI Srinivas Kandagatla
2026-09-07  8:54   ` Richard Fitzgerald
2026-09-07  9:09     ` Takashi Iwai
2026-09-07  8:37 ` [PATCH v2 02/11] ASoC: SDCA: export PM helpers keyed on sdca_class_drv Srinivas Kandagatla
2026-09-07  8:50   ` sashiko-bot [this message]
2026-09-07  9:43     ` Srinivas Kandagatla
2026-09-08 16:22   ` Charles Keepax
2026-09-08 17:49     ` Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 03/11] ASoC: SDCA: expose class SoundWire probe/remove/read_prop as library Srinivas Kandagatla
2026-09-07  8:51   ` sashiko-bot
2026-09-07 11:31   ` Pierre-Louis Bossart
2026-09-07 13:29     ` Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 04/11] ASoC: SDCA: add hw_ops with hw_init hook Srinivas Kandagatla
2026-09-07 11:29   ` Pierre-Louis Bossart
2026-09-07 13:33     ` Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 05/11] ASoC: SDCA: add populate_function hw_op for DT function data Srinivas Kandagatla
2026-09-07 11:28   ` Pierre-Louis Bossart
2026-09-07 13:16     ` Charles Keepax
2026-09-08 16:25   ` Charles Keepax
2026-09-08 18:00     ` Srinivas Kandagatla
2026-09-09  8:34       ` Charles Keepax
2026-09-07  8:37 ` [PATCH v2 06/11] ASoC: SDCA: class_function: xlate sound-dai cell by entity index Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 07/11] ASoC: SDCA: register SDCA_FUNCTION_TYPE_SIMPLE_JACK in class function driver Srinivas Kandagatla
2026-09-07 11:32   ` Pierre-Louis Bossart
2026-09-07  8:37 ` [PATCH v2 08/11] ASoC: SDCA: make find_sdca_control_reset() return void Srinivas Kandagatla
2026-09-07 11:32   ` Pierre-Louis Bossart
2026-09-07 13:03     ` Charles Keepax
2026-09-07 13:16       ` Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 09/11] ASoC: SDCA: add sdca_apply_default_control_classifiers() helper Srinivas Kandagatla
2026-09-07  8:37 ` [PATCH v2 10/11] dt-bindings: sound: qcom: add Tambora WCD9378 SDCA codec Srinivas Kandagatla
2026-09-07  8:56   ` sashiko-bot
2026-09-07  8:37 ` [PATCH v2 11/11] ASoC: codecs: add Qualcomm Tambora (WCD9378) " Srinivas Kandagatla
2026-09-07  9:01   ` sashiko-bot
2026-09-07 11:32   ` Pierre-Louis Bossart
2026-09-07 13:03     ` Srinivas Kandagatla
2026-09-07 19:47       ` Pierre-Louis Bossart
2026-09-07 21:26         ` Mark Brown
2026-09-07 22:37         ` Srinivas Kandagatla
2026-09-08  8:49           ` Charles Keepax
2026-09-08  9:09             ` Srinivas Kandagatla
2026-09-08 10:37               ` Richard Fitzgerald
2026-09-08 12:31                 ` Srinivas Kandagatla
2026-09-08 13:20                   ` Charles Keepax
2026-09-08 13:34                     ` Srinivas Kandagatla
2026-09-08 14:22                       ` Pierre-Louis Bossart
2026-09-08 15:33                         ` Charles Keepax
2026-09-08 15:34                           ` Srinivas Kandagatla
2026-09-08 15:58   ` Uwe Kleine-König
2026-09-08 16:20   ` Charles Keepax

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=20260907085028.110551F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=srinivas.kandagatla@oss.qualcomm.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