Received: by 10.223.176.46 with SMTP id f43csp2211140wra; Thu, 25 Jan 2018 06:37:05 -0800 (PST) X-Google-Smtp-Source: AH8x225fff7gVQAJLc9SUzTb/W5SXm3EakL0o0fwUHWnL4Kh9dFl4MmWSBp0iSn9DYB3XwHNprja X-Received: by 2002:a17:902:8a97:: with SMTP id p23-v6mr11586770plo.74.1516891025699; Thu, 25 Jan 2018 06:37:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516891025; cv=none; d=google.com; s=arc-20160816; b=C38LTQFJEVKrFRAeFslgKTrSkcIZBFAYRoRZzSP4HryPRUybNJNYiYO6sXZN11is3q ZHxAIN0jaMBsctZpOeSK7dBoHAK531umSKjmPnkzmHfYF+0pMT1oDW0v/K17he+vOIvA IjxwZve9iD5qBSJoXO+3WYV9apHCyUGJTXmjxNkHppHyPx43cK+cvnp2Kionz23oiBCS T30g4KdzF4SDpDgQNSfbxNRpcLvgqyAtxVPbxZXM43hD/F9sRaN5sisXogoyI11oHHZl YIM23el90h+zFHhCGis/ocHdTJVqf4iL6sr/4+YORmK/nRyW8JBmIVWWu7+L4JuTtyOc NohA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=d+3KvE/L1s+RW6+AVMai6179/Vzy5pLUKp+M5B5d0Xw=; b=ExQOfaQM7BAtUnmgxB98uULm+uvvnYy4CnjRPe9jrN1PDs1Y3P3dGy8xbapT46jqlx +khF6zpN49eihJTUW0XvYvFXeORt7Ih6QpIznlD3X2rEIGiHogKrRnjJtH9bxswtUXcH pvQyJNHg+ZxTcDjxPvq4OJYegTBlZ8J11CHHSrtFx3pH6Z58iyWRIbYwh3rPJrRkiByP z/kDESid7gWg+zXIXHGf/Tmi1mwk2Lw3pvweAT942WQ7uwrZwR76nwZY4hlxBvdZw5Ok B4bxTdmSlIZFQ/upfd+Rp1IsuU8ufDilNil377ZJU8b5/S+WC29LQYuamPGVu0t0vCcP Xg5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=dnX4RIwq; 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 w23si1638132pgc.569.2018.01.25.06.36.51; Thu, 25 Jan 2018 06:37:05 -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=fail header.i=@gmail.com header.s=20161025 header.b=dnX4RIwq; 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 S1751367AbeAYNxp (ORCPT + 99 others); Thu, 25 Jan 2018 08:53:45 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:33200 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750980AbeAYNxm (ORCPT ); Thu, 25 Jan 2018 08:53:42 -0500 Received: by mail-qt0-f194.google.com with SMTP id d8so19327921qtm.0; Thu, 25 Jan 2018 05:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=d+3KvE/L1s+RW6+AVMai6179/Vzy5pLUKp+M5B5d0Xw=; b=dnX4RIwqGo7ZvBCQR1GW+d8jRS6x45PxN0tVmSprbW0psfgMjPK8HAq+p4uMV7HAUl pME5lP5UMtJYz2guJF4K57tVcYqRfsObXWwdnsv20epTIxT6+EHWLbYV12khCUgxlhii UUCV+3qnHn+JYj8sBxpNyPJwKZq+3gmf9Bv9l1LPPsMzRKBQdwO0chHaPimuNaKBW3TA hbLrffbry3wA0Q90c8vAY/qki/3KL22l5csyhfaYTQrKWl+oH2I6psKeABU2iU06jcTA eIq3WCMUCvgpHLnCjRTmQdAMFrZhc/b/uEGO0pAlC5iMIkSJ/8F58/b/0k0CtYifKTiz Hapg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=d+3KvE/L1s+RW6+AVMai6179/Vzy5pLUKp+M5B5d0Xw=; b=tp98FTOrfcZrY8ARlgEJvB8/jiJTmnjMEXkLM6+nJa2TlKf5IHfXdC3IoIlnM+QIzl W5AGeGRtbzIIHs5EEj1Po4eHYtAn5pXnh1NlaiPexmfsXvl0zBplrY6Zc9fVwzGnbOPb 8r4zcWFYoKvnpLe0c4iikuiX9/eacINEtZdyuFWFt8Q4cR8GRwZUmkjNywYnRDXRLlDG /FTQYgMvjMtucf0dAf+tN2Ugh1Q1RzWBTN9PYKyv9N2pN6f6Obw4kGoozbYLu2lRh3cn nFcTjDHBNSAiyQY62tmiT6rph7MCn0fgr+UV0ECn9/bSU+AjnJIeMZiUjuriA8dpKTpu fFZw== X-Gm-Message-State: AKwxytf/Vurej236BO53QU8YlO0sjgEHUvAFYgAiRO7Ul+cZNxYQ7MHW ZSm7juDmsMxLv09/RnTiGXgBmHieGmyeDDT3yhQ= X-Received: by 10.55.46.69 with SMTP id u66mr13815260qkh.259.1516888421588; Thu, 25 Jan 2018 05:53:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.45.161 with HTTP; Thu, 25 Jan 2018 05:53:41 -0800 (PST) In-Reply-To: <1516879493-24637-1-git-send-email-jacopo+renesas@jmondi.org> References: <1516879493-24637-1-git-send-email-jacopo+renesas@jmondi.org> From: Geert Uytterhoeven Date: Thu, 25 Jan 2018 14:53:41 +0100 X-Google-Sender-Auth: VAPReqW3R2Y3hjfWZdi0siss0ys Message-ID: Subject: Re: [PATCH] sh: clk: Relax clk rate match test To: Jacopo Mondi Cc: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacopo, CC linux-clk (yes I know this is about the legacy SH clock framework, but the public API is/should be the same) On Thu, Jan 25, 2018 at 12:24 PM, Jacopo Mondi wrote: > When asking for a clk rate to be set, the sh core clock matches only > exact rate values against the calculated frequency table entries. If the > rate does not match exactly the test fails, and the whole frequency > table is walked, resulting in selection of the last entry, corresponding to > the lowest available clock rate. IIUIC, the code does not select the last entry, but returns an error code, which is propagated all the way up? > Ie. when asking for a 10MHz clock rate on div6 clocks (ie. "video_clk" line), > the calculated clock frequency 10088572 Hz gets ignored, and the clock is > actually set to 5201920 Hz, which is the last available entry of the frequencies > table. Perhaps 5201920 is just the default (or old value)? > Relax the clock frequency match test, allowing selection of clock rates > immediately slower than the required one. > > Signed-off-by: Jacopo Mondi > > --- > Hello renesas lists, > > I'm now working on handling frame rate for the ov7720 image sensor to have that > driver accepted as part of v4l2. The sensor is installed on on Migo-R board. > In order to properly calculate pixel clock and the framerate I noticed the > clock signal fed to the sensor from the SH7722 chip was always the lowest > available one. > > This patch fixes the issues and allows me to properly select which clock > frequency supply to the sensor, which according to datasheet does not support > input clock frequencies slower than 10MHz (but works anyhow). > > As all patches for SH architecture I wonder where they should be picked up from, > as SH seems not maintained at the moment. > > Thanks > j > > --- > 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, }; (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? > + > + return pos - freq_table; > + } > > return -ENOENT; > } 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