Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp26038988rwd; Mon, 3 Jul 2023 04:48:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpX0DAAeydY0O9iXHCqPfRfayiTtI89QsnCDrcoSNsvry/H9CM0ThK/dUwYWWwGK0Dp/8N X-Received: by 2002:a05:6808:1d5:b0:3a3:a8ce:c634 with SMTP id x21-20020a05680801d500b003a3a8cec634mr2246891oic.53.1688384911666; Mon, 03 Jul 2023 04:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688384911; cv=none; d=google.com; s=arc-20160816; b=H/EQqh/TcLmmQXqbaE9LRcK3H6WNOIeP/ZGZlJ+N0PJCRmSI70mO7LhAkgVRiV8fTw OYioWvb5JYMmMXolEABov/PAqrqlSbeyU74qkQ9xLgT2tHjqyofuIvoeZkl3PelP3pPo TbXP8F4YgkWDlcTNM9kjFX0cV2S+UpwhnM5mVsflRbphDqVhmYZJRwmKnIAr8S50+ipy gJKNVonjCn6P7WNE0mzUApIsyAo6lRTyzRwmEoiF7e65vtxSM2N85/D0Fh/2TiRtZNBk dxFPcbs4oP8VweGMHpBjNxwnAcr6SHioGNgFh0HJmy7wtgqVVP1tM/qHva7yhVEPp+EA K/iQ== 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:feedback-id :dkim-signature:dkim-signature; bh=6FGhhmRXoSlOTB/lM1bsSqDmlfwYny54Qvppyq5eXOc=; fh=+KcAhWSG9RzC2SvYVXgDzJ1nkcDBnTpIanTuJBxcWXo=; b=uzO1KtlbzKsMwk7t4zsZ1C91lrj576CmuBlm8HZHmRz6Y+wD82MBfVUprs4N//YZRJ 5ogLmk0U+U25MW7kybtFo7eMPQ8M+M9HOBJgHwgZhhkXfLcJkpeW9FW5thJHhAU+JV64 HW79d3+v3GCQGNu323PcpLwoeAPHcyLpokggtAMT6NQpn3t3ImwrneCpFeTdY5j0oXVZ 60lQWjaOHb9BwpLbRcxvFo1jcwzo8TwYJF6X814Jk6D08CTRF8emVBp4OWJOpIa4W/Xl PkD4502rnTIz2AlKXTRFyoKbvYWmR9U9ywWOwQzAZNQBY5VkpC0r7rErZ4VPTmYd2xal AEhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=SIq2vErI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XV3moJlN; 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=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 136-20020a63028e000000b0055bac19d21bsi1636436pgc.679.2023.07.03.04.48.16; Mon, 03 Jul 2023 04:48:31 -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=@cerno.tech header.s=fm2 header.b=SIq2vErI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XV3moJlN; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbjGCLhV (ORCPT + 99 others); Mon, 3 Jul 2023 07:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjGCLhU (ORCPT ); Mon, 3 Jul 2023 07:37:20 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9286B8; Mon, 3 Jul 2023 04:37:18 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2F70A5C0318; Mon, 3 Jul 2023 07:37:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 03 Jul 2023 07:37:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1688384238; x=1688470638; bh=6F GhhmRXoSlOTB/lM1bsSqDmlfwYny54Qvppyq5eXOc=; b=SIq2vErINz4Dv/7ikh q1n9lpCubM0avIVPYcv1DdF0jMeAP5tnTuNAcSnX1e39uVNplns/UGsJNd+Hvukp f9AX0fiEjiVqHt+JUGzEGc0ERen2hzXw5wAAjgVLA9TeVhEdz8XKfInCQTP4iLUm Objfb5LvNHEFoy+Gye3kNU4elR2h8Wfp6iMJmQ5hYM5pa5reLArZn8KCPJD+SKAT pNn7dc8+edtvr1tC4xKVlXSMtezhFVFb02cZvbcs+yaX8ZFhFMCii8DaDlTUuK4D O49RmPO3ZhmgGAvjoIazY8m3Lzv1FUzf5iIMQDXFI9tLPeCR0GurzuBzO8LhL7R4 spEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1688384238; x=1688470638; bh=6FGhhmRXoSlOT B/lM1bsSqDmlfwYny54Qvppyq5eXOc=; b=XV3moJlNqdLxir1yGjLCg16Snsu8K z0jdBjcV7fbboWJFqDMwoVODSnfnaOjYX9rcq5Gqq+A3lk5GqGP2vCzszkYO4VxV ItRJcZN0G1QbbConNS4Z6Lq1BOmPg9QhuejBI3eYwvVTf22HomW7OsuY8yUTtTNx qGq95gxT7Zk7H6DIEaPPdc90wE4O8+xviYCvJVQ3Iv0tO6kD2nJSabIRzor3Z6BG RuCxzmun8EI/OUKXC1EyKFZgVL9vdmCvUu4i6y9EiJnnSbYcWqxNtP0VlVvuJ/9c jNJEDPUIQi9HY01x0AoGQDdU43nWyiLiRcbivrgg/pPCKm1cB4pc/bQAw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddvgdegudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtdfsredttddvnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepueevudehuedtkeevgfduveejueefvddvvefhjefglefgtdekveeugeetkefg leefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jul 2023 07:37:17 -0400 (EDT) Date: Mon, 3 Jul 2023 13:37:15 +0200 From: Maxime Ripard To: Frank Oltmanns Cc: Michael Turquette , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andre Przywara , Roman Beranek , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 6/8] clk: sunxi-ng: mux: Support finding closest rate Message-ID: References: <20230702-pll-mipi_set_rate_parent-v3-0-46dcb8aa9cbc@oltmanns.dev> <20230702-pll-mipi_set_rate_parent-v3-6-46dcb8aa9cbc@oltmanns.dev> <87fs65s6aj.fsf@oltmanns.dev> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="t2tjec4yx3o7pbhi" Content-Disposition: inline In-Reply-To: <87fs65s6aj.fsf@oltmanns.dev> 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 --t2tjec4yx3o7pbhi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 03, 2023 at 11:17:24AM +0200, Frank Oltmanns wrote: >=20 > On 2023-07-03 at 09:38:48 +0200, Maxime Ripard wrote: > > [[PGP Signed Part:Undecided]] > > On Sun, Jul 02, 2023 at 07:55:25PM +0200, Frank Oltmanns wrote: > >> When finding the best rate for a mux clock, consider rates that are > >> higher than the requested rate by introducing a new clk_ops structure > >> that uses the existing __clk_mux_determine_rate_closest function. > >> Furthermore introduce an initialization macro that uses this new > >> structure. > >> > >> Signed-off-by: Frank Oltmanns > >> --- > >> drivers/clk/sunxi-ng/ccu_mux.c | 13 +++++++++++++ > >> drivers/clk/sunxi-ng/ccu_mux.h | 17 +++++++++++++++++ > >> 2 files changed, 30 insertions(+) > >> > >> diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu= _mux.c > >> index 8594d6a4addd..49a592bdeacf 100644 > >> --- a/drivers/clk/sunxi-ng/ccu_mux.c > >> +++ b/drivers/clk/sunxi-ng/ccu_mux.c > >> @@ -264,6 +264,19 @@ static unsigned long ccu_mux_recalc_rate(struct c= lk_hw *hw, > >> parent_rate); > >> } > >> > >> +const struct clk_ops ccu_mux_closest_ops =3D { > >> + .disable =3D ccu_mux_disable, > >> + .enable =3D ccu_mux_enable, > >> + .is_enabled =3D ccu_mux_is_enabled, > >> + > >> + .get_parent =3D ccu_mux_get_parent, > >> + .set_parent =3D ccu_mux_set_parent, > >> + > >> + .determine_rate =3D __clk_mux_determine_rate_closest, > >> + .recalc_rate =3D ccu_mux_recalc_rate, > >> +}; > >> +EXPORT_SYMBOL_NS_GPL(ccu_mux_closest_ops, SUNXI_CCU); > >> + > > > > This is also a bit inconsistent with the other clocks: most (all?) of > > them will simply handle this through a flag, but this one requires a new > > set of clk_ops as well? > > > > I think we should create our own wrapper here around > > __clk_mux_determine_rate and either call > > __clk_mux_determine_rate_closest or __clk_mux_determine_rate depending > > on the state of the flags, or call __clk_mux_determine_rate_flags with > > the proper flags set for our clock. > > > > The former is probably slightly simpler. >=20 > Ok, I will address that in v4. >=20 > > > >> const struct clk_ops ccu_mux_ops =3D { > >> .disable =3D ccu_mux_disable, > >> .enable =3D ccu_mux_enable, > >> diff --git a/drivers/clk/sunxi-ng/ccu_mux.h b/drivers/clk/sunxi-ng/ccu= _mux.h > >> index 2c1811a445b0..c4ee14e43719 100644 > >> --- a/drivers/clk/sunxi-ng/ccu_mux.h > >> +++ b/drivers/clk/sunxi-ng/ccu_mux.h > >> @@ -46,6 +46,22 @@ struct ccu_mux { > >> struct ccu_common common; > >> }; > >> > >> +#define SUNXI_CCU_MUX_TABLE_WITH_GATE_CLOSEST(_struct, _name, _parent= s, _table, \ > >> + _reg, _shift, _width, _gate, \ > >> + _flags) \ > >> + struct ccu_mux _struct =3D { \ > >> + .enable =3D _gate, \ > >> + .mux =3D _SUNXI_CCU_MUX_TABLE(_shift, _width, _table), \ > >> + .common =3D { \ > >> + .reg =3D _reg, \ > >> + .hw.init =3D CLK_HW_INIT_PARENTS(_name, \ > >> + _parents, \ > >> + &ccu_mux_closest_ops, \ > >> + _flags), \ > >> + .features =3D CCU_FEATURE_CLOSEST_RATE, \ > >> + } \ > >> + } > >> + > > > > I'm fine with that one, but like we discussed on the NM (I think?) patch > > already, this creates some clocks and macros that will use the feature > > as a flag, and some will encode it into their name. > > > > Given that we need it here too, I'm really inclined to prefer what you > > did there, and thus create a new macro for pll-video0 instead of > > modifying the existing one. >=20 > Ok. Just to be clear: What I did in this patch is fine and I should use > the same approach for NM. Did I get that right? Yes. Leave the NM macro as it is, and add a new _CLOSEST variant that sets the flag like you did there. Maxime --t2tjec4yx3o7pbhi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZKKy6wAKCRDj7w1vZxhR xWHzAQCHI7e5XU7oDIjGLZEeYpCvt6wruqXLan5kivXIWISfJQD/TKym+WzEOy/4 twHIRYOF8Gp3SNjZedHn9SBu4f7FMwA= =zM0z -----END PGP SIGNATURE----- --t2tjec4yx3o7pbhi--