Received: by 10.223.176.46 with SMTP id f43csp4024758wra; Tue, 23 Jan 2018 03:04:29 -0800 (PST) X-Google-Smtp-Source: AH8x225NheLe2Rzy3n/cBz/ioloSPqgXtX7Ku5W1cSOrXdBGDJZ7GTy6Evx7bwHnGhBVp7F4Q5Co X-Received: by 2002:a17:902:48c8:: with SMTP id u8-v6mr5132239plh.272.1516705469246; Tue, 23 Jan 2018 03:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516705469; cv=none; d=google.com; s=arc-20160816; b=hdYkBbcBJjugGBtNAv91LeHp4YFPn87bpUCENKilr28JZeWsPZmzHLWjD3G1KXTACW miPwdqPyGM1gjXYmymingb8aXsJM7AB2p7oVv/01y7VpC85k5B/y7qSfSBCF70n9XP1t Gjka/LYoThVP9+YDhlyNKYnlebrH6mOPTCK8zkq8l4lNzsG1Hcbmn4ZPEBssj675uhYA KBS/kCsNlEp8XLukfurS8s8eH5zRgxp1vFsSccb4aCklUyPKe/ykoPjcQlFWiEMPInHD h27HaxT/LEvlbRCTEc7InMJqymyrE+qceym9Ek0OQy2ue0s6g8KURkTE5GtbFJHTRFfm FrTw== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=gmooEbMykO+iGFQGZd1JAmAT9hxUg73/T2s/vs+e080=; b=01Gco980jGtv8gbi+7tbfY8BpiCwvCNsGUAJOLWNXP8l4kaOFeukJofQu6tL7QcORD 4o/jA+ZSSIonyHHCq4Xduixdy+laNTKgFTYFo4IY7puyx+kCOJJQfMJZ+KSsmZy0ry7B ouaJx5Wu+S4gMoEktQRlq9zNXukrjkeoR0u0BmTbZkwGMXjCT7Hpq2//va1AdVw3wkae opj5KPUCp86eRzrUvhSyvzThJErLtjC4mqpFhGWsbTBQ33ft1dFA4F89z9slcCPv6caE ZHOQJ6aevW8Oy9roVvujS1UpAetIBVyEGkq5yZ6xHIvskgabYfmlhcPnXGO9EDugC3j6 6CeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=QfIoDd6X; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q81si1336466pfd.99.2018.01.23.03.04.14; Tue, 23 Jan 2018 03:04:29 -0800 (PST) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=QfIoDd6X; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751412AbeAWLDu (ORCPT + 99 others); Tue, 23 Jan 2018 06:03:50 -0500 Received: from mail-wr0-f180.google.com ([209.85.128.180]:33277 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbeAWLDt (ORCPT ); Tue, 23 Jan 2018 06:03:49 -0500 Received: by mail-wr0-f180.google.com with SMTP id p6so105248wrd.0 for ; Tue, 23 Jan 2018 03:03:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=gmooEbMykO+iGFQGZd1JAmAT9hxUg73/T2s/vs+e080=; b=QfIoDd6XfSa7lGwZWHfr8x/1ggTf9SZmY+Bxsv2O3wtzwbB74jmPyptfHc/JU0qDcW IOCZHYfKuFgZwGoaIY7maa8evFZmxNahIfYLFwhBfQ841vg1Vu2bzFMFFBSRnLHIcC69 j7cmVG+SSpwFvRXJq4grNPtqQwZ/fa9STyZzblUZDJK+Y19RoWLyv9dwQ9PaagRytdh2 rcNDQH3Fzlk1W7ERcjJjBylWY+if8Lcl25Nk2CrIffI2RzvYTRsAIax1v1YIzrVeukUO WfKiepXO6xpsCBJK9xxKyMtXpwIDkxPrDer+HzwAra5EgPU9KqJqkmEAhyljU2370pjC 46Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=gmooEbMykO+iGFQGZd1JAmAT9hxUg73/T2s/vs+e080=; b=LY1mo5Uj9sbtfl8KW9n7vmjn4os8a0O5CAg8v5xNx6rZWWWpCL/Xb7qXVn8J1QPdOL qVMBa/HlRidpeXMl+/FnVDY3c9cU72yB4gmtcbcwMA4FwGDu9kGS08GWFrY/C2oRrCrI dkwl07ymM95Itauao2Zw2G7lnYHbIl4vQtcdLcBIAFxGt1jfhEUsGhPv9VVS9ZfXxepz Wqk0t09nlUmJhU8BoLmkE9OCj+y0RLGRZC1WXDtv0WXhm+bo+Gq6Q55NJ01sjyXD30G0 d4AObY75WmR/tL1dhFZ55DknD4O9BXHVAhGvUHWAKb4IxfPuE+E1R4VuVHfO2EPw6G8T ZzxQ== X-Gm-Message-State: AKwxytdCQK0IutGNWFcjQb64nlnajvOWCHmjayW8rSGSMaIBtVbgj2l5 KP1O0d0+D7LvHyDaOKERtjcpDw== X-Received: by 10.223.145.9 with SMTP id j9mr1862206wrj.128.1516705427684; Tue, 23 Jan 2018 03:03:47 -0800 (PST) Received: from [10.1.2.124] ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id x135sm11377343wmf.35.2018.01.23.03.03.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 03:03:47 -0800 (PST) Message-ID: <1516705426.7870.45.camel@baylibre.com> Subject: Re: [PATCH V3 01/10] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support From: Jerome Brunet To: Dong Aisheng , linux-clk@vger.kernel.org, sboyd@codeaurora.org, mturquette@baylibre.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel , shawnguo@kernel.org, Anson.Huang@nxp.com, ping.bai@nxp.com, linux-imx@nxp.com, fabio.estevam@nxp.com Date: Tue, 23 Jan 2018 12:03:46 +0100 In-Reply-To: <1516367470-24340-2-git-send-email-aisheng.dong@nxp.com> References: <1516367470-24340-1-git-send-email-aisheng.dong@nxp.com> <1516367470-24340-2-git-send-email-aisheng.dong@nxp.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.4 (3.26.4-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-01-19 at 21:11 +0800, Dong Aisheng wrote: > diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h > index f711be6..68ccd36 100644 > --- a/include/linux/clk-provider.h > +++ b/include/linux/clk-provider.h > @@ -360,6 +360,7 @@ struct clk_div_table { > * @shift: shift to the divider bit field > * @width: width of the divider bit field > * @table: array of value/divider pairs, last entry should have div = 0 > + * @cached_val: cached div hw value used for CLK_DIVIDER_ZERO_GATE > * @lock: register lock > * > * Clock with an adjustable divider affecting its output frequency. Implements > @@ -388,6 +389,12 @@ struct clk_div_table { > * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED > * except when the value read from the register is zero, the divisor is > * 2^width of the field. > + * CLK_DIVIDER_ZERO_GATE - For dividers which are like CLK_DIVIDER_ONE_BASED Unless I missed something in your patch, this comment says that, like CLK_DIVIDER_MAX_AT_ZERO, CLK_DIVIDER_ZERO_GATE behave as a CLK_DIVIDER_ONE_BASED clock However, I don't see anything special done in _get_val() around CLK_DIVIDER_ZERO_GATE which means that calling _get_val() with div=2 would give val=1. This is more like a regular divider (when CLK_DIVIDER_ONE_BASED is not set) Also, when looking for the best divider, CCF could find that the best div is 1. On a non-CLK_DIVIDER_ONE_BASED, this would translate to value 0 and (accidentally) gate the clock . all the occurrences of CLK_DIVIDER_ZERO_GATE I have seen in patch 9 are combined with CLK_DIVIDER_ONE_BASED, which is probably why this potential issue has gone unnoticed. I think CLK_DIVIDER_ZERO_GATE should just means that value 0 gate the clock, and just that. It should not imply what the rest of values mean. In a more general way, I'd love to see a feature such as CLK_DIVIDER_ZERO_GATE added to the divider but I'm bit concerned of all the quirks we are slowly adding to the generic divider. It seems we are all trying re-use the algorithm of clk_divider_bestdiv() with different 'val-to-div' transfer function. Not too sure what the best solution could be though. > + * when the value read from the register is zero, it means the divisor > + * is gated. For this case, the cached_val will be used to store the > + * intermediate div for the normal rate operation, like set_rate/get_rate/ > + * recalc_rate. When the divider is ungated, the driver will actually > + * program the hardware to have the requested divider value. > */