Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp4192321rba; Tue, 2 Apr 2024 09:48:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUgUZHkTiPPXUBwTlYxUbnBkljw0TJxWbOIan45ziXEq11IRBuPiIVaaq5Wvs/ErGHAQlPAIhC+AdBxTS4MIwLwEfjfJd+zlkOomqvpZw== X-Google-Smtp-Source: AGHT+IEh3KLEJgwRm+u30ExyRhLSe5fv7nhYolsV6n8I4TNzAQ9/JvBqlgx5fqZoiuCuNV7pG/vB X-Received: by 2002:a05:6a20:432b:b0:1a3:7e87:970 with SMTP id h43-20020a056a20432b00b001a37e870970mr16707575pzk.37.1712076520307; Tue, 02 Apr 2024 09:48:40 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v12-20020a17090abb8c00b0029fb80a4abcsi13867360pjr.88.2024.04.02.09.48.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 09:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128339-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=DJDRrDbN; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-128339-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 48F6BB2B93E for ; Tue, 2 Apr 2024 16:18:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBA0114AD34; Tue, 2 Apr 2024 16:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DJDRrDbN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADB8C2E40D; Tue, 2 Apr 2024 16:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712074696; cv=none; b=ssW2UpaKAMxVibG/lFzb2xTPZuN0h3dn8vD9eOfyaIjoLQh5PSr3zKkH+lKjgsTai3na9d1g1snzNiEVrBzQ+1NFcP1lNpm0ocWM8gRxrflUedG100z2RmswU1h6COAZP2Z1Nb+y0+tAScKMpW1qfseTUJrsAHumRuU3n1nQ9bk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712074696; c=relaxed/simple; bh=tqIuMZfC4MsoHlk9HVhKG/9PpH5oRCBJruwdKEA1VZw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iAHGQuxQBJ3/f9rHZtOuEBGHox+yqqQHPgd0QneqeYJvSyXOz425WaxLu8OWTOOfTfslNnZaG2YXfejVohG+V4/FAKolW3qsJomtkIx//xlMGrEyZauwkR1rBgTlK8R2HSH/bEu9vDi/Z0S3DcYe5SvfUE+3FhtZa16VX1bcEwQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DJDRrDbN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD868C433C7; Tue, 2 Apr 2024 16:18:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712074696; bh=tqIuMZfC4MsoHlk9HVhKG/9PpH5oRCBJruwdKEA1VZw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=DJDRrDbNLGOiNgFd3/HXrhBy/yplIQOUciqf0NwEUhNc72OkVudEPXLgseBuiTuH4 pUA3CN2l7ysl7ggJ34ZEsWQ7OFWB5VHUASq0qWrCkNd/XjeUaXzeyROLPwyqYDErUE lOBbvSaXwblHk4UiHlCfUmsQFGef9Z/F4EqEYjVhWWnGtfj7ZPnhhvW4I59deE5x2r cHMZmr3qnkY9FnT16mx1+RdGMgM2zEHDH6ldN2F0WOuCUXUNdLjltPRgEPPmg+6EwU gDwCDAzmLWBsmutde7WRplqOrZ5LgeqtJUg7wsi5USu3F/XEFULPbLJQqtjrTtZ5Lh xQPC+Do4UQCfQ== Message-ID: <8d21b1bc-9402-41d4-bd81-c521c8a33d2d@kernel.org> Date: Tue, 2 Apr 2024 18:18:09 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] clk: starfive: pll: Fix lower rate of CPUfreq by setting PLL0 rate to 1.5GHz To: Xingyu Wu , Michael Turquette , Stephen Boyd , Conor Dooley , Emil Renner Berthing , Rob Herring , Krzysztof Kozlowski Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org References: <20240402090920.11627-1-xingyu.wu@starfivetech.com> Content-Language: en-US From: Krzysztof Kozlowski Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEA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NaFahT0lRPjYtrTa1v3tem/ JoFzZ4B0p27K+qQCF2R96hVvuEyjzBmdq2esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <20240402090920.11627-1-xingyu.wu@starfivetech.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 02/04/2024 11:09, Xingyu Wu wrote: > CPUfreq supports 4 cpu frequency loads on 375/500/750/1500MHz. > But now PLL0 rate is 1GHz and the cpu frequency loads become > 333/500/500/1000MHz in fact. > > So PLL0 rate should be default set to 1.5GHz. But setting the > PLL0 rate need certain steps: > > 1. Change the parent of cpu_root clock to OSC clock. > 2. Change the divider of cpu_core if PLL0 rate is higher than > 1.25GHz before CPUfreq boot. > 3. Change the parent of cpu_root clock back to PLL0 clock. > > Reviewed-by: Hal Feng > Fixes: e2c510d6d630 ("riscv: dts: starfive: Add cpu scaling for JH7110 SoC") > Signed-off-by: Xingyu Wu > --- > > Hi Stephen and Emil, > > This patch fixes the issue about lower rate of CPUfreq[1] by setting PLL0 > rate to 1.5GHz. > > In order not to affect the cpu operation, setting the PLL0 rate need > certain steps. The cpu_root's parent clock should be changed first. And > the divider of the cpu_core clock should be set to 2 so they won't crash > when setting 1.5GHz without voltage regulation. Due to PLL driver boot > earlier than SYSCRG driver, cpu_core and cpu_root clocks are using by > ioremap(). > > [1]: https://github.com/starfive-tech/VisionFive2/issues/55 > > Previous patch link: > v2: https://lore.kernel.org/all/20230821152915.208366-1-xingyu.wu@starfivetech.com/ > v1: https://lore.kernel.org/all/20230811033631.160912-1-xingyu.wu@starfivetech.com/ > > Thanks, > Xingyu Wu > --- > .../jh7110-starfive-visionfive-2.dtsi | 5 + > .../clk/starfive/clk-starfive-jh7110-pll.c | 102 ++++++++++++++++++ Please do not mix DTS and driver code. That's not really portable. DTS is being exported and used in other projects. .. > > @@ -458,6 +535,8 @@ static int jh7110_pll_probe(struct platform_device *pdev) > struct jh7110_pll_priv *priv; > unsigned int idx; > int ret; > + struct device_node *np; > + struct resource res; > > priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > if (!priv) > @@ -489,6 +568,29 @@ static int jh7110_pll_probe(struct platform_device *pdev) > return ret; > } > > + priv->is_first_set = true; > + np = of_find_compatible_node(NULL, NULL, "starfive,jh7110-syscrg"); Your drivers should not do it. It's fragile, hides true link/dependency. Please use phandles. > + if (!np) { > + ret = PTR_ERR(np); > + dev_err(priv->dev, "failed to get syscrg node\n"); > + goto np_put; > + } > + > + ret = of_address_to_resource(np, 0, &res); > + if (ret) { > + dev_err(priv->dev, "failed to get syscrg resource\n"); > + goto np_put; > + } > + > + priv->syscrg_base = ioremap(res.start, resource_size(&res)); > + if (!priv->syscrg_base) > + ret = -ENOMEM; Why are you mapping other device's IO? How are you going to ensure synced access to registers? Best regards, Krzysztof