From: sashiko-bot@kernel.org
To: "Srinivas Kandagatla" <srinivas.kandagatla@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [RFC PATCH 1/8] ASoC: SDCA: hw_params: program upstream Input Terminals for OT DAI
Date: Wed, 22 Jul 2026 23:54:07 +0000 [thread overview]
Message-ID: <20260722235408.2DEC71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722234221.884765-2-srinivas.kandagatla@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The recursive graph traversal in `set_input_terminal_sources()` lacks cycle detection, allowing malformed firmware topologies to cause infinite recursion and a kernel stack overflow.
- [High] Output Terminal format parameters are blindly propagated to all upstream Input Terminals, breaking topologies with intermediate processing units (e.g., Sample Rate Converters or Mixers).
- [High] Unconditional traversal of the static source graph configures inactive alternative paths and clobbers shared hardware nodes without mutual exclusion.
--
--- Patch [1]: [RFC PATCH 1/8] ASoC: SDCA: hw_params: program upstream Input Terminals for OT DAI ---
commit e1c19ca1fbb78240fd7df2f80b2ad3f08d85052a
Author: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
ASoC: SDCA: hw_params: program upstream Input Terminals for OT DAI
For a capture stream the DAI is the Output Terminal so
sdca_asoc_hw_params() only programs the OT itself: cluster, clock
and Usage. The upstream Input Terminals that actually source the
audio never get their Usage, ClusterIndex or clock programmed, so
the power domain comes up but no samples are produced.
Walk the source graph from the OT and program every Input Terminal
reachable through it.
> diff --git a/sound/soc/sdca/sdca_asoc.c b/sound/soc/sdca/sdca_asoc.c
> index b4dedba719dc6..ac688cd629706 100644
> --- a/sound/soc/sdca/sdca_asoc.c
> +++ b/sound/soc/sdca/sdca_asoc.c
[ ... ]
> @@ -1726,6 +1726,51 @@ static int set_usage(struct device *dev, struct regmap *regmap,
> return -EINVAL;
> }
>
> +/*
> + * For a capture stream the ASoC DAI is the Output Terminal, so hw_params
> + * only programs the OT itself. The upstream Input Terminal(s) that
> + * actually source the audio (e.g. a mic input behind a power-domain entity)
> + * never get their Usage / ClusterIndex / clock programmed and stay inactive,
> + * so the power domain comes up but no samples are produced. Walk the source
> + * graph from the OT and program every Input Terminal we reach.
> + */
> +static int set_input_terminal_sources(struct device *dev, struct regmap *regmap,
> + struct sdca_function_data *function,
> + struct sdca_entity *entity,
> + int channels, int rate, int width)
> +{
> + int i, ret;
> +
> + for (i = 0; i < entity->num_sources; i++) {
> + struct sdca_entity *src = entity->sources[i];
[Severity: High]
Does this code inadvertently configure inactive alternative paths?
The loop iterates over all statically defined sources in the firmware graph,
which might ignore active ALSA/DAPM routing state like MUX selections.
Additionally, if an IT is actively shared between multiple OTs, could starting
a stream on the second OT dynamically overwrite the active IT's registers
without locking and corrupt the first stream?
> +
> + if (src->type == SDCA_ENTITY_TYPE_IT) {
> + ret = set_cluster(dev, regmap, function, src, channels);
> + if (ret)
> + return ret;
> +
> + if (src->iot.clock) {
> + ret = set_clock(dev, regmap, function,
> + src->iot.clock, rate);
> + if (ret)
> + return ret;
> + }
> +
> + ret = set_usage(dev, regmap, function, src,
> + SDCA_CTL_IT_USAGE, rate, width);
[Severity: High]
Can this break topologies that use intermediate processing units like a
Sample Rate Converter or channel mixer?
This propagates the Output Terminal's format parameters (channels, rate, width)
directly to all upstream Input Terminals. If the IT does not natively support
the exact same hardware parameters as the OT, won't set_usage() or
set_cluster() fail with -EINVAL?
> + if (ret)
> + return ret;
> + }
> +
> + ret = set_input_terminal_sources(dev, regmap, function, src,
> + channels, rate, width);
[Severity: High]
Is it possible for a malformed firmware topology to cause an infinite loop
here?
The recursive graph traversal in set_input_terminal_sources() doesn't appear
to have cycle detection. If entity->sources contains a cycle, could this
lead to a kernel stack overflow?
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722234221.884765-1-srinivas.kandagatla@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-07-22 23:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 23:42 [RFC PATCH 0/8] ASoC: SDCA: enable on DT platforms and add Qualcomm WCD9378 (Tambora) codec Srinivas Kandagatla
2026-07-22 23:42 ` [RFC PATCH 1/8] ASoC: SDCA: hw_params: program upstream Input Terminals for OT DAI Srinivas Kandagatla
2026-07-22 23:54 ` sashiko-bot [this message]
2026-07-22 23:42 ` [RFC PATCH 2/8] ASoC: SDCA: allow building without ACPI Srinivas Kandagatla
2026-07-22 23:59 ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 3/8] ASoC: SDCA: expose class helpers with hw_ops for non-DisCo platforms Srinivas Kandagatla
2026-07-22 23:58 ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 4/8] ASoC: SDCA: add PDE pre/post-pmu hooks to hw_ops Srinivas Kandagatla
2026-07-22 23:56 ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 5/8] ASoC: SDCA: class_function: xlate sound-dai cell by entity index Srinivas Kandagatla
2026-07-22 23:57 ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 6/8] ASoC: SDCA: register SDCA_FUNCTION_TYPE_SIMPLE_JACK in class function driver Srinivas Kandagatla
2026-07-22 23:56 ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 7/8] dt-bindings: sound: qcom: add Tambora WCD9378 SDCA codec Srinivas Kandagatla
2026-07-22 23:51 ` sashiko-bot
2026-07-22 23:42 ` [RFC PATCH 8/8] ASoC: codecs: add Qualcomm Tambora (WCD9378) " Srinivas Kandagatla
2026-07-23 0:03 ` sashiko-bot
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=20260722235408.2DEC71F000E9@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