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=1796144813; b=pEpt72mFhn5399nbzQ50HO18p9bOmRWaZdLAuazLkrsI1yk/rG3/mspjp/shnQFzIdg7 QkICJTKy3BUeC7hzm1sh5OeSz2w1OhVzAGG6I0Yq3i8zExa8Nr2csJw6fq5q/PuQcyK/W hH7jLkooL1qSV46SN3HZGDbO1neiX/Uhz+YOswTDXZRpxuyDwzwBnNU1aMxfht4Zoy0LE woNW+Z7n7I6AwsloTxJgmbztyvYgmsyImBc0hT/FJphtpAIx2YB3wINVALpD+z+VjJoJ6 nxu6XkiWYLamhlzsqZrgNEIvNwPTV/wIUtaPC1zwQF7OT2fP1vWQ8OgNHS4PQhrSWYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796144813; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=FQrkLdI4U+daVIsiv8+MNT+zxXwc4JtHUiWI9FXPwKM=; b=rDxxm14LDk84H9gwwp+gehcmiPUTSEpxinN1v+KaXghsWjZcwEW0j6dxjubEGESqY+Uh +Ioc+3qGbqS3E93HOmV+X2aKJt/l8H/Em0qM73JHLgy9hspva9NvPJaPbyaBO1mYAcd0h yQe74tyLYxtZHZO92SUk+k/UNIEoBzZsKSTEMGImGt0ScWnp+sBHaLM/Gofc0xLnQaRRP mYpv1hhyWJN+AYxE9RiBejWjpLLsJWD5t7B8DkZj5T6lZeC6CtMdiYx7JoBvm3MDoG7ha X2v6fHnCrtIPMQMXL4VXA4MClGkqQMQcctpqhILRyuZu1XH2F9d56SfZDbMBb67snYQ== 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=hqNTXSh9; 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 595CD606A329 for ; Tue, 1 Dec 2026 17:06:53 +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=hqNTXSh9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63CA91F0089A; Tue, 1 Dec 2026 17:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796144812; bh=FQrkLdI4U+daVIsiv8+MNT+zxXwc4JtHUiWI9FXPwKM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=hqNTXSh9qZ7NFOCQILCLy/3eSHj1bs2t8Kb9gzL259ENH4v5FTc3xClk8xvILX5qT qrBRi1qTvJqQemxN+CiUJOmSHDPh8RaBhktndHBD60UFTabp/bT3iLFIRPJ6JO9VCx ioxHYfN3FuYEPcZ/Q3wm5sLaxUXGVNBJO0j5lPkcrJqtJOX9i4b2dEs19IHyjoay6c veKfjDdhI4j9RjoO+9wQmQJI6tqrkWdoOKRKzFy1ANj//Ao+sIuyR4Qt8kfg8IfBhQ bPn9ktA7Ox6zEoJwxi4o/2FZLbNAoTwZk+XhMQ09x1iUnrxbMSg+z/Pr2EkKO0iRVo hGslAMikHjhMQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] soundwire: qcom: Balance runtime PM and hclk in remove Reply-To: sashiko-reviews@lists.linux.dev To: "Birk Skyum" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261201-qcom-soundwire-rebind-fixes-v1-2-6c31d05f15b3@pm.me> References: <20261201-qcom-soundwire-rebind-fixes-v1-0-6c31d05f15b3@pm.me> <20261201-qcom-soundwire-rebind-fixes-v1-2-6c31d05f15b3@pm.me> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 17:06:51 +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 1 potential issue to consider: - [High] soundwire: qcom: race in qcom_swrm_remove() deleting bus before disabling PM -- commit 03b09ca4bdac9e2ec9ab217ea5ddf60211e3ae7c Author: Birk Skyum soundwire: qcom: Balance runtime PM and hclk in remove This commit disables runtime PM and autosuspend in qcom_swrm_remove() and disables ctrl->hclk only when the device is not already runtime-suspended. > diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c > index 6dde94e42e895..d3fd7ccad0dab 100644 > --- a/drivers/soundwire/qcom.c > +++ b/drivers/soundwire/qcom.c > @@ -1789,9 +1789,22 @@ static int qcom_swrm_probe(struct platform_device = *pdev) > static void qcom_swrm_remove(struct platform_device *pdev) > { > struct qcom_swrm_ctrl *ctrl =3D dev_get_drvdata(&pdev->dev); > + struct device *dev =3D &pdev->dev; > =20 > sdw_bus_master_delete(&ctrl->bus); > - clk_disable_unprepare(ctrl->hclk); > + > + /* > + * Balance pm_runtime_enable() in probe. Left enabled, the next probe > + * after an unbind (the audio DSP restarting unbinds the LPASS chain) > + * runtime-resumes the controller from sdw_bus_master_add() before its > + * bus is set up and oopses in sdw_bus_exit_clk_stop(). Runtime suspend > + * already released hclk, so release it here only if still active. > + */ > + pm_runtime_disable(dev); > + pm_runtime_dont_use_autosuspend(dev); > + if (!pm_runtime_status_suspended(dev)) > + clk_disable_unprepare(ctrl->hclk); > + pm_runtime_set_suspended(dev); > } [Severity: High] Can swrm_runtime_suspend() run concurrently with sdw_bus_master_delete() because runtime PM is disabled only after deleting the bus? If the controller is active with active children (child_count > 0) and its last_busy timestamp is older than the autosuspend delay when unbind begins, __device_release_driver() leaves dev active with usage_count =3D=3D 0. Cal= ling sdw_bus_master_delete() while runtime PM is still enabled then drops child_count to 0 and queues an async runtime suspend while the bus is being torn down: CPU0 kworker (pm_wq) qcom_swrm_remove() sdw_bus_master_delete(&ctrl->bus) ... sdw_master_device_del(&ctrl->bus) device_unregister(bus->dev) ... pm_request_idle(dev) /* frees bus->md (bus->dev) */ swrm_runtime_suspend(dev) sdw_bus_prep_clk_stop(&ctrl->bus) sdw_bus_clk_stop(&ctrl->bus) ... dev_err(bus->dev, ...) <-- use-after-free lockdep_unregister_key(&bus->msg_lock_key) swrm_runtime_suspend() accesses ctrl->bus (including msg_lock and the freed bus->dev) and re-enables ctrl->wake_irq during removal. Calling pm_runtime_disable() and pm_runtime_dont_use_autosuspend() before sdw_bus_master_delete() would prevent runtime PM callbacks from running during bus teardown. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-qcom-sound= wire-rebind-fixes-v1-0-6c31d05f15b3@pm.me?part=3D2