Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp393628rwl; Fri, 4 Nov 2022 01:30:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ZjFty7b+JsTn7K0OFZB15qDzEdS9Hp09t/eYuWsYrIn01zNv1qSFB2A3uJfZvi4+BrcYc X-Received: by 2002:a17:902:f551:b0:186:be04:6670 with SMTP id h17-20020a170902f55100b00186be046670mr33898303plf.159.1667550643905; Fri, 04 Nov 2022 01:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667550643; cv=none; d=google.com; s=arc-20160816; b=ZaUX+Jg5W9mF12rBd4FLs+If7zb8VFwBQxVfh9MWvPiIqozfSS8u6y0ullTska4QVU 0TwGaxj7HuKjGIVpkvVqPcyo2+r4mYPaeBTzuIIq1WiYM7zZlw9AHBLMUmABLxSRzgCq N7d2GFYX0+3+C/jBSqwkLU9dM8vkDuV1q3GF8Tdx0lTpq5hdcPbOxicwjKmewJpgyzTn dNh6NZ+M2CqryCdVmwCa55FnDS8vwcaip6B5niO0+3nTZMkoTuna8UkTYZ52/SfCyKbT OpcelpVaB3GUefGqwxDnqGlGz6+VGrk0zhI/lXRosBfJEnHn5LPGUpJc4ZTP6cXa0Ssw TW7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=+H2GO8v3XbY+N5PDhigFQzh8x3FCkd8eGdKQu4ziIlU=; b=d0yJrKd19ffqTEASMyGl/MmoZUNeToPqHl67bQIxLanuJ2jZBEG6xa3bCtuBn9D6Io nb2LQsGRgwIY2w5gzkE3i71iyzGrirz9Y6htac/viPR6ADS8xSsVp3lgowd/jfELzHGW q2Jk/QOSAl8dIK2fUrrdVZIzmOPA/Q7lxC2i4jZ2RKRXN9kjw8tOFvxLaDC3v27mY2VC Aw2GcxF1+HvdNqNkfWlGoVjTuSISMpcMAx4zaXVUD5BYbmdvNKFkSlDeg40YY6mLH4xI QlNxT8L+3PJSPCeyy3/splfwHi6qmOEEgwrb9XcUZkYyiD1+6jcZ4S6muRxEWFCvPHvc PY8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=goh02MBw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d25-20020a630e19000000b0045ceb2c2eb7si4142329pgl.760.2022.11.04.01.30.31; Fri, 04 Nov 2022 01:30:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=goh02MBw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbiKDIOa (ORCPT + 96 others); Fri, 4 Nov 2022 04:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbiKDIO2 (ORCPT ); Fri, 4 Nov 2022 04:14:28 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D95A326109; Fri, 4 Nov 2022 01:14:25 -0700 (PDT) Received: from booty (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 0B06E10000A; Fri, 4 Nov 2022 08:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667549664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+H2GO8v3XbY+N5PDhigFQzh8x3FCkd8eGdKQu4ziIlU=; b=goh02MBw1xLMfvBjotjbiT1KklpqEqtRfEXdeDUE0vdwwwqc4WRzFT3kEkaMqPYUnOVnWq UBYoXdiuVLCurH2PSTnaDu49UYyYCfWLRSBYvoEExn3ETJ0Jy7s0rDBCicK0Nl3av/EHVW HfkD11MkStCAw+/OeisiTYf1UYg9Zn1cjkMQ+A2x3IQZyNsrSm5wvKAywFRKNGN5ZW28lD O2YpRPZdWj/FrKZHb/gl5DhCGnmaDyDcM5xMhjP8j36u9YOfuOSUFB3Nx7HOxXgsvVsnsq aMq92yeSLpi/OujBp1AuRA0U+/PKN+qdHrNf0/RIuPImgL2gNB72zZbmsde3OQ== Date: Fri, 4 Nov 2022 09:14:20 +0100 From: Luca Ceresoli To: Dmitry Osipenko Cc: linux-tegra@vger.kernel.org, Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Stephen Boyd , Thierry Reding , Jonathan Hunter , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , stable@vger.kernel.org, Ben Dooks Subject: Re: [PATCH] clk: tegra: fix HOST1X clock divider on Tegra20 and Tegra30 Message-ID: <20221104091420.4b6d90cb@booty> In-Reply-To: <0e002130-868e-ca51-a1dd-091c269dba5d@collabora.com> References: <20221028074826.2317640-1-luca.ceresoli@bootlin.com> <603a0227-7d25-b9da-6dc3-fa9fe1b951e7@collabora.com> <20221102093255.0b5ba7d6@booty> <0e002130-868e-ca51-a1dd-091c269dba5d@collabora.com> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dmitry, On Fri, 4 Nov 2022 00:44:16 +0300 Dmitry Osipenko wrote: > On 11/2/22 11:32, Luca Ceresoli wrote: > > Hello Dmitry, > > > > On Mon, 31 Oct 2022 03:34:07 +0300 > > Dmitry Osipenko wrote: > > > >> On 10/28/22 10:48, luca.ceresoli@bootlin.com wrote: > >>> From: Luca Ceresoli > >>> > >>> On Tegra20 and Tegra30 the HOST1X clock is a fractional clock divider with > >>> 7 integer bits + 1 decimal bit. This has been verified on both > >>> documentation and real hardware for Tegra20 an on the documentation I was > >>> able to find for Tegra30. > >>> > >>> However in the kernel code this clock is declared as an integer divider. A > >>> consequence of this is that requesting 144 MHz for HOST1X which is fed by > >>> pll_p running at 216 MHz would result in 108 MHz (216 / 2) instead of 144 > >>> MHz (216 / 1.5). > >>> > >>> Fix by replacing the INT() macro with the MUX() macro which, despite the > >>> name, defines a fractional divider. The only difference between the two > >>> macros is the former does not have the TEGRA_DIVIDER_INT flag. > >>> > >>> Also move the line together with the other MUX*() ones to keep the existing > >>> file organization. > >>> > >>> Fixes: 76ebc134d45d ("clk: tegra: move periph clocks to common file") > >>> Cc: stable@vger.kernel.org > >>> Cc: Peter De Schrijver > >>> Signed-off-by: Luca Ceresoli > >>> --- > >>> drivers/clk/tegra/clk-tegra-periph.c | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/clk/tegra/clk-tegra-periph.c b/drivers/clk/tegra/clk-tegra-periph.c > >>> index 4dcf7f7cb8a0..806d835ca0d2 100644 > >>> --- a/drivers/clk/tegra/clk-tegra-periph.c > >>> +++ b/drivers/clk/tegra/clk-tegra-periph.c > >>> @@ -615,7 +615,6 @@ static struct tegra_periph_init_data periph_clks[] = { > >>> INT("vde", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VDE, 61, 0, tegra_clk_vde), > >>> INT("vi", mux_pllm_pllc_pllp_plla, CLK_SOURCE_VI, 20, 0, tegra_clk_vi), > >>> INT("epp", mux_pllm_pllc_pllp_plla, CLK_SOURCE_EPP, 19, 0, tegra_clk_epp), > >>> - INT("host1x", mux_pllm_pllc_pllp_plla, CLK_SOURCE_HOST1X, 28, 0, tegra_clk_host1x), > >>> INT("mpe", mux_pllm_pllc_pllp_plla, CLK_SOURCE_MPE, 60, 0, tegra_clk_mpe), > >>> INT("2d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_2D, 21, 0, tegra_clk_gr2d), > >>> INT("3d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_3D, 24, 0, tegra_clk_gr3d), > >>> @@ -664,6 +663,7 @@ static struct tegra_periph_init_data periph_clks[] = { > >>> MUX("owr", mux_pllp_pllc_clkm, CLK_SOURCE_OWR, 71, TEGRA_PERIPH_ON_APB, tegra_clk_owr_8), > >>> MUX("nor", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NOR, 42, 0, tegra_clk_nor), > >>> MUX("mipi", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_MIPI, 50, TEGRA_PERIPH_ON_APB, tegra_clk_mipi), > >>> + MUX("host1x", mux_pllm_pllc_pllp_plla, CLK_SOURCE_HOST1X, 28, 0, tegra_clk_host1x), > >>> MUX("vi_sensor", mux_pllm_pllc_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor), > >>> MUX("vi_sensor", mux_pllc_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor_9), > >>> MUX("cilab", mux_pllp_pllc_clkm, CLK_SOURCE_CILAB, 144, 0, tegra_clk_cilab), > >> > >> This was attempted in the past > >> https://lore.kernel.org/all/20180723085010.GK1636@tbergstrom-lnx.Nvidia.com/ > >> > >> I assume here you're also porting the downstream patches to upstream. > >> This one is too questionable. The host1x clock shouldn't affect overall > >> performance to begin with. It doesn't make sense to use fractional clock > >> just for getting extra KHz. > > > > Thank you for the review and for the pointer! > > > > Indeed I'm not sure this patch brings an actual improvement to my use > > case, however I reached it by trying to replicate the configuration on > > a known-working kernel 3.1, which uses a 1.5 divider. This seems to be > > the same reason that led to the 2018 patch that also got rejected. > > > > I'll be OK with dropping this patch after I have a 100% working setup > > with an integer divider, which is very likely given your reply. But it > > took time before I found the root cause of this issue, and I would like > > to avoid other people waste time in the future, so what about adding a > > comment there? > > > > What about: > > > > /* > > * The host1x clock shouldn't affect overall performance. It doesn't > > * make sense to use fractional clock just for getting extra KHz, so > > * let's pretend it's an integer divider > > */ > > If host1x isn't the only clock like that, then comment shouldn't be > directed to host1x. Have you checked other clocks? No, apologies, I don't know enough about this SoC to be able to put into a comment anything interesting other than what you wrote in your previous reply. > I'm curious who made that change originally in your downstream, was it > coming from NVIDIA? It is coming from our customer, not sure where they got it initially, but this is the commit where it was added, with a DIV_U71 flag: https://osdn.net/projects/android-x86/scm/git/kernel/commits/d861196163e30c07add471562b45dce38517c9b2 -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com