From patchwork Wed Mar 26 18:26:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 14030474 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.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 ED63A253B75; Wed, 26 Mar 2025 18:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743013595; cv=none; b=fB565ImgovAhjF8+NLB5UKzIwxk54XsOVwi6XVpI4u/RCoZ+O47SZkHB7Y3AghC7E4fkEzAspUd/KA9MWe3qDiwXPL/AVPbkAJUwWORaHjjCjFNqo6NtkIipMMk90zDiYyKrVXpCGeMqPBRQz6Mhroc+NHjHCTkpQG31JpsncFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743013595; c=relaxed/simple; bh=El6RnnblGHxBDg+fU4YV0UFItKdKeeznwLzVSIgxWPw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qDg2oTywSoIm6E/0mj53aCK4/7M5KCvz7iKlNtwxXDkGdu57cP9UTJR9s2RvSqXVaW5BQOSHOgSA1YWpRri06hT4nVl167Ookqcz0GEefWluNoEPjq2ac5VGEruVQ9umpcIEWzVhUfVH9MB1YMwJyu6IbFH16OgyvZ38/FT2jPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ozgXb7WC; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ozgXb7WC" Received: by mail.gandi.net (Postfix) with ESMTPSA id 09A2D44442; Wed, 26 Mar 2025 18:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1743013591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TMDpRFlyrc8/aoAZfTEymjWosNwBMkC80r+GYpVAIsw=; b=ozgXb7WCfn28PDmXmcINhTrtyKUBTMLRCWwumqUkvYFMtwnxp/zsYMTI+fFCSN5BEcvgUx qskkydokGVMGWduF/5/9vYNm/UOm5wkKTvM6g4DzNACO9RBszpSHGj95Cx7j/OP5YK7W/L p7/08miVTHjxwT4BSXCZHHHLD3AL498xszr7oVUiu6xMTfwJlQfc31n7y7mu5N6g1ecbcN MD7IAWT1qSzVIgWXw5X7OEy9ZsVEXRnj6nKb8STlqxd4AWeB9tf+eAkhJvfMkXNsPDKINH xSQ103LUafozh8KzD5oHeDFLF+gwrMu9aZpRDw5Pdkv5nuVKWuetpvxA5Z5Fiw== From: Miquel Raynal Date: Wed, 26 Mar 2025 19:26:19 +0100 Subject: [PATCH RFC 04/10] clk: Avoid open coded-logic when a there is a helper available Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250326-cross-lock-dep-v1-4-3199e49e8652@bootlin.com> References: <20250326-cross-lock-dep-v1-0-3199e49e8652@bootlin.com> In-Reply-To: <20250326-cross-lock-dep-v1-0-3199e49e8652@bootlin.com> To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Danilo Krummrich , Michael Turquette , Stephen Boyd Cc: Thomas Petazzoni , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Chen-Yu Tsai , Lucas Stach , Laurent Pinchart , Marek Vasut , Ulf Hansson , Kevin Hilman , Fabio Estevam , Jacky Bai , Peng Fan , Shawn Guo , Shengjiu Wang , linux-imx@nxp.com, Ian Ray , =?utf-8?q?Herv?= =?utf-8?q?=C3=A9_Codina?= , Luca Ceresoli , Saravana Kannan , Miquel Raynal X-Mailer: b4 0.15-dev X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieeivdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofhiqhhuvghlucftrgihnhgrlhcuoehmihhquhgvlhdrrhgrhihnrghlsegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeelgfehvdduieefieeikeffgffggfdttdeugeffieetheeuleelfeehffdtffetveenucfkphepledtrdekledrudeifedruddvjeenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepihhnvghtpeeltddrkeelrdduieefrdduvdejpdhhvghloheplgduledvrdduieekrdegvddrgeeingdpmhgrihhlfhhrohhmpehmihhquhgvlhdrrhgrhihnrghlsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvkedprhgtphhtthhopehmrghrvgigseguvghngidruggvpdhrtghpthhtoheplhhinhhugidqihhmgiesnhigphdrtghomhdprhgtphhtthhopehlihhnuhigqdgtlhhksehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepihgrnhdrrhgrhiesghgvhhgvrghlthhhtggrrhgvrdgtohhmpdhrtghpthhtohepmhhtuhhrqhhuvghtthgvsegsrgihlhhisghrvgdrtghomhdpr hgtphhtthhopehssghohigusehkvghrnhgvlhdrohhrghdprhgtphhtthhopehkhhhilhhmrghnsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehthhhomhgrshdrphgvthgriiiiohhnihessghoohhtlhhinhdrtghomh X-GND-Sasl: miquel.raynal@bootlin.com The logic for checking whether a clock is already runtime resumed exists (and increasing the refcounting in this case) is already available. Reuse the helper instead of open-coding the logic here again. Signed-off-by: Miquel Raynal --- drivers/clk/clk.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 1c15d72cd3daeeb5bb4f0d94c9f387526fab75ae..a6148eae7b6615d23d6ac665e8f94e2ae69f93b6 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -338,13 +338,8 @@ static bool clk_core_is_enabled(struct clk_core *core) * taking enable spinlock, but the below check is needed if one tries * to call it from other places. */ - if (core->rpm_enabled) { - pm_runtime_get_noresume(core->dev); - if (!pm_runtime_active(core->dev)) { - ret = false; - goto done; - } - } + if (clk_pm_runtime_get_if_active(core)) + return false; /* * This could be called with the enable lock held, or from atomic @@ -359,8 +354,7 @@ static bool clk_core_is_enabled(struct clk_core *core) ret = core->ops->is_enabled(core->hw); done: - if (core->rpm_enabled) - pm_runtime_put(core->dev); + clk_pm_runtime_put(core); return ret; }