Received: by 10.223.176.46 with SMTP id f43csp889609wra; Fri, 26 Jan 2018 08:27:58 -0800 (PST) X-Google-Smtp-Source: AH8x226gkLXxBRU2NuKoNYnk12ta98exbZD2TydWTKz7MdqhpEOLwL+fiSPtufgB0m7mukYQR/NM X-Received: by 10.101.102.73 with SMTP id z9mr15745844pgv.448.1516984078358; Fri, 26 Jan 2018 08:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516984078; cv=none; d=google.com; s=arc-20160816; b=OtMy8ZkeFKVkRBh85wJpvx8kvv2wQJ1UgGrt7+KETHe48/0a4Hei1xuYQLcR/UiRan iCcUFr/6mHvhKuJJoQowuUuyeT3WIkZlMECsGQCIAYCp2x9+WWmg7ULvrztsihUANLmd h7HM4kw15blxC6RG2gwA5vigVzwAAnL7rz3BEbWBj/Cxc4FnGDHW/2UjqVj+zR5hjm2c hAoYYbo9JQYk+B3JwhZSLNauOHjYT9xE0YXQXQzpZbY/HUYBM/W/ZgVEjDdci8Ciq2Nz vfqOHK1AGuaVXjXnk5/lU0V+Z2ahKLcqXxR4ER5S7DLciCRdwffoejU8a25/YUwcvj5Z 7FDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=L5t43lJIuqiImdPhKwvyN+gWKpjiqlYGEWT/g9ipAsk=; b=x3F6PAoOukRWFVcpXKFLtYMh1QAX7oFc5KemPW5NCrtJS1vmeBp/I5zwN9wreDyG+B rH4tErLQvItvLw6xXViDJs2ShootzgYb78QrecaWX6UcbrCzIZrKjXqm4MXHL9gSBYOR znrEE169IpXcu9GXLGBjeX7j09KXA6Bi2OqNuAt4JYVVRzk2pXWWL2HA0J6TLbiiX2qx ScAPAi5EJ9JE6Gz8brW2ccPvN0rWDr6ZU/vAu4Dm0+VYcLSh8C1Zu1D5d7c0izcWDqkT 2215uKMFHQgwYR9c5So+ODIFdQ6L++NxCjye3lZQWio20WEJIhyx1QCNzRtf3hsRPj+t EIzA== ARC-Authentication-Results: i=1; mx.google.com; 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 q81si6619226pfd.99.2018.01.26.08.27.43; Fri, 26 Jan 2018 08:27:58 -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; 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 S1753866AbeAZQ1B (ORCPT + 99 others); Fri, 26 Jan 2018 11:27:01 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:34458 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753020AbeAZQ0w (ORCPT ); Fri, 26 Jan 2018 11:26:52 -0500 X-Originating-IP: 158.255.198.50 Received: from w540 (host-50-static-198-255-158.hosts-appwifi.wifix.org [158.255.198.50]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 6F8E51720AF; Fri, 26 Jan 2018 17:26:21 +0100 (CET) Date: Fri, 26 Jan 2018 17:24:54 +0100 From: jacopo mondi To: Geert Uytterhoeven Cc: Jacopo Mondi , Magnus Damm , Kuninori Morimoto , Laurent Pinchart , Yoshinori Sato , Rich Felker , Linux-sh list , Linux-Renesas , Linux Media Mailing List , Linux Kernel Mailing List , linux-clk Subject: Re: [PATCH] sh: clk: Relax clk rate match test Message-ID: <20180126162454.GA11798@w540> References: <1516879493-24637-1-git-send-email-jacopo+renesas@jmondi.org> <20180125141407.GH17416@w540> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, On Thu, Jan 25, 2018 at 03:39:32PM +0100, Geert Uytterhoeven wrote: > Hi Jacopo, [snip] > >> > --- > >> > drivers/sh/clk/core.c | 9 ++++++--- > >> > 1 file changed, 6 insertions(+), 3 deletions(-) > >> > > >> > diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c > >> > index 92863e3..d2cb94c 100644 > >> > --- a/drivers/sh/clk/core.c > >> > +++ b/drivers/sh/clk/core.c > >> > @@ -198,9 +198,12 @@ int clk_rate_table_find(struct clk *clk, > >> > { > >> > struct cpufreq_frequency_table *pos; > >> > > >> > - cpufreq_for_each_valid_entry(pos, freq_table) > >> > - if (pos->frequency == rate) > >> > - return pos - freq_table; > >> > + cpufreq_for_each_valid_entry(pos, freq_table) { > >> > + if (pos->frequency > rate) > >> > + continue; > >> > >> This assumes all frequency tables are sorted. > >> > >> Shouldn't you pick the closest frequency? > >> > >> However, that's what clk_rate_table_round() does, which is called from > >> sh_clk_div_round_rate(), and thus already used as .round_rate: > >> > >> static struct sh_clk_ops sh_clk_div_enable_clk_ops = { > >> .recalc = sh_clk_div_recalc, > >> .set_rate = sh_clk_div_set_rate, > >> .round_rate = sh_clk_div_round_rate, > >> .enable = sh_clk_div_enable, > >> .disable = sh_clk_div_disable, > >> }; > > > > Does this implies clock rates should be set using clk_round_rate() and > > not clk_set_rate() if I understand this right? > > Not necessarily... > > Note that both cpg_div6_clock_round_rate() and cpg_div6_clock_set_rate() > in the CCF implementation for DIV6 clocks use rounding. > Yeah but it doesn't seem to me that CCF implementation for DIV6 clocks does have to walk static tables like the old sh clock driver does. They perform rounding, but on the clock dividers given a requested rate and the respective parent clock, if I'm not wrong. Anyway, in this case a much simpler: clk_set_rate(video_clk, clk_round_rate(video_clk, 10000000)); does the job for Migo-R. I will include this in next CEU iterations, since I already have a small comment from you to fix there ;) Thanks j > >> (clk_rate_table_find() is called from sh_clk_div_set_rate()) > >> > >> Or are you supposed to ask for the exact clock rate? Where does the 10 MHz > >> come from? > > > > From board initialization code, in order to provide a valid input > > clock to OV7720 sensor. > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds