| Message ID | 20261202102716.572884-4-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCQ4XFG47UFRBE7FX7MAMGQENI2S3WY@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com
[209.85.128.72])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 509523F336
for <linux-amarula@patchwork.amarulasolutions.com>;
Wed, 2 Dec 2026 11:27:32 +0100 (CET)
Received: by mail-wm1-f72.google.com with SMTP id
5b1f17b1804b1-49953abe51fsf91733275e9.1
for <linux-amarula@patchwork.amarulasolutions.com>;
Wed, 02 Dec 2026 02:27:32 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1796207252; cv=pass;
d=google.com; s=arc-20260327;
b=fR7OiSfuCr7BtNHoCYn0zzKvUKo8Vhfkl0iY/KpvR9VIdObA3/HPkuyZeiDKZ32+Bu
JYW7lEM3oKtUBQAbuMAEmlaIfEaJVFg+0LMZQSNnDIK0tGRHW+OllgS9lb4A0+TJgUIg
p5fI8pMFccrIj3Ouvf8B7QX8I/QsJj2Povtlw6tswqEQ2JY/WCD6BDhJWnTKzGG7O3kl
UR1DxuSlAqL1G02osXBkt7dJ3uAT+rD1r+ZCIbYNziiD+cjie7vqe5UNyLggqISGHqlz
vuT7ZYVfThQOyYE4pDFu7jhH1mDTFYL5g3v53J0+CMDqGKOuGPa6haj61nMBqlQtFv+F
9Tdg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20260327;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=510zLx6qn+3ZCsfd0M5UBUvCq/5Mg8Um5NK5l7BIhjM=;
fh=7ggk7O0/FEhXM96tFPz7bzZDwcMnJzlPTrnFLNu+JpE=;
b=BHzKGkFd91zwv3I4Aq1nAVDSHtfcu+L85qqtLsbZdfbZANnfXG1APp/CkY6HAUcYyS
hk1bssEIqMffIXW546JmGGbtOwsSdFQhGlDHeOIKOGkfGRFrL0QfD4QPF4MlH7zlizrX
vh/OlysvVNaCR7Fs+r5biL2JttSlGFAfw2JLmcazq8lJERYFnVJbdU2b5ic8ZOI3+iEk
dxNIqWoGNsgvbXc9eHcVHjisXGitvIvQBzcOQ9hrOtqDHVC0hysl1RZpms/uyPuCzgzX
z/kOSNhmhk8pQol489enVEbQCg6Q8srelzApsCCJXVAI+TIka4wJbxCS6iWqrLW6yp9f
gNhw==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=rsXgoZ4j;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amarulasolutions.com; s=google; t=1796207252; x=1796812052;
darn=patchwork.amarulasolutions.com;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:content-type
:x-original-authentication-results:x-original-sender:mime-version
:references:in-reply-to:message-id:date:subject:cc:to:from:from:to
:cc:subject:date:message-id:reply-to:content-type;
bh=510zLx6qn+3ZCsfd0M5UBUvCq/5Mg8Um5NK5l7BIhjM=;
b=VPtVsBJm6jw3P7TMSTKj2SjDNaCiLGnpRpF4XifpqIHSwwJfGw4ZTOHIizyzUPIoPt
4h5HNmk2M4YnUZ3Sg2hL0ijnpkEJkuA8caVzN73asepZteHNzBw3hRHUu9AKIuDF7NUM
2Shwk7FS0o8l4Nwt55Qr0Za9qHL0dCtpjpqe8=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796207252; x=1796812052;
h=list-unsubscribe:list-archive:list-help:list-post
:x-spam-checked-in-group:list-id:mailing-list:precedence
:content-type:x-original-authentication-results:x-original-sender
:mime-version:references:in-reply-to:message-id:date:subject:cc:to
:from:x-gm-gg:x-beenthere:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=510zLx6qn+3ZCsfd0M5UBUvCq/5Mg8Um5NK5l7BIhjM=;
b=jFz9WfvYArc6XHJPVINEtcqDRMEWIojaBx9z92ayxLVnQQQ3cFmtt8tUS1FXGf7JKh
d0fkGqOTPnDWnZndal5MB4HRHRD46hGHw2DKmvdUZkGlcFCdOdx5uu+T1oajtg+ntMbB
teOTfiHJ4SthJxnwLZ2qyRcEdzSRrZgGZyOx7jDReNna4bjzTF6nzapHF3eyL50ZxWYg
Q7eFAgTF0x5sfislzeGo3uXKMzpk5Zb9rt4syi0ZpFNWI+Z3ndoZ5xSHQN7AGqt7M/v0
LoxBQRJEF0sigB+Dg4acx1WCxSgb0MGZncOm7APw5Ql0I9WeefmL6GhjgyDj0ps9SLDS
/crw==
X-Forwarded-Encrypted: i=2;
AL+hErHkfcwMd1o9epmczTCtWsKkjRihUGa9bmau9KJWG7g2rqtOAzkbgnp2L7MofUPv8Ndcartm3xRE6Ajv2mY1@patchwork.amarulasolutions.com
X-Gm-Message-State: APuU4Z+6P+btHB9V0eTRu/Om2s2KLrGZqD5xZH0jKF1gz6ouKnFUWLnA
ZjiEIBNhVf0evIRS4S21vKuNtWtED6cjbXj0fOH0y8zkc0XG9WmUAYvd0ftoIUNjhGwFWw==
X-Received: by 2002:a05:600c:1389:b0:4bb:7347:d5c0 with SMTP id
5b1f17b1804b1-4bb88826937mr740902765e9.9.1796207251969;
Wed, 02 Dec 2026 02:27:31 -0800 (PST)
X-BeenThere: linux-amarula@amarulasolutions.com;
h="ATskLddqxpoTwrnqzAeqRINt0CkRewYezOqgaAGXAMctbOr98Q=="
Received: by 2002:a05:600c:4f15:b0:4a1:d7d0:baa5 with SMTP id
5b1f17b1804b1-4bb89263478ls33389185e9.1.-pod-prod-06-eu; Wed, 02 Dec 2026
02:27:30 -0800 (PST)
X-Forwarded-Encrypted: i=2;
AL+hErEeY0LlPQd9C5AQDxIp+u4CjVB7RoFz0jvDikJVDRcdtcGsSZaWX5xVIovVEFzaXKCuM92tepahww31pCV2@amarulasolutions.com
X-Received: by 2002:a05:600c:4e8e:b0:4ba:59fa:510e with SMTP id
5b1f17b1804b1-4bb8893014dmr797101005e9.23.1796207250254;
Wed, 02 Dec 2026 02:27:30 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1796207250; cv=none;
d=google.com; s=arc-20260327;
b=UhWnqeWzG0mG68BflWuksvi4SokYad2CF08INjdTzIn4mchckUqREGXFCwWw5nNw//
3Ec2xhamrmk84uo7C9vdkkSW+PawZl2O8MuVfj4elX/PWqUDHm/7IaegyeGsF6kWD9cH
rA6ouFmoVgA4FFbNaZdH25jDWTmx5qHSXN/HAV2/zWie9iuQyNvMjxSuRZZ/g5b07Q0j
aGM/4mErM9MU8LIW42FtwVTHxICRs+OPK630+yoZeLpz60WmquPA64bU1lTwQkpwiXiG
WZbWIwPrTWqpls7l71xgKomxrCtmAKObRyt7/jVxp2x+alKc0PWy24OFIhchbhe2TJDy
VOJQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20260327;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=HbL0J8hDGXnm3lfBzl2zymQ/4G/SEWpZuraMOylyyyg=;
fh=IfBQbe0LUzpwAYHcgR9tw1jriQVQUNX2xcPQT2YJ/Nc=;
b=cHSyvi0Glt+b9J0UEFg2fDrxvQ9JxF7bU1O+1Rr/YkeFtbwBeYBA3WQZLS9cuagyFD
UWxq7Ix7VROo1uTo+QazfRcjtI+wHyjxqhrsxW6UdmKanKLPpyeF14dDRp7u3MdJ1Lpd
YkmLCypNObaPcy9/GCM+emK4MUccA0EiR6p53igEUl2sXphMdq/3qHxLsdBPZ5FcaCMw
CtmUmpW92nd52c8YQI8ICZSLCChlDBVXAARrn0tMaHymDTjRjb+vTAV8h1aDuWfUcFOO
qBMJszxRVwbtl8e5CFaeWu5BFegSkJq9VU3wpTzqmri21eSfCSLBnSg3rJWZRDuJ9Tsm
mCsw==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=rsXgoZ4j;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com.
[209.85.220.41])
by mx.google.com with SMTPS id
5b1f17b1804b1-4bb8848b5d9sor61981995e9.3.2026.12.02.02.27.30
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Wed, 02 Dec 2026 02:27:30 -0800 (PST)
Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Forwarded-Encrypted: i=1;
AL+hErEiX48C8nhgtjGqraIe8t7NoQ1KFQREDmrpHFSYX9WeM7WUtMR3YsN8mNHEUXPhqrUF2Sldyapltn5AFGCQ@amarulasolutions.com
X-Gm-Gg: AZFdTZeXf8S3J6OdycyQDgTdY5RKA81mHWS3MnolTSy1zlY2GMwwoy2HxYD4mjqhI7l
pZx94GvKroydodXZNxI0HBK0H4IIqfyxjQ/LQi11zpOT/PA9TTPFypKvca+hkAvVKucSwo2RE62
lQ65PFWDJBN1YgOrQ2vXlXuDl5zrURBnyrK7WHXmVNpW3LcnrZQqvqplNsh5dls9FXN2l7kpk0T
GnV4uHNAW63e5EwMdzDyzI5vV+LttUW76gEWA8dawMuS5UHSUZ8VXP5BR/GcXuCDOvfQ30JsUUZ
dQjMoh1V9BID5+E631bDTOqnk8CmWt+uwuUgvJmsVoazPtEZheC6KE2VVFr1+jGToBE8a0G8paO
fiKr3v+0zbaQtsdpNUPl1QyqfvR1IwLtnHn4vHMs7MSBKphnDH7P6w5ak0ZzZerWUMo73FGL99c
pl03jzyjsw7sxJqePg5a6e5ubUAQ+E+75KHD7LigtVl0ly83bJcbWsMMyqV3ZJsZOm/hlgL7ooZ
mNknB2x9/I+tsP50Ga6cfFcrUQJBPimkCruZHDsv4qk/xHYXnR+cBwvbGCPqQ6J63ryGJ54tpIp
4/fm7OxQCLAuzhYKWC51BWTxUaTfQDXZkVGwL2nhvkazOWWFj0iOBSzc9CVHZVP8MEEJ19l+OLn
XLfx1dX89xYMD5+dW6ygC
X-Received: by 2002:a05:600c:a55:b0:4a1:992f:d0e7 with SMTP id
5b1f17b1804b1-4bb889234a7mr757556035e9.16.1796207249836;
Wed, 02 Dec 2026 02:27:29 -0800 (PST)
Received: from localhost.localdomain ([2001:b07:6474:ebbf:6962:3ebc:7df:e6bf])
by smtp.gmail.com with ESMTPSA id
5b1f17b1804b1-4bbbaeb1e4csm366823865e9.13.2026.12.02.02.27.27
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 02 Dec 2026 02:27:29 -0800 (PST)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: u-boot@lists.u-boot-project.org
Cc: Heiko Schocher <hs@nabladev.com>,
linux-amarula@amarulasolutions.com,
Peng Fan <peng.fan@nxp.com>,
simon.holesch@bshg.com,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Valeriy.Yatsenko@bshg.com,
Leonhard Hesse <leonhard.hesse@bshg.com>,
michael@amarulasolutions.com,
Miquel Raynal <miquel.raynal@bootlin.com>,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Lukasz Majewski <lukma@nabladev.com>,
Maksim Kiselev <bigunclemax@gmail.com>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v3 03/26] clk: clk-uclass: fix parent reference counting in
clk_set_parent()
Date: Wed, 2 Dec 2026 11:26:14 +0100
Message-ID: <20261202102716.572884-4-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20261202102716.572884-1-dario.binacchi@amarulasolutions.com>
References: <20261202102716.572884-1-dario.binacchi@amarulasolutions.com>
MIME-Version: 1.0
X-Original-Sender: dario.binacchi@amarulasolutions.com
X-Original-Authentication-Results: mx.google.com; dkim=pass
header.i=@amarulasolutions.com header.s=google header.b=rsXgoZ4j;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
Content-Type: text/plain; charset="UTF-8"
Precedence: list
Mailing-list: list linux-amarula@amarulasolutions.com;
contact linux-amarula+owners@amarulasolutions.com
List-ID: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
Support display on the BSH SMM S2/PRO boards
|
|
Commit Message
Dario Binacchi
Dec. 2, 2026, 10:26 a.m. UTC
clk_set_parent() enables the new parent only if the clock is enabled,
but on failure it disables it unconditionally, dropping a reference it
never took. On success, it never releases the reference the clock holds
on its old parent, which then keeps running forever.
Disable the new parent on failure only if it was enabled, and release
the old parent once the clock has moved away from it, as Linux does in
__clk_set_parent_after().
Fixes: ac30d90f3367 ("clk: Ensure the parent clocks are enabled while reparenting")
Fixes: b493db39ea7f ("clk: Only enable the parent clock if the clock was enabled before reparenting")
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
(no changes since v2)
Changes in v2:
- Add patch
drivers/clk/clk-uclass.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 0069ce9a8875..c503f6733907 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -631,6 +631,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate) int clk_set_parent(struct clk *clk, struct clk *parent) { const struct clk_ops *ops; + struct clk *old_parent = NULL; int ret; debug("%s(clk=%p, parent=%p)\n", __func__, clk, parent); @@ -641,6 +642,12 @@ int clk_set_parent(struct clk *clk, struct clk *parent) if (!ops->set_parent) return -ENOSYS; + if (CONFIG_IS_ENABLED(CLK_CCF)) { + old_parent = clk_get_parent(clk); + if (IS_ERR(old_parent)) + old_parent = NULL; + } + if (clk->enable_count) { ret = clk_enable(parent); if (ret && ret != -ENOSYS) { @@ -650,18 +657,18 @@ int clk_set_parent(struct clk *clk, struct clk *parent) } ret = ops->set_parent(clk, parent); + if (!ret && CONFIG_IS_ENABLED(CLK_CCF)) + ret = device_reparent(clk->dev, parent->dev); + if (ret) { - clk_disable(parent); + if (clk->enable_count) + clk_disable(parent); return ret; } - if (CONFIG_IS_ENABLED(CLK_CCF)) { - ret = device_reparent(clk->dev, parent->dev); - if (ret) { - clk_disable(parent); - return ret; - } - } + /* The clock no longer keeps its old parent running */ + if (clk->enable_count && old_parent) + clk_disable(old_parent); return 0; }