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=1796382318; b=W82K1QN80ki00chfI7LI9X93EaqkswUN7xjdUqhxZrfwW4qErcJoAMt56lDeh1AjSNwA eanv93qiI6IDPA0cLxq3WyqjB5zL1/WtGdK5gGfaPPNbGwiKbiyEvslgzP4rcLNoNxGX+ 0ILzDhHL0cZeAWM6zjOwFuql/e3+YGeFT6a/TzzyOLuypi0x9+fGZ5EejkQMVramxuJAp HPFbGtIS/7Ckwk0FXacZYvmcxKV7N5217NyapJ+JppXeWJZLcXhUMpxRKH6bgVR9VYvQp rdrdJCvWR83rfic9WuqNDUsJMytQ9DYPoDdyJvHgJUx9SzAGPuWFRPJBfH36J4dS0YQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382318; 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=ZAjSqAg65aG06T6F9NiqQwQ7+7/18td1+YLXEYXZpd0=; b=qXkuzP3kARXaYHsazTJSeTXBzfLHfeRiV9dN4zRFl+U9pSi0n5RQEWOO0YEbmSc2nZFQ 3Sfd+JOE8GoHNGQuCKtRLIGt5Kde0UkXp/5kdvbv22q6dqk8FxMI7dJx4HUBVamRVsCVh dGIvdkbJ/EsWSj+fMDc6ZJR4bnnUFLavFYqDaPoesKwbtaI0Zn+kw7NXtiA/GGRDrVZ1M UGC5TLcr7CHAjCwTARIYv0GN1wtMV+K4zhcA2h56aqtL10bH/768Huhwi5HK6Sk9hH3uv MreW4vAnaI+6nPqa6F/dHEhiaCyNVH6yVZkOi+d30HNdA/d9Gg+Y3Yc/xudR7PAsRmQ== 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=Zbv35IWt; 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 45CA0606A332; Fri, 4 Dec 2026 11:05:18 +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=Zbv35IWt Received: by smtp.kernel.org (Postfix) with ESMTPSA id B25C71F00933; Fri, 4 Dec 2026 11:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382318; bh=ZAjSqAg65aG06T6F9NiqQwQ7+7/18td1+YLXEYXZpd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Zbv35IWtL/NaRIXeidUtI24DWghUn0EdAbDR2qXk6ttbGvmnTyt8TFslhdPMIjrFR uGh8JWz1tEId9KJ8DnaiOIWQJ9EZqZQJy1FBImnHNcmdcfMR/TUJhJXCbgWusneL+q wjKuETtDuQnSGV6+fjyyeAyQHwFMPwNX4sSJ+FH4= 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.18 400/703] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Date: Fri, 4 Dec 2026 19:04:59 +0900 Message-ID: <20261204100638.466719808@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -146,6 +146,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 = { @@ -174,12 +180,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);