From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796420393; b=QZO2wTRQv3Xhm2D3FSorwN4pP9/smrLRNDZLQuDvGRtmqEPgDWhepAjRE6JJW/S0mMVa ttT92eMsuWDQCXp9xcTURjoiDtud4KxqPxt3+su2pTChw9pxHBiJcIeS2jyWEqJSnW/5Z d7+dqz+Obz2p3LKvD33FbGbTGxWNar0ehvGJPm34ZCwA9h3SE2CgBrvExNAXS+CxGlXYE Fni2KogY7PcTnE+d/RXfPyxLFDFZhLwEEvpSncnn7KLnrBDEnO/ImlFqiLvbQnY0+9yLA M3hePjgY7m8MnpRi++tcKY0Zxtzg84KXlIUwKUrnC5e6OvlPQoTA02rMGv58ydnUuww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796420393; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=4+oAmUC7tCzW/x57b/a9ECG6txsqZ2fE3QPWHrIBiok=; b=3eJnQojmKyQvq2e3uN5T3oewhTlBv9/TpR9QmgDUUH+z0eitfZL+pIXn9W3Ia1nWRCsC p4xsK5akXZPPRFKIRIIxS/X6RZqibYIqN9v8wEiX0vz82BKTsyXYwBInldnWQUw1BPboY bCoUoPX0wewrPR7Y7+OoVs1a2msWARw6JZ3HzOJnDeV0KBc4ynsD61yBg/sf4JK1bQBii oDlB1jmcZq3NQ6NCkultIt0cTptLBEwowFSUGHkeafi8lsUvrbyGyp7k1eeORf9vcay0T gDX5k3pmGlBRXdEpObvHdvCRbOUsQHmOym388ZavUZ/+CDyZlMUqfk9j9QajfQt2qLA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WOp0wxjs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FAC9606A322 for ; Fri, 4 Dec 2026 21:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WOp0wxjs Received: by smtp.kernel.org (Postfix) with ESMTPSA id B936D1F00936; Fri, 4 Dec 2026 21:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796420392; bh=4+oAmUC7tCzW/x57b/a9ECG6txsqZ2fE3QPWHrIBiok=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=WOp0wxjsDBViVHrOvUptFEKtYAp14vIr9SeXM0uDUrpHd6s8M+rBZ2cdII12m0HKD BmgQfvVcF3tHX3dHd8AMi4QVzZfW2cokxrygyQ5wqil2ro5mQZacvfG/xV+6gzxC27 6A+Xtdq09+uCZb0F+7M7hgp9BClPsmFX1hUxV1f6pzmAE48/a2ZvnNGz8gMzdTAh+2 1tG7QrrLA1F8Tu2+SPq5kEAgT7xqnrmsQskrlsOw+RHqOm1DM2kFZS8Uk/i7eqFCjV xnn+JkDVK3uysgouszO3rphtsGUbI3nUj8D8qAqWfd1ZhNS7nzDZdlxNRUfsUza3Uf ZUnbpnJvkrpuA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] ASoC: amd: acp: add DMIC capture switch Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?QmFoYWTEsXIgSGFtemEgw5Z6dMO8cms=?= Cc: linux-sound@vger.kernel.org In-Reply-To: <20261204211751.13825-1-bahadirhamza2@gmail.com> References: <20261204211751.13825-1-bahadirhamza2@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 21:39:52 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Medium] ASoC: amd: acp: prepare and resume gate DMIC without arming dmic_clearing - [Medium] ASoC: amd: acp: acp_dmic_dai_trigger() and switch put miss PDM gate sync - [Medium] ASoC: amd: acp: full-buffer memset and MMIO read in acp_dma_pointer() - [Medium] ASoC: amd: acp: undocumented ACP_WOV_MISC_CTRL bit 5 written on all Renoir - [Medium] ASoC: amd: acp: DMIC mute bypassed via mmap and full-buffer memset in hardirq - [Low] ASoC: amd: acp: acp_pcm_probe() exposes DMIC switch without PDM hardware -- commit 861aa6259e9d977790367dd9467eb2b0278ea46e Author: Bahad=C4=B1r Hamza =C3=96zt=C3=BCrk ASoC: amd: acp: add DMIC capture switch This commit adds a "DMIC Capture Switch" mixer control for the ACP PDM microphone. While muted, it gates the PDM data input via bit 5 of ACP_WOV_MISC_CTRL on Renoir and zeroes the capture DMA buffer on each pointer query, continuing for 10 ms after unmuting to drop the decimator step. [ ... ] > diff --git a/sound/soc/amd/acp/acp-pdm.c b/sound/soc/amd/acp/acp-pdm.c > index 1bfc34c2aa536..0daa935a5b057 100644 > --- a/sound/soc/amd/acp/acp-pdm.c > +++ b/sound/soc/amd/acp/acp-pdm.c > @@ -40,6 +40,7 @@ static int acp_dmic_prepare(struct snd_pcm_substream *s= ubstream, > dmic_ctrl =3D readl(chip->base + ACP_WOV_MISC_CTRL); > dmic_ctrl |=3D PDM_MISC_CTRL_MASK; > writel(dmic_ctrl, chip->base + ACP_WOV_MISC_CTRL); > + acp_dmic_update_gate(chip, READ_ONCE(chip->dmic_mute)); [Severity: Medium] Does acp_dmic_prepare() (and set_acp_pdm_clk() on resume) leave stream->dmic_clearing and stream->dmic_open_pos out of sync with the gate? A freshly opened stream starts with dmic_clearing =3D false. If the stream= is prepared while muted and unmuted before the first acp_dma_pointer() call, acp_dmic_mute_update() clears PDM_MISC_DATA_GATE and immediately returns at "else if (!stream->dmic_clearing)" without zeroing runtime->dma_area or waiting ACP_DMIC_SETTLE_MS. That delivers up to a full period of gated full-scale negative samples plus the decimator unmute step on Renoir (or live muted audio on other revisions) as a loud pop. Re-preparing an already-open stream after stop or suspend also carries over stale dmic_clearing and dmic_open_pos values, which can cut the settle period short or zero the start of an unmuted capture. Initializing both fields from the mute state in prepare and resume would keep them in sync. > diff --git a/sound/soc/amd/acp/acp-platform.c b/sound/soc/amd/acp/acp-pla= tform.c > index f2c8853775ad3..9deeb9d4d023d 100644 > --- a/sound/soc/amd/acp/acp-platform.c > +++ b/sound/soc/amd/acp/acp-platform.c [ ... ] > +static void acp_dmic_mute_update(struct acp_chip_info *pdata, > + struct snd_pcm_substream *substream, > + struct acp_stream *stream, u64 total, > + u32 buffersize) > +{ > + struct snd_pcm_runtime *runtime =3D substream->runtime; > + bool mute =3D READ_ONCE(pdata->dmic_mute); > + u32 settle; > + > + acp_dmic_update_gate(pdata, mute); > + > + if (mute) { > + stream->dmic_clearing =3D true; > + stream->dmic_open_pos =3D U64_MAX; > + } else if (!stream->dmic_clearing) { > + return; > + } else if (stream->dmic_open_pos =3D=3D U64_MAX) { > + stream->dmic_open_pos =3D total; > + } else { > + settle =3D frames_to_bytes(runtime, runtime->rate / 1000 * > + ACP_DMIC_SETTLE_MS); > + if (total < stream->dmic_open_pos || > + total - stream->dmic_open_pos >=3D settle) > + stream->dmic_clearing =3D false; > + } > + > + memset(runtime->dma_area, 0, buffersize); > +} [Severity: Medium] Is it safe to memset() the entire capture buffer on every acp_dma_pointer() call? acp_dma_pointer() runs in hardirq context from acp_irq_handler() while holding chip->acp_lock and the PCM substream spinlock, and on every userspace status/delay ioctl with interrupts disabled. Zeroing up to 64 KiB of coherent DMA memory on every call stalls sibling I2S streams and shared IRQ handlers, skews the hardware-position timestamp taken right after ->pointer() in snd_pcm_update_hw_ptr0(), and overwrites already-captured unread frames while userspace is reading them. On Renoir, acp_dmic_update_gate() also does a redundant PCIe MMIO readl() on every muted pointer call because it does not return early when mute =3D=3D pdata->dmic_gated. [ ... ] > +static int acp_dmic_switch_put(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + struct snd_soc_component *component =3D snd_kcontrol_chip(kcontrol); > + struct acp_chip_info *pdata =3D dev_get_platdata(component->dev); > + bool mute =3D !ucontrol->value.integer.value[0]; > + > + if (mute =3D=3D READ_ONCE(pdata->dmic_mute)) > + return 0; > + > + /* Applied by the next prepare or position read */ > + WRITE_ONCE(pdata->dmic_mute, mute); > + return 1; > +} [Severity: Medium] Can live microphone audio reach runtime->dma_area on Renoir because the hardware gate is deferred out of acp_dmic_switch_put() and not synced in acp_dmic_dai_trigger()? If the switch is muted after acp_dmic_prepare() or while the stream is paused, acp_dmic_dai_trigger() enables PDM DMA without setting PDM_MISC_DATA_GATE, so up to a full period of live audio is written to memory before the first acp_dma_pointer() call. The same window occurs after muting an already running stream, and unmuting between prepare and SNDRV_PCM_TRIGGER_START leaves the gate set for the first period. [ ... ] > +static int acp_pcm_probe(struct snd_soc_component *component) > +{ > + struct snd_soc_dai *dai; > + > + /* Only offer the switch when the PDM DAI is part of this component */ > + for_each_component_dais(component, dai) { > + if (dai->driver->id =3D=3D DMIC_INSTANCE) > + return snd_soc_add_component_controls(component, > + acp_dmic_controls, > + ARRAY_SIZE(acp_dmic_controls)); > + } > + > + return 0; > +} [Severity: Low] Will this expose a non-functional "DMIC Capture Switch" on I2S-only ACP configurations? All four ACP platform drivers (acp-renoir.c, acp-rembrandt.c, acp63.c, acp70.c) unconditionally include an acp-pdm-dmic entry with DMIC_INSTANCE in their static DAI arrays, so the loop always matches even when no PDM microphone is present. Checking pdata->is_pdm_dev && pdata->is_pdm_config here, as create_acp_platform_devs() in acp-pci.c does, would restrict the control to platforms with PDM hardware. > diff --git a/sound/soc/amd/acp/amd.h b/sound/soc/amd/acp/amd.h > index 73a028e672462..e150706d00edd 100644 > --- a/sound/soc/amd/acp/amd.h > +++ b/sound/soc/amd/acp/amd.h > @@ -131,6 +131,11 @@ > #define PDM_DEC_64 0x2 > #define PDM_CLK_FREQ_MASK 0x07 > #define PDM_MISC_CTRL_MASK 0x18 > +/* > + * Not documented: with this bit set the PDM data input is gated and the > + * decimator outputs a constant value instead of microphone data. > + */ > +#define PDM_MISC_DATA_GATE BIT(5) [Severity: Medium] Should an undocumented ACP_WOV_MISC_CTRL bit observed on a single laptop be written across all ACP_RN_PCI_ID Renoir systems? In 1-bit PDM, a constant all-zero bitstream decodes to full-scale negative output, which is also consistent with a data-lane mux selecting an unconnected lane or a clock/test mode rather than a dedicated mute gate. Without hardware documentation confirming bit 5, setting it globally on Renoir risks breaking PDM capture or failing to mute microphones wired to other lanes on untested boards. [ ... ] > +static inline void acp_dmic_update_gate(struct acp_chip_info *pdata, boo= l mute) > +{ > + u32 ctrl, val; > + > + if (pdata->acp_rev !=3D ACP_RN_PCI_ID || (!mute && !pdata->dmic_gated)) > + return; > + > + ctrl =3D readl(pdata->base + ACP_WOV_MISC_CTRL); > + val =3D mute ? ctrl | PDM_MISC_DATA_GATE : ctrl & ~PDM_MISC_DATA_GATE; > + if (val !=3D ctrl) > + writel(val, pdata->base + ACP_WOV_MISC_CTRL); > + pdata->dmic_gated =3D mute; > +} [Severity: Medium] Does limiting hardware gating to ACP_RN_PCI_ID allow muted audio to leak through mmap on Rembrandt, ACP63, and ACP70/71/72? acp_pcm_probe() exposes "DMIC Capture Switch" on all those platforms, and the ACP capture hardware advertises SNDRV_PCM_INFO_MMAP. Because PDM DMA continues writing live microphone samples into runtime->dma_area between pointer queries while muted, an mmap client reading ahead of hw_ptr can capture live audio while the switch and any UCM-linked mic mute LED report muted; on Renoir, deferring the gate out of acp_dmic_switch_put() leaves the same window until the next pointer read. Relying on a full-buffer memset() in acp_dma_pointer() to clear the buffer retroactively also adds hardirq spinlock latency in acp_irq_handler() under chip->acp_lock and the PCM substream lock. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204211751.1382= 5-1-bahadirhamza2@gmail.com?part=3D1