From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7E0EC433DB for ; Sat, 13 Mar 2021 23:10:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9791164ED6 for ; Sat, 13 Mar 2021 23:10:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232974AbhCMXKD convert rfc822-to-8bit (ORCPT ); Sat, 13 Mar 2021 18:10:03 -0500 Received: from aposti.net ([89.234.176.197]:37604 "EHLO aposti.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231329AbhCMXJs (ORCPT ); Sat, 13 Mar 2021 18:09:48 -0500 Date: Sat, 13 Mar 2021 23:09:23 +0000 From: Paul Cercueil Subject: Re: [PATCH 1/2] clk: Add clk_get_first_to_set_rate To: Stephen Boyd Cc: Michael Turquette , Russell King , Ulf Hansson , od@zcrc.me, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org Message-Id: In-Reply-To: <161567452539.1478170.2985873696192051312@swboyd.mtv.corp.google.com> References: <20210307170742.70949-1-paul@crapouillou.net> <20210307170742.70949-2-paul@crapouillou.net> <161567452539.1478170.2985873696192051312@swboyd.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Hi Stephen, Le sam. 13 mars 2021 à 14:28, Stephen Boyd a écrit : > Quoting Paul Cercueil (2021-03-07 09:07:41) >> The purpose of this function is to be used along with the notifier >> mechanism. >> >> When a parent clock can see its rate externally changed at any >> moment, >> and a driver needs a specific clock rate to function, it can >> register a >> notifier on the parent clock, and call clk_set_rate() on the base >> clock >> to adjust its frequency according to the new parent clock. > > Can the driver use the rate locking mechanism to get a certain rate > instead of registering for notifiers and trying to react to changes? You mean with clk_rate_exclusive_get()? That sounds like a good idea, but what would happen when a different driver calls the non-exclusive clk_set_rate() on this clock (or the parent), would it return -EBUSY, lock on a mutex? ... Cheers, -Paul > >> >> This works fine, until the base clock has the CLK_SET_RATE_PARENT >> flag >> set. In that case, calling clk_set_rate() on the base clock will >> call >> clk_set_rate() on the parent clock, which will trigger the notifier >> again, and we're in a loop. >> >> For that reason, we need to register the notifier on the parent >> clock of >> the first ancestor of the base clock that will effectively modify >> its >> rate when clk_set_rate() is called, which we can now obtain with >> clk_get_first_to_set_rate(). >> >> Signed-off-by: Paul Cercueil