From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Subject: Re: [PATCH] clk: clk_register: Correctly initialize enable_count To: =?UTF-8?Q?Emilio_L=c3=b3pez?= , Michael Turquette , Stephen Boyd References: <1455058120-7398-1-git-send-email-rklein@nvidia.com> <56BAA6D9.9090009@elopez.com.ar> CC: , From: Rhyland Klein Message-ID: <56BB82A8.8010701@nvidia.com> Date: Wed, 10 Feb 2016 13:34:16 -0500 MIME-Version: 1.0 In-Reply-To: <56BAA6D9.9090009@elopez.com.ar> Content-Type: text/plain; charset="windows-1252" Return-Path: rklein@nvidia.com List-ID: On 2/9/2016 9:56 PM, Emilio L=F3pez wrote: > Hi, >=20 > El 09/02/16 a las 19:48, Rhyland Klein escribi=F3: >> When clocks are registered, they could be enabled already in >> hardware. As of now, the enable count will start at 0. When this >> happens, it means a clock is enabled and the framework doesn't know >> that, so it will always report it as disabled. >=20 > Keep in mind that during the boot process, towards the end, unused > clocks get disabled, so the state remains in sync. If suddenly the > enable_count on unused clocks is not 0, this will break and unused > clocks will remain on, wasting power. Hmm, I had misread the logic in clk_disable_unused_subtree(), namely I inverted the check on enable_count when I was looking at it. It does seem like it would take care of the clocks I was referring to. >=20 > http://lxr.free-electrons.com/source/drivers/clk/clk.c#L244 >=20 > What issue were you having that prompted you to write this patch? I ran into the situation where a peripheral clock was enabled before the kernel loaded, and I was trying to disable it in the clk-tegra210 driver. Calling clk_disable() won't work, as the clock doesn't have an enable_count. I do think that the clk_disable_unused_subtree() should pick up the slack, but I was trying to disable it before the cleanup code to remove unused clocks ran. I think you are right and the clean up code should cover the situation I was looking at. Thanks. -rhyland --=20 nvpublic From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbcBJSeV (ORCPT ); Wed, 10 Feb 2016 13:34:21 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:10818 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752219AbcBJSeT convert rfc822-to-8bit (ORCPT ); Wed, 10 Feb 2016 13:34:19 -0500 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Wed, 10 Feb 2016 10:34:40 -0800 Subject: Re: [PATCH] clk: clk_register: Correctly initialize enable_count To: =?UTF-8?Q?Emilio_L=c3=b3pez?= , Michael Turquette , Stephen Boyd References: <1455058120-7398-1-git-send-email-rklein@nvidia.com> <56BAA6D9.9090009@elopez.com.ar> CC: , From: Rhyland Klein Message-ID: <56BB82A8.8010701@nvidia.com> Date: Wed, 10 Feb 2016 13:34:16 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56BAA6D9.9090009@elopez.com.ar> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/9/2016 9:56 PM, Emilio López wrote: > Hi, > > El 09/02/16 a las 19:48, Rhyland Klein escribió: >> When clocks are registered, they could be enabled already in >> hardware. As of now, the enable count will start at 0. When this >> happens, it means a clock is enabled and the framework doesn't know >> that, so it will always report it as disabled. > > Keep in mind that during the boot process, towards the end, unused > clocks get disabled, so the state remains in sync. If suddenly the > enable_count on unused clocks is not 0, this will break and unused > clocks will remain on, wasting power. Hmm, I had misread the logic in clk_disable_unused_subtree(), namely I inverted the check on enable_count when I was looking at it. It does seem like it would take care of the clocks I was referring to. > > http://lxr.free-electrons.com/source/drivers/clk/clk.c#L244 > > What issue were you having that prompted you to write this patch? I ran into the situation where a peripheral clock was enabled before the kernel loaded, and I was trying to disable it in the clk-tegra210 driver. Calling clk_disable() won't work, as the clock doesn't have an enable_count. I do think that the clk_disable_unused_subtree() should pick up the slack, but I was trying to disable it before the cleanup code to remove unused clocks ran. I think you are right and the clean up code should cover the situation I was looking at. Thanks. -rhyland -- nvpublic