From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CD39ECAAD4 for ; Tue, 30 Aug 2022 22:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:To:Cc:From:Subject: References:In-Reply-To:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jc+WnjyifV+Rb2GhqDSCfYAh55Uxfj9zoSTxsD/2MPc=; b=nd5hbeyrpXpIcg UOYe/u1id6zDA2eDfUDNF/FrFo+8pMn9Xr1oSv4LhHnKfQ+aUpryB+v5VSbA1VunRJYhlzoWxYPPD uoZCPUPAcKMG4m4ZJd9wiEO2NwzDAATK+fhmZ2FuFIfSA5pB/x6WCINR5N71V7TcFGVfaE2bLUFIT Q87/itC5ePScybcj44wRmOrtWL+cK5nzDHrzUls0WuwGYK2p7kcB/uH0hyx/mo8s8KxUdEbmnTBay 1OO1tzRidFTsyFVIV/3hkDFvjtnxJjn0fHwtoW5FyW3z6AFzOqSBYulsCbxYu2pU0EBbGolFvao+L 1i8PWxo6g6Ck8alC+ebw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT9NR-002Cj0-TK; Tue, 30 Aug 2022 22:06:34 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT9NM-002Cho-9l for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 22:06:31 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A3F1360DE9; Tue, 30 Aug 2022 22:06:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07440C433B5; Tue, 30 Aug 2022 22:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661897187; bh=VVaAyTdAfsCPJoUa2MTvj/q7KQPHl/s8HHj/gCUuUo4=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=LTn4IbBMxJEp6Q7V3tyca8rMfjQhb+1sZ9XVw4Heq6M3hFxTPF2Jf8VJuW4BLujGq 6EnCmAkoYl7oKR4cZWzhieamjP0PFdXe8u+KuZjqkrMvdi5Ecql9GbbuRY0EwHww3k DsW9peqa5b389Czrd08ZNAcSQ5nhxrgOHVzmkeW75iG9iDTUQFVxLmofwIV3KzWZm1 Zww9BFNfLcHwpmy8GlKA0OHCxOwIQicey0IzaNGYyadxq2WJGt1JeuAoHYvHRfdMyh udIxGuajZrdmm6eX2SJDIUz2fj8NhU0VdcQvIIwKAo7GpfFpOcEct730Am3TDKdtHX A/8PrIm1/0vUA== MIME-Version: 1.0 In-Reply-To: <20220826142030.213805-1-quanyang.wang@windriver.com> References: <20220826142030.213805-1-quanyang.wang@windriver.com> Subject: Re: [PATCH] clk: zynqmp: pll: rectify rate rounding in zynqmp_pll_round_rate From: Stephen Boyd Cc: Michael Tretter , Quanyang Wang , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org To: Michael Turquette , Michal Simek , quanyang.wang@windriver.com Date: Tue, 30 Aug 2022 15:06:25 -0700 User-Agent: alot/0.10 Message-Id: <20220830220627.07440C433B5@smtp.kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220830_150628_417729_602E264C X-CRM114-Status: GOOD ( 18.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Quoting quanyang.wang@windriver.com (2022-08-26 07:20:30) > From: Quanyang Wang > > The function zynqmp_pll_round_rate is used to find a most appropriate > PLL frequency which the hardware can generate according to the desired > frequency. For example, if the desired frequency is 297MHz, considering > the limited range from PS_PLL_VCO_MIN (1.5GHz) to PS_PLL_VCO_MAX (3.0GHz) > of PLL, zynqmp_pll_round_rate should return 1.872GHz (297MHz * 5). > > There are two problems with the current code of zynqmp_pll_round_rate: > > 1) When the rate is below PS_PLL_VCO_MIN, it can't find a correct rate > when the parameter "rate" is an integer multiple of *prate, in other words, > if "f" is zero, zynqmp_pll_round_rate won't return a valid frequency which > is from PS_PLL_VCO_MIN to PS_PLL_VCO_MAX. For example, *prate is 33MHz > and the rate is 660MHz, zynqmp_pll_round_rate will not boost up rate and > just return 660MHz, and this will cause clk_calc_new_rates failure since > zynqmp_pll_round_rate returns an invalid rate out of its boundaries. > > 2) Even if the rate is higher than PS_PLL_VCO_MIN, there is still a risk > that zynqmp_pll_round_rate returns an invalid rate because the function > DIV_ROUND_CLOSEST makes some loss in the fractional part. If the parent > clock *prate is 33333333Hz and we want to set the PLL rate to 1.5GHz, > this function will return 1499999985Hz by using the formula below: > value = *prate * DIV_ROUND_CLOSEST(rate, *prate)). > This value is also invalid since it's slightly smaller than PS_PLL_VCO_MIN. > because DIV_ROUND_CLOSEST makes some loss in the fractional part. > > Signed-off-by: Quanyang Wang > --- Applied to clk-next _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel