Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp939203rwd; Wed, 31 May 2023 07:27:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61+NYXzoWoc7WCzoqDm9cQ7nXTOhfJm8VWuQgcEWqNxR3T2y+c0cn22P5jWrMP5BW/SPek X-Received: by 2002:a05:6a20:4326:b0:10a:dafc:aef5 with SMTP id h38-20020a056a20432600b0010adafcaef5mr5848077pzk.34.1685543252364; Wed, 31 May 2023 07:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685543252; cv=none; d=google.com; s=arc-20160816; b=JIXPk5SaG3voOUU0Q1VRGHiYYZPWnmkYYNKeGsJtK0zeg2f8xnTTCuyxyok8UL6uJy J15l6kkeb7hQtKtyfGqIpVdO2yOoN8YfJqx4N+CuzX63VNUteAq4kZc+x8VsXr0eebck ngPutSj90Q2yHQiFSgEagC77T+4gPqwsLyr/MVYkhUBhCrYSo+VBEQJUmYgJPdXRybTq pdsq5d96Dq0qJzC+hJ+ijoc0R411LrB66r3nDl+YdZODhyIXVlq8Uw3PByBVvU6WVMnW RXhTDh+WVXs7QGlfsta3XLjCUYadXN2cZRUentJUd7OYf9rbhp4AHdz0wzKpqqx5NKp2 wjFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kyEMKBvd/be2zIaXWqQFWSTgoQTLWkljg3hPufnH/II=; b=ciuBruNuZwy0eP5V+a5+WVOpkMcn86pUQorXMLTlDz6i3hfobnIYsHaiXhJG1NKcXe dlsY67bTb8C0pLxduhNhZelXNOvBQX6lx5uj2cqIRhbq3H4ikRGY6p4ZtoGPHUZO0aCA EM/be6SiDo5c2mSnzQFkaqN517oVJWEhdQF/CG3epTP452Iieq6MrD6BBG5yQQcUzevc 1ez5F7AKsRqubKHS0cgvK2H2jCld0T9u47nhN/cVKKWxYJOB4zrxE/otjAVj5wf1497M jeQj55+skqUQUZFIMxjwm5iYTkBdv+gUbsI2j86kAiFNJaLo8uD/c+4lcKlnXov04aXo G4eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iQu9QtR0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a65480b000000b005308fb9619asi1047123pgs.54.2023.05.31.07.27.20; Wed, 31 May 2023 07:27:32 -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=@kernel.org header.s=k20201202 header.b=iQu9QtR0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237493AbjEaOEF (ORCPT + 99 others); Wed, 31 May 2023 10:04:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237270AbjEaODk (ORCPT ); Wed, 31 May 2023 10:03:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A99930CF; Wed, 31 May 2023 06:58:08 -0700 (PDT) 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 B454D63BDA; Wed, 31 May 2023 13:48:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 984E3C433EF; Wed, 31 May 2023 13:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685540926; bh=5oiWn6L9rJqvMfCt+T7VTPNle9Rnvsv/ziJ/f7AOOsc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iQu9QtR0wBqSrRiiuepq4IExLg5r6UtNI9pderJLGcaJDMrkAbtMSLA/ccZClJHlh ceLh1hziCxKv3Uv4cJ2ZP8FWOR8+cVonqIKTAOEnqtTxActK3j0LsiJDmDbd9JjgDn l0uXBQLscmnWHb2ZfLooP0bsfPZLlJIQWifDetum5djG3yL3gtX4RRgiXxIPPei1ff LbYkQf7aai9Yehjq/YOXfYVL+QQFnXKCc7d8bdZAyP8v1kIElycciWBQALnBmtu+MT 2eMI1Rm9LuqM2fio1ElVVnu3mCxr3iTgaZ7V0HqVcHPKoPDaCZcKUOmVmfyuan2W50 0fPO5tgMYxNTg== Date: Wed, 31 May 2023 15:48:43 +0200 From: Maxime Ripard To: Frank Oltmanns Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Andre Przywara , Chen-Yu Tsai , Icenowy Zheng , Jernej Skrabec , Michael Turquette , Rob Herring , Samuel Holland , Stephen Boyd Subject: Re: [RFC PATCH 0/3] clk: sunxi-ng: Optimize rate selection for NKM clocks Message-ID: References: <20230527132747.83196-1-frank@oltmanns.dev> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4ll2i5xo7tjkazzo" Content-Disposition: inline In-Reply-To: <20230527132747.83196-1-frank@oltmanns.dev> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --4ll2i5xo7tjkazzo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Frank, On Sat, May 27, 2023 at 03:27:44PM +0200, Frank Oltmanns wrote: > I would like to bring your attention to the current process of setting > the rate of an NKM clock. As it stands, when setting the rate of an > NKM clock, the rate nearest but less than or equal to the requested > rate is found, instead of the nearest rate. Yeah, it's actually pretty common, see clk_mux_determine_rate_flags() for example. Some devices require that we don't overshoot, while some prefer to have the closest rate. Both are fine, and it's a bit context specific which one we should favour. If we were to do anything, it would be to support both and let the clock driver select which behaviour it wants. > Moreover, ccu_nkm_find_best() is called multiple times (footnote [1]) > when setting a rate, each time iterating over all combinations of n, > k, and m. Yeah, that's expected as well. > In response to this, I propose the following refinements to optimize the NKM > clock setting: > a. when finding the best rate use the nearest rate, even if it is greater than > the requested rate (PATCH 1) > b. utilize binary search to find the best rate by going through a > precalculated, ordered list of all meaningful combinations of n, k, and m > (PATCH 2) One thing you haven't really addressed is why we would be doing this? Is there some clocks that require a more precise clock and don't? Is the factor calculation a bottleneck for some workloads? Clocks in general are very regression-prone, so I'd rather be a bit conservative there, and "if it ain't broke, don't fix it". Maxime --4ll2i5xo7tjkazzo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZHdQOwAKCRDj7w1vZxhR xY7YAQCRMdM5sXe5+PRdsFQ42wN/ON/BTZv5VyjJjPNXDSV+fwEAxbyTFNxkGl7t ATFXYYJKY2m8tEcRbPXGriRr5AMQKQ0= =vNhW -----END PGP SIGNATURE----- --4ll2i5xo7tjkazzo--