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 4587019539F; Fri, 4 Apr 2025 00:04:29 +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=1743725069; cv=none; b=rXQo0oiaD4uqzyotiX06ROB5u5pNlPH2a9DGntsw6kdB6vn8yKm+sD6x3j1kgcATdU38zDR02kVEc9xwxnP9cmRPdseGcCPiCH+4mvc4fE1yFacYz0Is3EUngGLE0ki+Q/8CWpS49uL7WgriCdQEEttA433+CFeDUXNVdb+4Ilk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743725069; c=relaxed/simple; bh=NaEjO+BlkUrQoTEtbguQMK6Ma5RjBdxH0W3MopbJg+k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h/WvjUcgLCLDQw1ZX/6SgdNI1wnET5DY4qB42y8Bv4CCzDE9Lmco/jZYJmCc7mAuzmBX5lmun98p0/7YcTKNNdFhh1ln+EewN5Zt+Vx1czrQl/khBfBILgKhcjKMCIy3yC//Y1Z0+2T4ZikCDnm7NOjphbmQAZ5O1adKaLlGExs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CuapXugL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CuapXugL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23EEFC4CEE3; Fri, 4 Apr 2025 00:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743725069; bh=NaEjO+BlkUrQoTEtbguQMK6Ma5RjBdxH0W3MopbJg+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CuapXugLFIQX5xRp2jNI4agGxnk8qmQANLDsm7C5F9OP3j4cLT+MZre4rZsJ32uON pvg5tVBqUeYafytmOl2aUsuOtOnu9QkNopZzyOqKNkCwpPCUCndaqTKsmQI+etd640 v7ag7/wtLx5UlKv/f533zskT9XRDyBb45XiU2+0SNzBg1vlMmnw6fYgwuMU8T8K4NV ln2egDvbYv1588aUsEdQ5kXI4Tc+KySUn3837iroTFWHbjA7BHFcQ/6HyE0TDAfvHZ bQr710FHiljOB1pfbH4loEl4ehaPQAeiUkmmMTCrDSSjjOi967Pz7dz23T3l8r+V8Z Zf5EKtqGslpBw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Heiko Stuebner , Sebastian Reichel , Cristian Ciocaltea , Stephen Boyd , Sasha Levin , mturquette@baylibre.com, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 6.14 12/23] clk: check for disabled clock-provider in of_clk_get_hw_from_clkspec() Date: Thu, 3 Apr 2025 20:03:49 -0400 Message-Id: <20250404000402.2688049-12-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250404000402.2688049-1-sashal@kernel.org> References: <20250404000402.2688049-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.14 Content-Transfer-Encoding: 8bit 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 cf7720b9172ff..50faafbf5dda5 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -5258,6 +5258,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