From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DBDA606A31A for ; Mon, 23 Nov 2026 15:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=KIbLFAow; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=tyx9iVUr DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=QhwkeRsKW2eU1yR2DBn8OENZbsAgbpApGZdt64vMdFc=; b=KIbLFAowvXn43RouDRvsdkkMvQ GoYixSGg7+ISy1MzXJPX35QXt3tmIhSSO15OCRxkC8fuJELVPdNtUraePaSxihKxgp6kTz4eKtodg pX38XxsYjaEifPT2GneD4a7VNYeey9pkQv/xuHDDzueCFBrsn8VaEC2WM2VAl7XWm0Mw04RYQHgAx gpnnscnpGEgMNQJrk/1jy1s7kLO3BicfZjaEEnPq1Dut6x0nKEuXWS66TzE0ymySxM619GVXhk7cL 4dMxair4HINDyGOBnHvYPfDS7UQjhYhCI7gifZZ7+gImAXEDub9E27Wj8OVhAXU6+xz95UK/5M9NC ZDIthHew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xVVdV-00000003tlu-2Tkj; Mon, 23 Nov 2026 15:07:17 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xVVdS-00000003tl2-3Ost for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2026 15:07:16 +0000 Received: from killaraus.ideasonboard.com (2001-14ba-7086-3000--a06.rev.dnainternet.fi [IPv6:2001:14ba:7086:3000::a06]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E20A0177; Mon, 23 Nov 2026 16:04:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1795446280; bh=hWpll5jCWlb3p4P0FO1e+zezhAH+oosPgqeDUB2EaBU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tyx9iVUrmGY4LpCqE/MfiTNAFkDFvyz0SFmzDek+lY5RRd76Px++aSNSpfPLdXWKZ TVcpqSiPaYUFQumgA4os9b+Hwh6xeZtVU0fEHDhmkvEN/vhwnbaJ89aOm/40l2m528 anHmd+DXrdgZC2kgRDJEfzq4FcSmfRw4NtfIiK4Q= Date: Mon, 23 Nov 2026 17:07:10 +0200 From: Laurent Pinchart To: Geert Uytterhoeven Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stephen Boyd , Brian Masney , Jerome Brunet , Ulf Hansson , Philipp Zabel , "Rafael J . Wysocki" , Marek Vasut , Bartosz Golaszewski , Konrad Dybcio , Kevin Hilman , Vinod Koul , Wolfram Sang , Kuninori Morimoto , Paul Elder , =?utf-8?Q?Cl=C3=A9ment?= Le Goffic , Sudeep Holla , Cristian Marussi , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH v5 05/15] clk: renesas: r8a78000: Add SCMI remapping support Message-ID: <20261123150710.GL3010398@killaraus.ideasonboard.com> References: <20261123113619.GG3010398@killaraus.ideasonboard.com> <23ab561a-c5c5-41ff-a0f4-87a3f5ca2e49@app.fastmail.com> <20261123125410.GK3010398@killaraus.ideasonboard.com> <066fcf7c-e1f6-4186-9874-622dbce18f92@app.fastmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <066fcf7c-e1f6-4186-9874-622dbce18f92@app.fastmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261123_070714_995566_4BE28AF2 X-CRM114-Status: GOOD ( 27.33 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Mon, Nov 23, 2026 at 02:02:35PM +0100, Geert Uytterhoeven wrote: > On Mon, Nov 23, 2026, at 13:54, Laurent Pinchart wrote: > > On Mon, Nov 23, 2026 at 01:34:06PM +0100, Geert Uytterhoeven wrote: > >> On Mon, Nov 23, 2026, at 12:36, Laurent Pinchart wrote: > >> > On Wed, Nov 18, 2026 at 08:44:53PM +0100, Geert Uytterhoeven wrote: > >> >> Extend the Clock Pulse Generator driver for R-Car X5H with SCMI support, > >> >> to remap DT clock IDs to abstractions (clocks) offered by the SCMI > >> >> firmware when running on a system with SCMI, and SCMI support is > >> >> enabled. Take into account some peculiarities of the current SCMI > >> >> firmware implementations, and fall-back to fixed-rate clocks as > >> >> replacements for SCMI clocks that are not available. > >> >> Support for bus clocks used by serial, I2C, and SPI devices is included. > >> >> > >> >> This lets us avoid putting SCMI IDs in DT, and allows us to use the same > >> >> hardware description in SoC DTS for systems with and without SCMI > >> >> firmware. > >> >> > >> >> For now, it is assumed SCMI clock IDs are stable, and match SCP FW > >> >> SDKv4.31.0 and later. > >> >> > >> >> Suggested-by: Marek Vasut > >> >> Signed-off-by: Geert Uytterhoeven > >> >> Tested-by: Wolfram Sang > >> > >> >> --- a/drivers/clk/renesas/r8a78000-cpg.c > >> >> +++ b/drivers/clk/renesas/r8a78000-cpg.c > >> > >> >> @@ -140,7 +182,35 @@ static struct clk_hw **get_hws(struct r8a78000_cpg_priv *priv) > >> >> > >> >> for (unsigned int i = 0; i < map->size; i++) { > >> >> fw_id = map->entries[i].fw_id; > >> >> - hws[i] = fixed_hws[fw_id]; > >> >> + if (fw_id >= FIXED_CLK_OFFSET) { > >> >> + hws[i] = fixed_hws[fw_id - FIXED_CLK_OFFSET]; > >> >> + continue; > >> >> + } > >> >> + > >> >> + scmi_spec.np = scmi_clk_np; > >> >> + scmi_spec.args_count = 1; > >> >> + scmi_spec.args[0] = fw_id; > >> >> + > >> >> + clk = of_clk_get_from_provider(&scmi_spec); > >> >> + if (IS_ERR(clk)) > >> >> + return dev_err_cast_probe(dev, clk, > >> >> + "Failed to get SCMI clock %u\n", fw_id); > >> >> + > >> >> + hw = __clk_get_hw(clk); > >> >> + clk_put(clk); > >> > > >> > Doesn't that leave the hw pointer possibly dangling, shouldn't you keep > >> > the reference to the clock ? > >> > >> Only struct clk is reference-counted; struct clk_hw is not, and exists as > >> long as the clock provider hasn't unregistered it. > > > > That's what I meant, what prevents clk_hw from being destroyed while you > > still hold a pointer ? > > If the SCMI clock provider goes away, we're indeed dead... > > Note that __clk_get_hw() + clk_put() is a common pattern to avoid > leaking the struct clk reference, and fixes were CCed to stable. It's only leaked if you don't store it and release it at remove time. I suppose that, in this case, we can rely on the SCMI clocks never going away. Hopefully. > "git grep -A1 __clk_get_hw | grep clk_put" -- Regards, Laurent Pinchart