From: sashiko-bot@kernel.org
To: "Harendra Gautam" <harendra.gautam@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 4/9] ASoC: qcom: Add QAIF CPU DAI ops, regmap, DT parsing and platform init
Date: Mon, 24 Aug 2026 06:49:26 +0000 [thread overview]
Message-ID: <20260824064927.626781F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824063627.3595610-5-harendra.gautam@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Shared AIF enable bit is improperly cleared during concurrent loopback stream stop.
- [High] Inconsistent frame clock inversion handling between set_fmt and DT parser breaks I2S.
- [Medium] Device Tree TDM slot parameters are not validated, causing silent truncation and hardware misconfiguration.
- [Low] Missing DAI type validation in DT parser allows CIF DAIs to overwrite AIF interface configurations.
--
--- Patch [4]: [PATCH v3 4/9] ASoC: qcom: Add QAIF CPU DAI ops, regmap, DT parsing and platform init ---
commit 11d4fc6e518b0a0de63f9a65aeca246850ab08f1
Author: Harendra Gautam <harendra.gautam@oss.qualcomm.com>
Subject: ASoC: qcom: Add QAIF CPU DAI ops, regmap, DT parsing and platform init
This patch implements the CIF and AIF DAI operations for the QAIF CPU driver.
It configures the DMA paths, MI2S/TDM formats, registers the regmap, and
parses per-interface configuration from the device tree.
> diff --git a/sound/soc/qcom/qaif-cpu.c b/sound/soc/qcom/qaif-cpu.c
> new file mode 100644
> index 0000000000000..8792d01254a68
> --- /dev/null
> +++ b/sound/soc/qcom/qaif-cpu.c
[ ... ]
> +static int qaif_aif_cpu_daiops_trigger(struct snd_pcm_substream *substream,
> + int cmd, struct snd_soc_dai *dai)
> +{
> + struct qaif_drv_data *drvdata = snd_soc_dai_get_drvdata(dai);
> + const struct qaif_variant *v = drvdata->variant;
> + const struct qaif_aif_config *cfg;
> + unsigned int enable_bit;
> + int idx, ret;
> +
> + idx = v->get_dma_idx(dai->driver->id);
> + if (idx < 0) {
> + dev_err(dai->dev, "Invalid DMA index: %d\n", idx);
> + return -EINVAL;
> + }
> +
> + cfg = &drvdata->aif_intf_cfg[idx];
> + if (cfg->loopback_en)
> + enable_bit = QAIF_AIF_CTL_ENABLE_BIT;
> + else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> + enable_bit = QAIF_AIF_CTL_ENABLE_TX_BIT;
> + else
> + enable_bit = QAIF_AIF_CTL_ENABLE_RX_BIT;
> +
> + switch (cmd) {
> + case SNDRV_PCM_TRIGGER_START:
> + case SNDRV_PCM_TRIGGER_RESUME:
> + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> + ret = regmap_update_bits(drvdata->audio_qaif_map,
> + QAIF_AUD_INTF_CTL_REG(idx), enable_bit, enable_bit);
> + if (ret)
> + dev_err(dai->dev, "error setting AIF enable bit: %d\n", ret);
> + return ret;
> + case SNDRV_PCM_TRIGGER_STOP:
> + case SNDRV_PCM_TRIGGER_SUSPEND:
> + case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> + ret = regmap_update_bits(drvdata->audio_qaif_map,
> + QAIF_AUD_INTF_CTL_REG(idx), enable_bit, 0);
[Severity: High]
When loopback is enabled, enable_bit is assigned to the global
QAIF_AIF_CTL_ENABLE_BIT instead of a stream-specific bit.
If both streams are running concurrently in full-duplex, will stopping one
stream unconditionally clear this shared enable bit and disrupt the other
active stream?
[ ... ]
> +static int qaif_aif_cpu_daiops_set_fmt(struct snd_soc_dai *dai,
> + unsigned int fmt)
> +{
> + struct qaif_drv_data *drvdata = snd_soc_dai_get_drvdata(dai);
> + const struct qaif_variant *v = drvdata->variant;
> + int idx = v->get_dma_idx(dai->driver->id);
> + struct qaif_aif_config *cfg;
> +
> + if (idx < 0)
> + return -EINVAL;
> +
> + cfg = &drvdata->aif_intf_cfg[idx];
[ ... ]
> + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
> + case SND_SOC_DAIFMT_NB_NF:
> + case SND_SOC_DAIFMT_NB_IF:
> + cfg->invert_sync = (fmt & SND_SOC_DAIFMT_INV_MASK) ==
> + SND_SOC_DAIFMT_NB_IF;
> + break;
[Severity: High]
If a machine driver sets the format to SND_SOC_DAIFMT_I2S with
SND_SOC_DAIFMT_NB_NF, this code clears cfg->invert_sync to false.
However, the device tree parser hardcodes cfg->invert_sync to true for I2S.
Does this set_fmt override conflict with the hardware requirements established
during DT parsing and break the I2S setup?
[ ... ]
> +static int of_qaif_parse_aif_intf_cfg(struct device *dev,
> + struct qaif_drv_data *data)
> +{
> + const struct qaif_variant *v = data->variant;
> + struct device_node *np = dev->of_node;
> + struct device_node *intf_np;
> + struct qaif_aif_config *cfg;
> + int ret;
> + u32 dai_id;
> + int intf_idx;
> + int num_interfaces = 0;
> + u32 val_buf[QAIF_MAX_LANES];
> + int j, n;
> + unsigned long configured_intf_mask = 0;
> +
> + for_each_child_of_node(np, intf_np) {
> + if (!of_property_present(intf_np, "reg"))
> + continue;
> +
> + if (num_interfaces >= QAIF_MAX_AIF_CFG_CNT) {
> + dev_warn(dev, "Too many AIF interfaces, limiting to %d\n",
> + QAIF_MAX_AIF_CFG_CNT);
> + of_node_put(intf_np);
> + break;
> + }
> +
> + ret = of_property_read_u32(intf_np, "reg", &dai_id);
> + if (ret) {
> + dev_err(dev, "Missing reg for interface %pOFn\n", intf_np);
> + of_node_put(intf_np);
> + return ret;
> + }
> +
> + intf_idx = v->get_dma_idx(dai_id);
[Severity: Low]
This loop iterates over all child nodes with a reg property and assumes they
are AIF DAIs.
If a malformed device tree includes a CIF DAI child node, could its ID
overlap with an AIF DAI index when passed to get_dma_idx(), causing array
corruption in drvdata->aif_intf_cfg or a false duplicate registration error?
[ ... ]
> + if (!qaif_is_mi2s_port(dai_id)) {
> + ret = of_property_read_u32(intf_np, "dai-tdm-slot-width",
> + &cfg->slot_width);
> + if (ret || !cfg->slot_width) {
> + dev_err(dev, "Missing/invalid dai-tdm-slot-width for %pOFn\n",
> + intf_np);
> + of_node_put(intf_np);
> + return ret ? ret : -EINVAL;
> + }
> + ret = of_property_read_u32(intf_np, "dai-tdm-slot-num",
> + &cfg->slot_num);
[Severity: Medium]
The values from dai-tdm-slot-width and dai-tdm-slot-num are read directly
into cfg without bounds checking against hardware maximums.
In qaif_aif_cpu_daiops_hw_params(), the unvalidated slot_width is shifted
and masked:
qaif_aif_cpu_daiops_hw_params()
...
QAIF_AIF_SLOT_WIDTH(slot_width) |
...
If a device tree specifies a width greater than 32, does this result in
silent bitwise truncation and hardware misconfiguration instead of returning
an error during probe?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824063627.3595610-1-harendra.gautam@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-08-24 6:49 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 6:36 [PATCH v3 0/9] ASoC: qcom: Add QAIF driver for Shikra audio platform Harendra Gautam
2026-08-24 6:36 ` [PATCH v3 1/9] ASoC: dt-bindings: qcom,qaif-cpu: Add binding Harendra Gautam
2026-08-24 6:46 ` sashiko-bot
2026-08-24 8:39 ` Manuel Ebner
2026-08-24 9:14 ` Harendra Gautam
2026-08-25 5:59 ` Krzysztof Kozlowski
2026-08-26 8:31 ` Mohammad Rafi Shaik
2026-08-26 9:39 ` Harendra Gautam
2026-08-26 9:43 ` Srinivas Kandagatla
2026-08-26 9:55 ` Harendra Gautam
2026-08-26 10:01 ` Srinivas Kandagatla
2026-08-26 10:06 ` Harendra Gautam
2026-08-26 10:25 ` Harendra Gautam
2026-08-26 23:32 ` Mark Brown
2026-08-27 4:00 ` Harendra Gautam
2026-08-24 6:36 ` [PATCH v3 2/9] ASoC: qcom: Add QAIF shared data structures and variant interface Harendra Gautam
2026-08-24 6:36 ` [PATCH v3 3/9] ASoC: qcom: Add QAIF hardware register map Harendra Gautam
2026-08-24 6:48 ` sashiko-bot
2026-08-24 6:36 ` [PATCH v3 4/9] ASoC: qcom: Add QAIF CPU DAI ops, regmap, DT parsing and platform init Harendra Gautam
2026-08-24 6:49 ` sashiko-bot [this message]
2026-08-24 6:36 ` [PATCH v3 5/9] ASoC: soc-core: Add snd_soc_of_xlate_dai_name() generic helper Harendra Gautam
2026-08-25 4:20 ` Kuninori Morimoto
2026-08-24 6:36 ` [PATCH v3 6/9] ASoC: qcom: Add QAIF PCM operations Harendra Gautam
2026-08-24 6:53 ` sashiko-bot
2026-08-24 9:25 ` Markus Elfring
2026-08-24 10:10 ` Harendra Gautam
2026-08-25 6:07 ` Krzysztof Kozlowski
2026-08-24 6:36 ` [PATCH v3 7/9] ASoC: qcom: Add QAIF IRQ handling, suspend/resume and platform register Harendra Gautam
2026-08-24 6:53 ` sashiko-bot
2026-08-24 6:36 ` [PATCH v3 8/9] ASoC: qcom: Add Shikra QAIF support Harendra Gautam
2026-08-26 8:35 ` Mohammad Rafi Shaik
2026-08-26 8:58 ` Harendra Gautam
2026-08-26 10:13 ` Srinivas Kandagatla
2026-08-26 10:37 ` Harendra Gautam
2026-08-24 6:36 ` [PATCH v3 9/9] MAINTAINERS: Add Qualcomm QAIF driver entry Harendra Gautam
2026-08-24 8:22 ` Abel Vesa
2026-08-24 8:31 ` Harendra Gautam
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=20260824064927.626781F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=harendra.gautam@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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