Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1633221rda; Mon, 23 Oct 2023 20:38:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYEDo+1knujgJOPmC6/t0bICOPbkIsS9X8sYyT8tm4nLcd6qhyty1UehiaBzBqlPZxLgud X-Received: by 2002:aca:d19:0:b0:3b2:e61f:f0a8 with SMTP id 25-20020aca0d19000000b003b2e61ff0a8mr11978168oin.45.1698118693035; Mon, 23 Oct 2023 20:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698118692; cv=none; d=google.com; s=arc-20160816; b=xxuJaJBFGBSOyNXGcF4kC2I76b0t+YGHHNIDtJC7zkgw6vRzKSan4NVJR8gHfm8mck wiP+QBYRGBxBtRQwHGWZCjlyEJT05Nh+acet4NLC+doU+ooxqHg9PrjMNv5NVNfNuBsN jrguAiNaeMdhzuGZ4eFNRzyK7f+R2gf/Q79WaCQvegIRAaltT4pELrjJBeXy84oUcxQN 6hrHKYpZZwJRoLfqdGPPy35AVooekzEpFYzaZJL+JrD87Vg6M5He6idFWUBmw3rVxGFr V1yTArD8DpNIxIcRFK0CJKrVNSubc4Rme4+9kKYjAGBKg3fkI13hf7fqTQBCtXc5drGT BFMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:date:to:cc:from:subject:references :in-reply-to:content-transfer-encoding:mime-version:message-id :dkim-signature; bh=7bbKSrqBNUHosQj+tAs3YpR1GL+xoL6PIflZNrwvrp4=; fh=/LH0r9S4eyEDe58t2VyaLGAKKqu/xpfWA+AmyqQGeUQ=; b=Zj4EgEQu+FL4AOlvnCuuR8ug5P5baIEVoe3UuUtfekA1J1Jx0dHxHtVqa9dgMZPF8O AKHjtl1OJ3y9J1XJy3+Nh0CIcbfy3tFIQksMLld+F6kYSaP5vEI5xdPZFgIKZ82Nf9hB iZ8e3/KO4fDx6SGTw0dt6qGb1NxoMX2feTs5/3ojsma9oVBTuOarcW7I6FEifUSt+VWC ZFp/aoCYalp79IciF09ob71cvBv+xwL1gMrXXTARt+s14A1XSX8Zb+eBY8nY6KAPUboA zzHBQz0sNJkqmlmgvSFMPgIHRt9PTjS1Ewvmm4YO0pKazaiPtoHyZ/7PtWWW/s10/N+Z QckQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DznAzuMn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id c18-20020a637252000000b00578a2da998asi7900459pgn.304.2023.10.23.20.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:38:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DznAzuMn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id AE4BC8097793; Mon, 23 Oct 2023 20:38:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232042AbjJXDhz (ORCPT + 99 others); Mon, 23 Oct 2023 23:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbjJXDhy (ORCPT ); Mon, 23 Oct 2023 23:37:54 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E6B83; Mon, 23 Oct 2023 20:37:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA808C433C7; Tue, 24 Oct 2023 03:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698118671; bh=YwS7fpAn8GYq+ycGNrZLGcNoPLL/m1ouHBG1tLxpjOI=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=DznAzuMndKCSVwnuNxZ0LwSURLYuvYBCIRO9ARmxplQ1caCts7t2UKAW3upwNYrcL +p7WmKKvF7IGYMvcjcDzg/jii852UsiEUon9E9Ql+LQoPgjKRVhSGAI06OpCSyv/lr CJRz+FwaLYYvDX8Ybmq9WsCo2Y0/93Q+4daSXtJipO9/ryq4N7Odk+3+JgW9cPwiMB te9XieUs9oHiAfPzEKwTV1gwJKO0lEZM8OBlwYmu1fzd4KgnBQN2FZQcXRryjTeMwn mrfRWfTiFMboCtclKW+H2H60bm3xLQrwmpZWOxTTh7YIvkzET7nFacNkfu2jfpCtiN 6CsYF8nfgF3SQ== Message-ID: <3ff911fa4c417a81462813f975ac757f.sboyd@kernel.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20231016113002.15929-3-jay.buddhabhatti@amd.com> References: <20231016113002.15929-1-jay.buddhabhatti@amd.com> <20231016113002.15929-3-jay.buddhabhatti@amd.com> Subject: Re: [PATCH RESEND 2/2] drivers: clk: zynqmp: update divider round rate logic From: Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jay Buddhabhatti To: Jay Buddhabhatti , michal.simek@amd.com, mturquette@baylibre.com Date: Mon, 23 Oct 2023 20:37:49 -0700 User-Agent: alot/0.10 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 20:38:10 -0700 (PDT) Quoting Jay Buddhabhatti (2023-10-16 04:30:02) > Currently zynqmp divider round rate is considering single parent and > calculating rate and parent rate accordingly. But if divider clock flag > is set to SET_RATE_PARENT then its not trying to traverse through all > parent rate and not selecting best parent rate from that. So use common > divider_round_rate() which is traversing through all clock parents and > its rate and calculating proper parent rate. >=20 > Signed-off-by: Jay Buddhabhatti > --- > drivers/clk/zynqmp/divider.c | 70 ++++++------------------------------ > 1 file changed, 10 insertions(+), 60 deletions(-) Can't argue against removing that many lines! >=20 > diff --git a/drivers/clk/zynqmp/divider.c b/drivers/clk/zynqmp/divider.c > index 33a3b2a22659..a42c183d7e5d 100644 > --- a/drivers/clk/zynqmp/divider.c > +++ b/drivers/clk/zynqmp/divider.c > @@ -193,23 +149,17 @@ static long zynqmp_clk_divider_round_rate(struct cl= k_hw *hw, > return DIV_ROUND_UP_ULL((u64)*prate, bestdiv); > } > =20 > - bestdiv =3D zynqmp_divider_get_val(*prate, rate, divider->flags); > - > - /* > - * In case of two divisors, compute best divider values and return > - * divider2 value based on compute value. div1 will be automatic= ally > - * set to optimum based on required total divider value. > - */ > - if (div_type =3D=3D TYPE_DIV2 && > - (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) { > - zynqmp_get_divider2_val(hw, rate, divider, &bestdiv); > + max =3D divider->max_div; > + while (max !=3D 0) { > + if ((max & 1) =3D=3D 1) > + width++; > + max =3D max >> 1; Is this ffs()? > } > =20 > - if ((clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) && divider->is_f= rac) > - bestdiv =3D rate % *prate ? 1 : bestdiv; > + rate =3D divider_round_rate(hw, rate, prate, NULL, width, divider= ->flags); > =20 > - bestdiv =3D min_t(u32, bestdiv, divider->max_div); > - *prate =3D rate * bestdiv; > + if (divider->is_frac && (clk_hw_get_flags(hw) & CLK_SET_RATE_PARE= NT) && (rate % *prate)) > + *prate =3D rate;