From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BA0625334D; Tue, 29 Apr 2025 17:22:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745947362; cv=none; b=httyeEou6+qfCLJuqyGZBrfyRvpzXQwivvO9iSrJP9sFE273GOMRKiVGEsPrMUSvDZJoVYiVgwST918Q9UK2VsWeNyY61iE/7FBi0+ZQxBGexsU8AuyMLuJQlLPBFsDwa+PjcoCSJTRPQCMIx6X23Mv4xreB+75Qoa3FCgmjs7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745947362; c=relaxed/simple; bh=rhtDVjf/gPV3hbmnCgmGb9GPmFUXomOxscaoWnsOdcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nr+66Npfeqi6S5dn9ZuUViP4ufOC/JOUOyqiZmuLILSLvUILR0N4bm7lt1L10rzG/u0KX0bGAegmi68UQfjg9HX0KWefQ9Q6DDGuJ3FN2Oi2nf1fdXoMHEZ3vSBpjloM7zBBFhYpFxl9dZi8WXcR0tN2aeNd7YyEzdLD+s+ZsoM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lYZJgIpf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lYZJgIpf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12187C4CEE3; Tue, 29 Apr 2025 17:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745947362; bh=rhtDVjf/gPV3hbmnCgmGb9GPmFUXomOxscaoWnsOdcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lYZJgIpfkCWkblWDB9ktmmvJOHzZh9JHmvVw6Z8c+DEdZujYZy3ig1fourDL9u7p2 2cE1Yie/gES8gxig2iPCLFBUsvfF9I5VxGYIz4BzJgVoOMFZvTZn1wQNED5poWCgej 1XaPNi0OxyXw7K6FUe6EM4eXI9rTuqjOzuyWbJ94= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sebastian Reichel , Cristian Ciocaltea , Heiko Stuebner , Stephen Boyd , Sasha Levin Subject: [PATCH 5.10 255/286] clk: check for disabled clock-provider in of_clk_get_hw_from_clkspec() Date: Tue, 29 Apr 2025 18:42:39 +0200 Message-ID: <20250429161118.408854000@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161107.848008295@linuxfoundation.org> References: <20250429161107.848008295@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heiko Stuebner [ Upstream commit b20150d499b3ee5c2d632fbc5ac94f98dd33accf ] of_clk_get_hw_from_clkspec() checks all available clock-providers by comparing their of nodes to the one from the clkspec. If no matching clock provider is found, the function returns -EPROBE_DEFER to cause a re-check at a later date. If a matching clock provider is found, an authoritative answer can be retrieved from it whether the clock exists or not. This does not take into account that the clock-provider may never appear, because it's node is disabled. This can happen when a clock is optional, provided by a separate block which never gets enabled. One example of this happening is the rk3588's VOP, which has optional additional display clocks coming from PLLs inside the hdmiphy blocks. These can be used for better rates, but the system will also work without them. The problem around that is described in the followups to[1]. As we already know the of node of the presumed clock provider, add a check via of_device_is_available() whether this is a "valid" device node. This prevents eternal defer loops. Link: https://lore.kernel.org/dri-devel/20250215-vop2-hdmi1-disp-modes-v1-3-81962a7151d6@collabora.com/ [1] Reviewed-by: Sebastian Reichel Tested-by: Cristian Ciocaltea Signed-off-by: Heiko Stuebner Link: https://lore.kernel.org/r/20250222223733.2990179-1-heiko@sntech.de [sboyd@kernel.org: Reword commit text a bit] Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/clk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 7dc3b0cca252a..950dfa059a209 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4858,6 +4858,10 @@ of_clk_get_hw_from_clkspec(struct of_phandle_args *clkspec) if (!clkspec) return ERR_PTR(-EINVAL); + /* Check if node in clkspec is in disabled/fail state */ + if (!of_device_is_available(clkspec->np)) + return ERR_PTR(-ENOENT); + mutex_lock(&of_clk_mutex); list_for_each_entry(provider, &of_clk_providers, link) { if (provider->node == clkspec->np) { -- 2.39.5