Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp3684816rwi; Wed, 2 Nov 2022 01:46:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4EEm8Rg4XSKbydU9RjdFQm41OZI6pRSTKgRIeeYUs63kKuG55tRB2Fqq1mofXdtsmXnbch X-Received: by 2002:a17:903:24f:b0:178:bf4f:fc7c with SMTP id j15-20020a170903024f00b00178bf4ffc7cmr6873798plh.124.1667378818021; Wed, 02 Nov 2022 01:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667378818; cv=none; d=google.com; s=arc-20160816; b=b/rORJO4KeYeefwLHP2zosQVbboEH1nXuHOVndWNb81a0Rtjt3hALt9o+dBMiZe1HW 8wkSCYxMWwc2VzC2Sb78KlnDIkUKQxG7HfWShf7KBXFUaItnzNLHhxBq3sRVV7LEdry0 KNCI2H2yH3fJHn5jXzexFcBg45gTrDHAnr8eiqSMLUzzFBP0aXrFNqbMgasFEonZBvnT QyRCGqMTbcTEWCrEPC8ctxV5HflhlJEKmEmtjiurZogp2jzsK6+35OP2vwvLr8355Qlp g59lpDM3+ptmB2VwzYgmoejaDEmUYrzZ6IS5OdZ2ih/YGS8z9yOrU8ezyumhVtmNbj7E 5XmA== 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=nDDyvRuP5YVwgQ4Sv51x8uHgPQuqZr7+R+y4amwnRCA=; b=m5Efu4U0YprlfMRh2PkqvOrrtDYwB0pgyjSh7w7iiF5vX48+3ckxrUYJkVF2spMf0f ki4RjdKQ10SssS9501JnoWAE3/a5SLXCjHMH/x8AsR2iZjtWJjiPWtWLOV+16oUMWHux idyEZOEpbJbjtv8vc5raRHQqQAPRRu/qZU2vD/78eJ30GLj/MYZxyEZnWdRyxY8meS/s TgYebyDylbhbxfsqPhxkowVsI5FhCh3sYsvprbh8crZ1iW7Jm8Ji27IMn4BrJ0JAR408 myJUAhAOK0Nnnts10R7p9TqLVXm2ygB8WnIRLvxDTwHVpDOdXl56QR5U2LR3nCesdvEw Brig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EaZG7r64; 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 l12-20020a17090270cc00b00187204b35besi9790523plt.203.2022.11.02.01.46.44; Wed, 02 Nov 2022 01:46:58 -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=EaZG7r64; 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 S230391AbiKBIdH (ORCPT + 98 others); Wed, 2 Nov 2022 04:33:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230376AbiKBIdD (ORCPT ); Wed, 2 Nov 2022 04:33:03 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE2C27932; Wed, 2 Nov 2022 01:33:00 -0700 (PDT) Received: from booty (unknown [77.244.183.192]) (Authenticated sender: luca.ceresoli@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 54E3840016; Wed, 2 Nov 2022 08:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667377978; 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=nDDyvRuP5YVwgQ4Sv51x8uHgPQuqZr7+R+y4amwnRCA=; b=EaZG7r64T44bSau9BAfVyn1Rg9Www9852QY5f6ONdfxVuykC9ga2q4Y1sQ9fc6FeArOIxK eIstuHfDtP8S4Q4XhXd9wvRvyimA9WVHMqMCf452HwFtFRVE+XzAaSUKoX28i0RgKsMy/1 DfMqm4ZProgyWDBYlL3Pq4bmENNAk/ZgAzIJcOJgnEU84Bguk7w59CxNNugES4I9GYDbFt 3b5SwaL1Ay/G3hMdLHdMMgSHrF6bFwD81bOERx85g3lQih31W20L2GbDJR5N/vJwBXv8y/ OORfRwu2ILWhslXyPimEcLADNgjFiKSEJe4jnE/0Hn/3ovwUThtPN78hD/ukOA== Date: Wed, 2 Nov 2022 09:32:55 +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 , Peter De Schrijver Subject: Re: [PATCH] clk: tegra: fix HOST1X clock divider on Tegra20 and Tegra30 Message-ID: <20221102093255.0b5ba7d6@booty> In-Reply-To: <603a0227-7d25-b9da-6dc3-fa9fe1b951e7@collabora.com> References: <20221028074826.2317640-1-luca.ceresoli@bootlin.com> <603a0227-7d25-b9da-6dc3-fa9fe1b951e7@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 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 */ ? -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com