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=1796389242; b=NtBQ2OG3oAanjdKKfg1SjeCEZp4hPnusxwt/9kDKeEEm14U7Sw8ibahiKnpmsMmQ4Xle A0iuGc9VVvgPjHnPj3axXsKIbONMEFPNsqOjZWRvHJs1OGFE6VH93ck0thXKMdr7wpJGU 7PpIaJcb5aDo7YKW6/aBkIntN0zNbbvdG8zWrWbFSBj6w/lUPQ+ZISyB5htdiNHb97d3e rnd0d4xiwopWbE+DxFfOPWphFpcIqm4YRsZOD25IB0uubVFqyBjYWCQFNeT8PKx9lGTVK hMly/8EuJP+joxFflPoFwo7dBtapBZUOpUAFrMjGE3WziMCuMw+pT4KFO9uCV4YJuog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389242; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=L//NMJDz75X3u4605xVKH/KtzEyj3TqeELDQM/sm6SM=; b=eUY06HaOERANyToO0XxDkE9zXw3xbBzaKZeM0giBdjAtrO3BBar/zdsFIfy7ag+5Yeor re2PVQsg1+LdxCLQt33YKANeptN/Yls5eH4MLeiqk6POG8sI6XrVNz0e/Nb/z5P5BwBdZ fFh/70QyziHpExDxHflbLgLPo791uqygoay+wU02mcCLSdOWwBnaEThwz7AM7wujRy1us bXlzbK1zfqkjOVtpHonvh0gyxBlYZttnDSe3dHJWeItgB/tO4Qy2gz3PgnOXK6VC5z2Tl tNT35oPx7Y4vwzT0SqhCudDDZZZgO7Lgob3YaIlUdSDckr6JrPoMu19njbWhcKGmHaA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dQggcy45; 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 2B668606A322; Fri, 4 Dec 2026 13:00:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dQggcy45 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D08E1F000C2; Fri, 4 Dec 2026 13:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389242; bh=L//NMJDz75X3u4605xVKH/KtzEyj3TqeELDQM/sm6SM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dQggcy458cB6xvjs+ye0w6+GkllVNLzSKwgLVs4U6PGiN1kLi0hFO2LdpWM+6SkgL uhiyDhPmmlOkWo7U9fmL9kLdmA2mknxlayeKyXDPl/VL5ktw4Dh8r0Z1ars9949Voe 7SWIiqblhDAvdmtYUUnbUtfFEs2tVrbbrB87L7nc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, yzddMr6 , Srinivas Kandagatla , Mark Brown Subject: [PATCH 6.1 0917/1059] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Date: Fri, 4 Dec 2026 19:07:28 +0900 Message-ID: <20261204100707.774206594@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: yzddMr6 commit bd6e011c8121c909daf51c78b56bb3bf7f467889 upstream. The clk ops of the q6dsp clock controller look up struct q6dsp_cc with dev_get_drvdata(), but q6dsp_clock_dev_probe() sets the driver data only after it has registered the clocks and added the OF clock provider. A consumer that gets and prepares one of the clocks in between dereferences a NULL pointer. fw_devlink does not keep consumers out of that window. The q6prm and q6afe clock controllers are described below the ADSP remoteproc node, and their devices are only created once the ADSP has booted and its GPR/APR services have come up, long after the remoteproc device has bound. fw_devlink therefore makes the remoteproc device the supplier of their consumers. A consumer such as the LPASS LPI pinctrl then just defers until of_clk_get() succeeds, and its retry from the deferred probe worker can run while the clock controller is still in its probe. That happened once on a Xiaomi Pad 8 Pro (SM8750). While the LPI pinctrl probe registered its GPIO chip, gpiolib read a GPIO direction, which runtime resumed the device and prepared its q6prm vote clocks through pm_clk. The prepare op then faulted with a NULL pointer dereference at virtual address 0x350 (trimmed): pc : clk_vote_q6dsp_block+0x24/0x58 [snd_q6dsp_common] lr : clk_core_prepare+0x7c/0x298 Call trace: clk_vote_q6dsp_block+0x24/0x58 [snd_q6dsp_common] (P) clk_core_prepare+0x7c/0x298 clk_prepare+0x28/0x44 pm_clk_resume+0x10c/0x188 pm_generic_runtime_resume+0x2c/0x44 ... __pm_runtime_resume+0x50/0x94 ... lpi_gpio_get_direction+0x4c/0x8c [pinctrl_lpass_lpi] gpiochip_add_data_with_key+0x7b0/0x10dc devm_gpiochip_add_data_with_key+0x38/0x8c lpi_pinctrl_probe+0x2b8/0x320 [pinctrl_lpass_lpi] ... deferred_probe_work_func+0x88/0xc0 0x350 is the offset of desc in struct q6dsp_cc; the driver data pointer it was loaded from was NULL. The oops left the clk prepare_lock held, which blocks every later clk_prepare(), and the system did not finish booting. On mainline the window is short, but it includes a wait for prepare_lock in clk_core_reparent_orphans(), which of_clk_add_hw_provider() calls right after listing the provider. The kernel that hit this had out-of-tree changes to drivers/clk/clk.c that do more work at that point, which makes the window wider. Both q6afe-clocks and q6prm-clocks use q6dsp_clock_dev_probe(). Set the driver data before the first clock is registered. The oops was analysed and the fix written with the help of an AI coding assistant. Fixes: 9ab71ac37240 ("ASoC: qdsp6: q6afe-clocks: move audio-clocks to common file") Cc: stable@vger.kernel.org Signed-off-by: yzddMr6 Reviewed-by: Srinivas Kandagatla Link: https://patch.msgid.link/20261115-upstream-q6dsp-clk-drvdata-v1-1-4d7dbea52e52@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c +++ b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c @@ -147,6 +147,12 @@ int q6dsp_clock_dev_probe(struct platfor cc->dev = dev; q6dsp_clks = desc->clks; + /* + * The clk ops look up cc through the driver data, so set it before + * any of the clocks can be prepared. + */ + dev_set_drvdata(dev, cc); + for (i = 0; i < desc->num_clks; i++) { unsigned int id = q6dsp_clks[i].clk_id; struct clk_init_data init = { @@ -175,12 +181,6 @@ int q6dsp_clock_dev_probe(struct platfor return ret; } - ret = devm_of_clk_add_hw_provider(dev, q6dsp_of_clk_hw_get, cc); - if (ret) - return ret; - - dev_set_drvdata(dev, cc); - - return 0; + return devm_of_clk_add_hw_provider(dev, q6dsp_of_clk_hw_get, cc); } EXPORT_SYMBOL_GPL(q6dsp_clock_dev_probe);