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=1796285298; b=o/MNiuCcUJ+ouq4r4orz1jLTcv2TT9yN2AAyvNh8EC3btAV+phoijvKZhatfA6FFK+M6 qx/PCd7V2YzrU0DGqdLzvQk4HaQ7ANJARYGKpAiQ6FtxlNjIhZaC6cxveVXuFZpjZrS4q DP3U1CAp3LF11a78TYHS6sD5cQCePnYONLeTPrmytrI3mUSJU7fNrno8BPXIX85Gcyc/z 6INFBBqW4reBU9A89/T+ZuuEG12f5Wcjx5UTlZfgjhGEdDHN0z4ZVnmqj/CdttcuUKSqs T4elbrmfU0sEZcXlG6GPnJL5YdddRvAXJEhm0d+4qqYmmyRK3DIsUgiIlddGE347f2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796285298; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=7JkpqPHLFheoWVMqeUKhUNKSmQReqiQ/hCaWmU5IRwE=; b=JnsnawS3PTdXTX6Y9b8ynuTwnJCAfy8ws5IJ4hAxzuLNv9A+dmdjsRphLJOSSTxgO1PB QXVHowZWcTy9+gE6qDW1+BQvliApr9+I2C6w2ug89pNE8tsKKjHSIf0THcARTnBQTpL5H SAK18uhO2dHD0ssNA5AwHWMMh25AMbB44/fWWnI06V+RSQR86RzU+FuD1TVIQ2brgHzty +IBFaMxXBubOrPQJjxXlSHjXSBuW83fm5wOXyl+1XaI8ZFyPiyGffoSkXU+WvVdH8xImj v0SZvB32wK4j2AzZZtV5yWbeZndRb3YWP3kP/IXWWv9gXj1CZV04kznUJXNYFRl6AXw== 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="Z16i/S2Q"; 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 2A42F606A32C for ; Thu, 3 Dec 2026 08:08:18 +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=Z16i/S2Q Received: by smtp.kernel.org (Postfix) with ESMTPSA id E81881F000C1; Thu, 3 Dec 2026 08:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796285298; bh=7JkpqPHLFheoWVMqeUKhUNKSmQReqiQ/hCaWmU5IRwE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Z16i/S2Qkz4yTvhYA8us5tu4SZXwsqpgruaOYgod/rDDKJ9ZXAFr1ypfYB3oMNPIt lAqYwxaFzO5q4XOjbmch0pn16tSZKq5U+w1dCthMoB+ahKv8G3Y22mCWEJUae8eXg8 mT+Tqe1N98E2cfYneadeAmie3FgFiqUJlU1aLLe83UMiv0urKPYB9bpuTuucw1woal vFgLY6yPx5/NkcT2EUpAeHWO0ZR0allxEgxGmPH3MlQFch+PoI1NNbT4AVuRdq9KIC d6AqZbtOb1OZJhHLZwgyyxIxdY64NFKi8v+4QE6Xzya2OjToxqpuH9rpcjeqN49FEm KUI4D4fam6g9A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/4] soundwire: qcom: disable runtime PM on controller unbind Reply-To: sashiko-reviews@lists.linux.dev To: "Ajay Kumar Nandam" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261203-ak-gt-soundwire-qcom-mmrole-rework-v1-2-046ce68c8b0e@oss.qualcomm.com> References: <20261203-ak-gt-soundwire-qcom-mmrole-rework-v1-0-046ce68c8b0e@oss.qualcomm.com> <20261203-ak-gt-soundwire-qcom-mmrole-rework-v1-2-046ce68c8b0e@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 08:08:17 +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 5 potential issues to consider: - [High] soundwire: qcom: unclocked peer MMIO writes in qcom_swrm_remove() - [Medium] soundwire: qcom: hclk disable check in qcom_swrm_remove() desyncs on dead clk - [Medium] soundwire: qcom: hclk refcount mismatch in qcom_swrm_remove() on ADSP restart - [Medium] soundwire: qcom: pm_runtime_disable() before teardown allows unclocked MMIO - [Low] soundwire: qcom: missing Fixes trailer for commit 74e79da9fd46 -- commit b31693c684ab42b0a6bf2fee75c49470bacdd1ea Author: Ajay Kumar Nandam > soundwire: qcom: disable runtime PM on controller unbind > > qcom_swrm_remove() does not balance the pm_runtime_enable() done in > probe() for the default and primary roles. It also disables the > interface clock even when runtime suspend already disabled it. > > During an ADSP restart, the controller can be removed while runtime > suspended. This can leave runtime PM enabled for the old controller > instance, or disable the interface clock twice. > > The dependent remove path already handles both cases. Do the same > for the default and primary paths by disabling runtime PM before > tearing down the bus, and only releasing the clock when it is still > active. > > Co-developed-by: Ravi Hothi > Signed-off-by: Ravi Hothi > Signed-off-by: Ajay Kumar Nandam [Severity: Low] This fixes missing runtime PM teardown and an unbalanced clk_disable_unprepare() in qcom_swrm_remove(). Should this include: Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support") > diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c > index bd44d89132675..d23d6ec56fed9 100644 > --- a/drivers/soundwire/qcom.c > +++ b/drivers/soundwire/qcom.c > @@ -2051,6 +2051,10 @@ static void qcom_swrm_remove(struct platform_devic= e *pdev) > return; > } > =20 > + /* Balance probe()'s pm_runtime_enable() before tearing the bus down. */ > + pm_runtime_disable(&pdev->dev); > + pm_runtime_dont_use_autosuspend(&pdev->dev); > + > /* delete bus before dropping peer_ctrl; in-flight ops deref it */ > sdw_bus_master_delete(&ctrl->bus); [Severity: Medium] Can disabling runtime PM before sdw_bus_master_delete() and ASoC DAI teardown allow unclocked MMIO accesses from swrm_reg_show() or qcom_swrm_startup()? If &pdev->dev enters qcom_swrm_remove() runtime-suspended with ctrl->hclk gated off (for example when autosuspend_delay_ms is 0 so __device_release_driver()'s pm_runtime_put_sync() suspends synchronously), pm_runtime_disable() makes subsequent pm_runtime_get_sync(ctrl->dev) calls return -EACCES without enabling ctrl->hclk. CPU0 CPU1 qcom_swrm_remove() pm_runtime_disable(&pdev->dev) qcom_swrm_startup() pm_runtime_get_sync() -> -EACCES /* ignores -EACCES, returns 0 */ qcom_swrm_shutdown() swrm_wait_for_wr_fifo_done() ctrl->reg_read() <-- unclocked MMIO sdw_bus_master_delete() ... devres_release_all() Both swrm_reg_show() and qcom_swrm_startup() treat -EACCES from pm_runtime_get_sync() as success, so a concurrent debugfs read before sdw_bus_debugfs_exit() or a DAI callback before the devm ASoC component is unregistered can issue unclocked MMIO accesses and cause an SError or bus hang. > @@ -2073,7 +2077,9 @@ static void qcom_swrm_remove(struct platform_device= *pdev) > ctrl->peer_ctrl =3D NULL; > } [Severity: High] Can the primary remove path still issue unclocked MMIO writes to the dependent peer when the interface clock provider is gone? Just above these lines, qcom_swrm_remove() resumes the dependent peer and writes its registers whenever pm_runtime_resume_and_get() succeeds: drivers/soundwire/qcom.c:qcom_swrm_remove() { ... ret =3D pm_runtime_resume_and_get(peer->dev); if (ret < 0) { dev_err(&pdev->dev, "peer resume failed on remove: %d\n", ret); } else { peer->reg_write(peer, peer->reg_layout[SWRM_REG_INTERRUPT_CPU_EN], 0); /* disable peer SWRM; releases shared SWR_CLK */ peer->reg_write(peer, SWRM_COMP_CFG_ADDR, 0); pm_runtime_put(peer->dev); } ... } After commit "soundwire: qcom: don't touch registers when the iface clock is not live", swrm_runtime_resume() returns 0 without calling clk_prepare_enable(peer->hclk) when swrm_iface_clk_live(peer) is false. During an ADSP restart, pm_runtime_resume_and_get(peer->dev) then returns 0 while peer->hclk is dead and gated, so qcom_swrm_remove() writes to unclocked peer MMIO registers and risks an SError or bus hang. Checking swrm_iface_clk_live(peer) before the peer->reg_write() calls would avoid this. > =20 > - clk_disable_unprepare(ctrl->hclk); > + /* Skip if runtime suspend already dropped the clock. */ > + if (!pm_runtime_status_suspended(&pdev->dev)) > + clk_disable_unprepare(ctrl->hclk); > } [Severity: Medium] Does checking pm_runtime_status_suspended(&pdev->dev) still match whether ctrl->hclk is prepared and enabled after commit "soundwire: qcom: don't touch registers when the iface clock is not live"? When swrm_iface_clk_live(ctrl) is false, both swrm_runtime_resume() and swrm_runtime_suspend() return 0 without calling clk_prepare_enable() or clk_disable_unprepare(), so the runtime PM core still transitions runtime_status between RPM_SUSPENDED and RPM_ACTIVE while ctrl->hclk is left unchanged. That can either leak the ctrl->hclk prepare/enable count (if runtime suspend returns 0 on a dead clock before remove) or disable ctrl->hclk when the parent provider is already gone. Tracking whether ctrl->hclk is enabled in driver state would avoid relying on runtime PM status here. [Severity: Medium] Can this still call clk_disable_unprepare(ctrl->hclk) twice during an ADSP restart on a runtime-suspended default or primary controller? Before calling device_remove() -> qcom_swrm_remove(), __device_release_driver() calls pm_runtime_get_sync(dev) followed by pm_runtime_put_sync(dev). If the controller was already RPM_SUSPENDED (ctrl->hclk count 0) and the clock parent disappeared, pm_runtime_get_sync() invokes swrm_runtime_resume(), which returns 0 without enabling ctrl->hclk and transitions runtime_status to RPM_ACTIVE. Because default and primary roles enable a 3000 ms autosuspend delay in qcom_swrm_probe(), pm_runtime_put_sync() only arms the autosuspend timer and leaves runtime_status at RPM_ACTIVE, so qcom_swrm_remove() calls clk_disable_unprepare(ctrl->hclk) a second time and triggers clk_core_disable()/clk_core_unprepare() warnings. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-ak-gt-soun= dwire-qcom-mmrole-rework-v1-0-046ce68c8b0e@oss.qualcomm.com?part=3D2