Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6102970ybi; Wed, 31 Jul 2019 08:23:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsu1LNpdn7S4ZFG5LXIyLkmsKrC36OPtEu73n+Q5hM/HV+W8xdPqR8vpxyrcDBVCQllf3c X-Received: by 2002:a63:4823:: with SMTP id v35mr87065805pga.138.1564586603333; Wed, 31 Jul 2019 08:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564586603; cv=none; d=google.com; s=arc-20160816; b=n1EdW69qi0A2bbI2lf1jdgE07HXoNfLS6bix/sJL67osBd1mONP1/2ptr2c9Btka6o XDgt0m5C7n9bYlzE7STROczKsyuRKwHhdl1HNpQ4t/u6CGrWSJuaq+QNBZ6RfgS19L5G luvkYQ9985xpQCQCqZAgWl5WsqR2Q1dQI0s3zb9ZSYj8gbX16iM9gDr3jQRPKitD+6Fa RB+2Ii7gi8ikxWr0jgv5F2am8dri5beMAWaOqaCpjXy9vd57cEjppbOCUMHZtI+7ty9M U9ZEYuIWFeLBNSA95YMSisGfm/DRgKnNUR0hD7I5r4thedr/WzisksSIQEk9TQ/9WG0D VJmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=MDnPbJodK/a6eTFi3yfzZVR2rm3ZSgLhYLWa+WneOcQ=; b=FScgm+v+mGJfF8yAhI11pRNdqO47hSjXuDMrmpD2lOffpUc+2jem5iRzLTK8pL9d6M wa9zBPgY6guPL6m3BuO7m+HA13AZpgp5dNOjuANjS3LDNrFwUZ4yhbU3h8EArTIiol5B 0L3B1cISQa3VoUFPA6RhsDyryB6Qgo0ehaLWR+1Yy0AvowTMtaEeCayBwP4HuNLvQYcB X1B4/NsCKdQJ+CHDHwI6DPKcKalcNFHQmY9PlTKmQJfs5IwfJJnO95pXhrAwwqrkj86b xnUiNQwVV/ln9XxP3dz3F13aqabUb8grrnloJpQbNU2KHV6g9vx3XX6OhDs9UDnPC75R 3aPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LObSE0fF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si28257348plv.26.2019.07.31.08.23.07; Wed, 31 Jul 2019 08:23:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LObSE0fF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729310AbfGaOa7 (ORCPT + 99 others); Wed, 31 Jul 2019 10:30:59 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39735 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbfGaOa6 (ORCPT ); Wed, 31 Jul 2019 10:30:58 -0400 Received: by mail-wm1-f66.google.com with SMTP id u25so49693463wmc.4 for ; Wed, 31 Jul 2019 07:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MDnPbJodK/a6eTFi3yfzZVR2rm3ZSgLhYLWa+WneOcQ=; b=LObSE0fFJUw55SB99a92enfrZZUq30eu9bG2F/nsfWNxuzV9x2HmIAvxj0KJ9w0KTU qrIclXt78r1QBfee5k0HYdjVZ0gbj9fNSGTnKWLZ6ndr3dOMOX7Y3VDxa3DQq8RHuZm5 /48OTXttWhRqrIZkeXdW6N77lLaaOtC6y8buit2VDJx/IGQ2OpeOYR2S+G8mfirEjQ7g NG0SSL/kykYLqhLsE7AUDUa3AqwG9sCxx+/LNHCTnGNh63e8AYQFw+tzeNt3Qzt+XsbL JU1G4bO3AWErvXFZ4ADhul3FeEJLOAWayBNWrKY7rYuU1Uxboou2Yj/gCmQ/Ty+MX81g igkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MDnPbJodK/a6eTFi3yfzZVR2rm3ZSgLhYLWa+WneOcQ=; b=YHBLRjZ1h6uFSyAbiQipRFQ6IIKoq5Ay1ayNbKaSiZa//FV5fo8HhCw90yr7yXWugf KGD8oDdW3tcjCXr/NlJ3ZdRerHDlVn0i91AeDvSoRuC9RDpbnhtxjdT+9QtcrQx30+P0 K9Uayi1S7lPkQGjy7aZsOwbjqPo9lk7wPcIYBl8fhNWsWhEEKrdT2ImWFMU+w4X4JX07 ILGFsnK+lw8AA0AdC9KCyqjH775aYKnrjBOnqSixraMZ0NN/pDOw3I4/xLW4GOx6OnPm Rsk+oaULQ/oAYk4a24PwrlH2VAzQYBn1/tSN3eckEq7deOuqcwmku6hQmrEB6TZruIgK qf1g== X-Gm-Message-State: APjAAAU8uISFZtyXg+y6WnzMg+LRn7RKxIOtvVqgrwS5Aqu5CnVmd4Ql VeC3F59RWucu0/MttBZ7yLzEtQ== X-Received: by 2002:a1c:e90d:: with SMTP id q13mr110692820wmc.89.1564583455255; Wed, 31 Jul 2019 07:30:55 -0700 (PDT) Received: from [192.168.1.6] (19.red-176-86-136.dynamicip.rima-tde.net. [176.86.136.19]) by smtp.gmail.com with ESMTPSA id z6sm61429920wrw.2.2019.07.31.07.30.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 07:30:54 -0700 (PDT) Subject: Re: [PATCH v3 08/14] clk: qcom: hfpll: CLK_IGNORE_UNUSED To: Bjorn Andersson Cc: sboyd@kernel.org, david.brown@linaro.org, jassisinghbrar@gmail.com, mark.rutland@arm.com, mturquette@baylibre.com, robh+dt@kernel.org, will.deacon@arm.com, arnd@arndb.de, horms+renesas@verge.net.au, heiko@sntech.de, sibis@codeaurora.org, enric.balletbo@collabora.com, jagan@amarulasolutions.com, olof@lixom.net, vkoul@kernel.org, niklas.cassel@linaro.org, georgi.djakov@linaro.org, amit.kucheria@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org, khasim.mohammed@linaro.org References: <20190625164733.11091-1-jorge.ramirez-ortiz@linaro.org> <20190625164733.11091-9-jorge.ramirez-ortiz@linaro.org> <20190711151631.GI7234@tuxbook-pro> From: Jorge Ramirez Message-ID: Date: Wed, 31 Jul 2019 16:30:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190711151631.GI7234@tuxbook-pro> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/11/19 17:16, Bjorn Andersson wrote: > On Tue 25 Jun 09:47 PDT 2019, Jorge Ramirez-Ortiz wrote: > >> When COMMON_CLK_DISABLED_UNUSED is set, in an effort to save power and >> to keep the software model of the clock in line with reality, the >> framework transverses the clock tree and disables those clocks that >> were enabled by the firmware but have not been enabled by any device >> driver. >> >> If CPUFREQ is enabled, early during the system boot, it might attempt >> to change the CPU frequency ("set_rate"). If the HFPLL is selected as >> a provider, it will then change the rate for this clock. >> >> As boot continues, clk_disable_unused_subtree will run. Since it wont >> find a valid counter (enable_count) for a clock that is actually >> enabled it will attempt to disable it which will cause the CPU to >> stop. > > But if CPUfreq has acquired the CPU clock and the hfpll is the currently > selected input, why does the clock framework not know about this clock > being used? right, see the comment right below - maybe I should have been more explicit at the time. sorry about it. > >> Notice that in this driver, calls to check whether the clock is >> enabled are routed via the is_enabled callback which queries the >> hardware. calls to check whether the clock is enabled dont use the usage counter but a hardware read. IIRC the clock framework will check some counter to know if the clock is being used. >> >> The following commit, rather than marking the clock critical and >> forcing the clock to be always enabled, addresses the above scenario >> making sure the clock is not disabled but it continues to rely on the >> firmware to enable the clock. >> >> Co-developed-by: Niklas Cassel >> Signed-off-by: Niklas Cassel >> Signed-off-by: Jorge Ramirez-Ortiz > > > I can see that we have a real issue in the case where CPUfreq is not > enabled and hence there are no clients, according to Linux. And that I > don't know another way to guard against. the issue is there when CPUfreq is enabled that is for sure (if we just remove this commit the system will not boot due to the situation I tried to describe above). > > Reviewed-by: Bjorn Andersson > > Regards, > Bjorn > >> --- >> drivers/clk/qcom/hfpll.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/drivers/clk/qcom/hfpll.c b/drivers/clk/qcom/hfpll.c >> index 0ffed0d41c50..d5fd27938e7b 100644 >> --- a/drivers/clk/qcom/hfpll.c >> +++ b/drivers/clk/qcom/hfpll.c >> @@ -58,6 +58,13 @@ static int qcom_hfpll_probe(struct platform_device *pdev) >> .parent_names = (const char *[]){ "xo" }, >> .num_parents = 1, >> .ops = &clk_ops_hfpll, >> + /* >> + * rather than marking the clock critical and forcing the clock >> + * to be always enabled, we make sure that the clock is not >> + * disabled: the firmware remains responsible of enabling this >> + * clock (for more info check the commit log) >> + */ >> + .flags = CLK_IGNORE_UNUSED, >> }; >> >> h = devm_kzalloc(dev, sizeof(*h), GFP_KERNEL); >> -- >> 2.21.0 >> >