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=1796406161; b=atr9pzUBZVBKFi5p/4fe9OAtssTN8MjHk/CvDtOfSUIV6LQNS251e9Eb7cruManHhv8t m4u5YTVQePOhqGs3gp/fY+yO6sZiLktPWIQl068HBU0oNlP+zzqaBtO4JYIh6fNE1IpF/ 5+28atcylL4g6rSICdKgRp6Q0dnpDxsyg6DOH8KOJ+BIaWXBvjjkeuV7v4YZd0vartC9q L7ObtSVTHqLY8n+gK9GBy+zwD647lSQg81r5uysllipZIfCf95RW+In4iOuP637a+QnTp j6Bm479U1k7AvkIuFajwLxxN6K6ybRJWPQRxvX5KFioCx7j+TUsCZYG+2KBfZwl7j5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406161; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=9qZs4sYy0Uxe13FebkKMcIsFGn3QGR2vdJS1kayKTxY=; b=Txz/eCL4y62fydrgYGFGapwaFVcVp7weG8iBenKfBzsmDg1IKYjh0jsw9hbqV5YzOhdg QeoZsUtQFNOWan5RW9k0IeesYq44EKuIfZTJOLyqwHvhvmh5Xy8pwM4TgR9Fdxl5gqM1h 5vMHfjtzupbhvuH8MhsLiSYfthoT4E4DA0J5/156euc/aAfei3BD5DZCaXMMS46E8FfwO o/Dgx62+fMAKZ187xS9eWnYRIPukeP9iW7/PF3Sp3EWVwT2ylAfI4ahMHJwE2NguSd934 7doPym7scjKEvPjran3WppaUYgv4j/PQ4sMr7vMDD8OxKPYKePhcgn5d0f2pnwAdGvQ== 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=GFj73e5V; 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 74BB4606A322; Fri, 4 Dec 2026 17:42:41 +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=GFj73e5V Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18F2A1F00A06; Fri, 4 Dec 2026 17:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796406161; bh=9qZs4sYy0Uxe13FebkKMcIsFGn3QGR2vdJS1kayKTxY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GFj73e5VRZBn8UEU3OsRdQD9jJQ3b7G8lLCFtZOVLBN8GcQnECLPuzVjBtEMn2bA8 ShPa0IqV7R09FQ6m96Iog+X3+a6LFtzu1r9mzHQC1BnZ8lP01veol7ABZL6mSp/85z PkulGUq9cDto6ssbGwTXMAipdvvQmzaApxDetbHQaSkBgb7bW5BKAtj0+WxRknRAHt fTOF7hgjWylhQ+mUP35LWgyLmRA4FkiTYTDrgNUogXzdfKlCHqpRBrdFOMNCiJHqiC 7kc5A2FKeVPcYqMsIemSNIvx8UhT6gHYmgURoZKXfVgecFdS8G755wwMg3E6OSP5Lo yt9uLrTkPlObw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 17/19] ASoC: qcom: add SM8650 LPASS CPU driver Reply-To: sashiko-reviews@lists.linux.dev To: "Neil Armstrong" Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204-topic-sm8650-el2-v3-17-8384ef0ac751@linaro.org> References: <20261204-topic-sm8650-el2-v3-0-8384ef0ac751@linaro.org> <20261204-topic-sm8650-el2-v3-17-8384ef0ac751@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 17:42:40 +0000 X-Mailing-List: devicetree@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 8 potential issues to consider: - [High] ASoC: qcom: codec_dma_enable MMIO/IRQ claims collide with SM8650 MI2S LPAIFs - [High] ASoC: qcom: LPM memremap() mappings leak and hit free_pages_exact() on teardown - [Medium] ASoC: qcom: u32 underflow in lpass_platform_allocate_lpm() - [Medium] ASoC: qcom: unchecked memremap() in LPM prealloc causes NULL dereference - [Medium] ASoC: qcom: sm8650 WRDMA channel range exceeds LPASS_MAX_CDC_DMA_CHANNELS - [Medium] ASoC: qcom: lpass: missing CDC DMA regcache sync on suspend/resume - [Low] ASoC: qcom: commit message omits Quaternary and Quinary MI2S DAIs - [Low] ASoC: qcom: unsigned underflow in lpass_platform_allocate_lpm() -- commit 7cec95248eea9dc0ea78ea2e92f97a7dcf6185dd Author: Neil Armstrong ASoC: qcom: add SM8650 LPASS CPU driver This commit adds the SM8650 LPASS CPU driver variant with MI2S, DP, and codec DMA DAIs, their LPAIF instances, clocks, and LPM DMA buffer configurations. > Add the SM8650 lpass-cpu variant with the Primary, Secondary, Tertiary, > Senary & Septenary MI2S, DP and codec DMA DAIs, their LPAIF instances, > clocks and LPM DMA buffers. [Severity: Low] This isn't a bug, but the commit message omits Quaternary and Quinary MI2S even though sm8650_lpass_cpu_dai_driver[] and sm8650_lpaif_mi2s_desc[] define all seven MI2S interfaces (Primary through Septenary). > diff --git a/sound/soc/qcom/lpass-sm8650.c b/sound/soc/qcom/lpass-sm8650.c > new file mode 100644 > index 0000000000000..53c155e1b6396 > --- /dev/null > +++ b/sound/soc/qcom/lpass-sm8650.c > @@ -0,0 +1,653 @@ [ ... ] > +static int sm8650_lpass_dev_suspend(struct device *dev) > +{ > + struct lpass_data *drvdata =3D dev_get_drvdata(dev); > + > + clk_bulk_disable_unprepare(drvdata->num_clks, drvdata->clks); > + return 0; > +} > + > +static const struct dev_pm_ops sm8650_lpass_pm_ops =3D { > + SYSTEM_SLEEP_PM_OPS(sm8650_lpass_dev_suspend, sm8650_lpass_dev_resume) > +}; [Severity: Medium] Will CDC DMA streams lose their hardware DMA register state across system suspend and resume? lpass_platform_pcmops_suspend() and lpass_platform_pcmops_resume() in sound/soc/qcom/lpass-platform.c only cache-only and regcache_sync() hdmiif_map and lpaif[i].map, omitting rxtx_lpaif_map, va_lpaif_map, and the newly exposed wsa_lpaif_map from commit "ASoC: qcom: lpass: add support for optional WSA interface". Because the CDC DMA descriptors advertise SNDRV_PCM_INFO_RESUME, resume calls trigger(SNDRV_PCM_TRIGGER_RESUME) without prepare(). After LPASS power collapse, LPAIF_DMABASE_REG, LPAIF_DMABUFF_REG, and LPAIF_DMAPER_REG stay zeroed in hardware, breaking stream resume and pointer calculations. [ ... ] > + { > + .reg_name =3D "lpass-rxtx-lpaif", > + .irq_name =3D "lpass-irq-rxtxif", > + .lpm_type =3D LPASS_RXTX_CDC_LPM, > + .port_desc =3D (const struct mi2s_port_desc[]) { > + { .intf =3D 0, .id =3D MI2S_QUATERNARY, }, > + }, > + .port_desc_count =3D 1, > + }, > + { > + .reg_name =3D "lpass-va-lpaif", > + .irq_name =3D "lpass-irq-vaif", > + .lpm_type =3D LPASS_VA_CDC_LPM, > + .port_desc =3D (const struct mi2s_port_desc[]) { > + { .intf =3D 0, .id =3D MI2S_QUINARY, }, > + }, > + .port_desc_count =3D 1, > + }, [Severity: High] Does enabling any Codec DMA DAI alongside MI2S_QUATERNARY or MI2S_QUINARY fail probe with -EBUSY? of_lpass_cpu_parse_dai_data() sets drvdata->codec_dma_enable for any Codec DMA node (RXTX, VA, or WSA). asoc_qcom_lpass_cpu_platform_probe() then exclusively maps both lpass-rxtx-lpaif and lpass-va-lpaif via devm_platform_ioremap_resource_byname(). lpass_cpu_init_lpaif() then tries to map the same region again for MI2S_QUATERNARY or MI2S_QUINARY and fails probe with -EBUSY, even on non-conflicting boards such as WSA Codec DMA with MI2S_QUATERNARY. asoc_qcom_lpass_platform_register() hits the same -EBUSY conflict by requesting lpass-irq-rxtxif and lpass-irq-vaif without IRQF_SHARED whenever codec_dma_enable is set. lpass_platform_allocate_lpm() also unconditionally reserves 16 KiB for rxtx_lpm_offset when RXTX is unused. > + { > + .reg_name =3D "lpass-wsa-lpaif", > + .irq_name =3D "lpass-irq-wsaif", > + .lpm_type =3D LPASS_RXTX_CDC_LPM, > + .port_desc =3D (const struct mi2s_port_desc[]) { > + { .intf =3D 0, .id =3D MI2S_SENARY, }, > + }, > + .port_desc_count =3D 1, > + }, [Severity: Medium] Can rxtx_cdc_dma_lpm_remain underflow in lpass_platform_allocate_lpm() when the DT LPM region is smaller than the Codec DMA reservation? In sound/soc/qcom/lpass-platform.c (added in commit "ASoC: qcom: lpass: allocate LPM buffer memory to DAIs"), lpass_platform_allocate_lpm() subtracts LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE * 2 from the unsigned u32 rxtx_cdc_dma_lpm_remain (twice when wsa_enable is set) without checking that enough space remains: sound/soc/qcom/lpass-platform.c:lpass_platform_allocate_lpm() { ... if (drvdata->codec_dma_enable) { drvdata->rxtx_lpm_offset =3D rxtx_cdc_dma_lpm_offset; rxtx_cdc_dma_lpm_offset +=3D LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE * 2; rxtx_cdc_dma_lpm_remain -=3D LPASS_RXTX_CDC_DMA_LPM_BUFF_SIZE * 2; ... } If the region is undersized, rxtx_cdc_dma_lpm_remain wraps to a large positive value, defeating the subsequent LPASS_RXTX_CDC_LPM capacity check for SM8650 MI2S ports and causing memremap() and io_remap_pfn_range() to map physical addresses beyond the LPM window. [Severity: Low] Can va_cdc_dma_lpm_remain similarly underflow in lpass_platform_allocate_lpm() when drvdata->va_enable is set? The subtraction of LPASS_VA_CDC_DMA_LPM_BUFF_SIZE from the unsigned u32 va_cdc_dma_lpm_remain is also unchecked, so an undersized VA LPM DT region wraps around and bypasses the LPASS_VA_CDC_LPM bounds check for MI2S_QUINARY, assigning out-of-bounds physical addresses to memremap(). > + { > + .reg_name =3D "lpass-aud-lpaif", > + .irq_name =3D "lpass-irq-audif", > + .lpm_type =3D LPASS_RXTX_CDC_LPM, > + .port_desc =3D (const struct mi2s_port_desc[]) { > + { .intf =3D 0, .id =3D MI2S_SEPTENARY, }, > + { .intf =3D 1, .id =3D MI2S_TERTIARY, }, > + }, > + .port_desc_count =3D 2, > + }, [Severity: Medium] Can an unchecked memremap() failure for SM8650 LPM MI2S buffers cause a NULL pointer dereference in lpass_platform_copy()? lpass_platform_prealloc_lpm_mi2s_buffer() (and lpass_platform_prealloc_cdc_dma_buffer()) in sound/soc/qcom/lpass-platform.c store memremap(buf->addr, buf->bytes, MEMREMAP_WC) in buf->area without checking for NULL and return 0. Because lpass_component_driver supplies .copy =3D lpass_platform_copy, ALSA's pcm_sanity_check() skips its !runtime->dma_area check, so a subsequent PCM read or write passes NULL plus offset to copy_from_iter_toio() or copy_to_iter_fromio(). [Severity: High] Do the LPM memremap() mappings leak and trigger free_pages_exact() on an I/O mapping during PCM teardown? lpass_platform_prealloc_lpm_mi2s_buffer() and lpass_platform_prealloc_cdc_dma_buffer() set buf->dev.type to SNDRV_DMA_TYPE_CONTINUOUS and assign an unmanaged memremap() pointer to buf->area, while lpass_component_driver provides no .pcm_free callback. On teardown or unbind, snd_pcm_free() -> do_free_pages() hits WARN_ON(card->total_pcm_alloc_bytes < bytes) and passes the memremap() address to free_pages_exact() instead of memunmap(), leaking the mapping and risking page-allocator corruption. [ ... ] > + .rxtx_wrdma_channel_start =3D 5, > + .rxtx_wrdma_channels =3D 4, > + .va_wrdma_reg_base =3D 0x1a000, > + .va_wrdma_reg_stride =3D 0x1000, > + .va_wrdma_channel_start =3D 5, > + .va_wrdma_channels =3D 3, > + .va_irq_reg_base =3D 0x9000, > + .va_irq_reg_stride =3D 0x1000, > + .va_irq_ports =3D 5, > + .wsa_irq_reg_base =3D 0x9000, > + .wsa_irq_reg_stride =3D 0x1000, > + .wsa_irq_ports =3D 5, > + .wsa_wrdma_reg_base =3D 0x1a000, > + .wsa_wrdma_reg_stride =3D 0x1000, > + .wsa_wrdma_channel_start =3D 5, > + .wsa_wrdma_channels =3D 4, [Severity: Medium] Can these WRDMA channel counts overflow drvdata->rxtx_substream[] and drvdata->wsa_substream[]? With channel_start =3D 5 and channels =3D 4, sm8650_lpass_alloc_dma_channel= () can allocate channel 8, exceeding LPASS_MAX_CDC_DMA_CHANNELS (8). Four concurrently opened DAI links on LPASS_CDC_DMA_TX3 then write past rxtx_substream[7] into va_substream[0] (or wsa_substream[8] into clks). In addition, lpass_platform_rxtxif_irq() and lpass_platform_wsaif_irq() only iterate up to LPASS_MAX_CDC_DMA_CHANNELS, so interrupts for channel 8 would never be serviced. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-topic-sm86= 50-el2-v3-0-8384ef0ac751@linaro.org?part=3D17