Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2482525rwd; Wed, 14 Jun 2023 03:34:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6NS2L2EKIRoygTn0pUuZqFUMlOTXSAM9CB9MqnR3+eS5uzG/Q4BnHPVDqxABHvXNselUYg X-Received: by 2002:a05:6a00:1787:b0:64f:52c9:ddd5 with SMTP id s7-20020a056a00178700b0064f52c9ddd5mr2115998pfg.34.1686738877210; Wed, 14 Jun 2023 03:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686738877; cv=none; d=google.com; s=arc-20160816; b=a4YtKQU+e365gqGoApsDi0jtYy7bmOwLIBK2gNnhIvIeO2ftSCaZ8eeriKweVAlEd2 ZcteeNbaGVS4G22YuhTRWLCXZ8esFIsZm/LiNTmDU/HoCiKwROv2uImy2ykgKWRQKknB tHhT/Du4Mbvifyzr+ch2un7iGMR+M+a+T8MMUVJHqb2jbEBk7BXMnYU3cOwcN1ZTQI0m OK4h7mx6hhkiu2rMyYtoveuHx1SmRRnTmei55RoSF+qMQ9R1OSV0OoPqUTg5evYZfLwu TCrwT4YF8cLctFDgSO273g8Q48Xrp/nR/UfTwobhta/uLWfJeU6AP4mLZyjrW0ho8JVb Fnbg== 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=ZCOUyt2yTF9x4FgWIQpwXhgoxss/OYhX4Xfp8kmzJBc=; b=C84rAYvEZrZPe2Z4fetCOoQ6ud7/f3jEmMNnrn4cB33q5XJ2T968xUQfxIudrAOk3V s43uB8sYSrrKM/f9wcLsGXCmXui/rBoBQvYteWyZCzx/9HwZL/RJlzN4ATSVHlOBkzeP gmxkkFD3PdZ7AbW8Nnfs6cK1TNId8n/TST76bcUuNrOWXBqxPwHRlg+PCBD753T6+GA6 K+LLyeq3+/pk5bZC4HQQYoDfhBWn3QSMI7bmZox/MSk4Q8n+nqLkbs2c3xsoZOFBmiE0 boui8dzZU6HquBbJJkoocNR9t4hkwnev3qSXM8Qj3pdbq8r7Fkth0/C8XdzpME65SZkQ 45pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=guYsAd3f; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LpNwAyqz; 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 m11-20020a056a00080b00b0064f3c650248si11434932pfk.91.2023.06.14.03.34.25; Wed, 14 Jun 2023 03:34:37 -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=guYsAd3f; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=LpNwAyqz; 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 S235925AbjFNKbK (ORCPT + 99 others); Wed, 14 Jun 2023 06:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244377AbjFNKaQ (ORCPT ); Wed, 14 Jun 2023 06:30:16 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2352D75; Wed, 14 Jun 2023 03:28:58 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A40AF32009F0; Wed, 14 Jun 2023 06:28:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 14 Jun 2023 06:28:19 -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=1686738498; x=1686824898; bh=ZC OUyt2yTF9x4FgWIQpwXhgoxss/OYhX4Xfp8kmzJBc=; b=guYsAd3fpIJyaf1wnX OMgz2zWhoMC1pTGt07uVpJGxan5ur6GEq3JERg0eZtkXrTp3CUVQ47DilYqKYg6o MyJbK44rzVOU2808LKQEgWv+m3HRY/pYzp2rAZSGUZxNl8YJMKbFZCkYlPB8B92W VI/jxcT6g+Ro0V16RQQagdUqjrqdkHdR+XtVrC+C0u81vCNquxDKne1PocuI+Y71 YCOSKqmmwNwkoZFsBxfencfFgWRrQH/x3pIF5xfFSMlZzZO34X7E9Mt4J+YdP40c UuNytT7EbAALC+e/GwfBglfS4Pu86nuWlBuuQsATzNcGTKDSIQohOmuDQIX4AWKF giWA== 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=1686738498; x=1686824898; bh=ZCOUyt2yTF9x4 FgWIQpwXhgoxss/OYhX4Xfp8kmzJBc=; b=LpNwAyqzfXhnOwPbRR76rDm1kvFUY f8mBuUOga6MapZonnBq8bJQYco9En3mr0HGqordQKjDi5+yofxzgp0Z5Rjqkf9Rs ewAWSMyHHvHesHJbiQZR6VIRK1EDzve6PjaINqsY8H2MSvu7kbS1kzwPBP88fdZX NVEONEkBOOjiOUdKejKSlwOXmMM0rk1aXd2YFtNtqCLqQWn8Ursn0LGaYALgWG7z yOVz72R4kHZWngy3NtGNibSOgYi1Qi7s0gPKQFvHu5dGYLQHYD/KOQYCp+z+sp3O v4NNdqqDf7SPNxb3Xay95QFn89kN+htLSucmrjTLd3JkbQppTZNjESgMQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedvtddgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtsfertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeeuveduheeutdekvefgudevjeeufedvvdevhfejgfelgfdtkeevueegteek gfelfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Jun 2023 06:28:17 -0400 (EDT) Date: Wed, 14 Jun 2023 12:28:14 +0200 From: Maxime Ripard To: Stephen Boyd Cc: Michael Turquette , Sebastian Reichel , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Christopher Obbard , David Laight , kernel@collabora.com, stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] clk: composite: Fix handling of high clock rates Message-ID: <6nihw4k2vdtmjpvbei5ahb7cmtmuyi2w5m4pwhjrmdqi2yp7v6@vdpg5kwa7trl> References: <20230526171057.66876-1-sebastian.reichel@collabora.com> <20230526171057.66876-2-sebastian.reichel@collabora.com> <2f3328c4be9db6feef2cc662ede70f92.sboyd@kernel.org> <7s2xdk43a2lhyezgj6bbwxaekbtgym2rin7t432m4pos4j6v74@qaxm3htjak4a> <86d58c6b131028a71964a0bcb135f01f.sboyd@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rvbzj4d27cgjtg4p" Content-Disposition: inline In-Reply-To: <86d58c6b131028a71964a0bcb135f01f.sboyd@kernel.org> 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,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 --rvbzj4d27cgjtg4p Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 13, 2023 at 11:25:12AM -0700, Stephen Boyd wrote: > Quoting Maxime Ripard (2023-06-13 05:14:25) > > On Mon, Jun 12, 2023 at 05:10:35PM -0700, Stephen Boyd wrote: > > > Quoting Sebastian Reichel (2023-05-26 10:10:56) > > > > diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composit= e.c > > > > index edfa94641bbf..66759fe28fad 100644 > > > > --- a/drivers/clk/clk-composite.c > > > > +++ b/drivers/clk/clk-composite.c > > > > @@ -119,7 +119,10 @@ static int clk_composite_determine_rate(struct= clk_hw *hw, > > > > if (ret) > > > > continue; > > > > =20 > > > > - rate_diff =3D abs(req->rate - tmp_req.rate); > > > > + if (req->rate >=3D tmp_req.rate) > > > > + rate_diff =3D req->rate - tmp_req.r= ate; > > > > + else > > > > + rate_diff =3D tmp_req.rate - req->r= ate; > > >=20 > > > This problem is widespread > > >=20 > > > $ git grep abs\(.*- -- drivers/clk/ | wc -l > > > 52 > > >=20 > > > so we may have a bigger problem here. Maybe some sort of coccinelle > > > script or smatch checker can be written to look for abs() usage with = an > > > unsigned long type or a subtraction expression. This may also be worse > > > after converting drivers to clk_hw_forward_rate_request() and > > > clk_hw_init_rate_request() because those set the rate to ULONG_MAX. > > > +Maxime for that as an FYI. > >=20 > > We set max_rate to ULONG_MAX in those functions, and I don't think we > > have a lot of driver that will call clk_round_rate on the max rate, so > > we should be somewhat ok? >=20 > Good point. I haven't looked to see if any drivers are using the > max_rate directly. Hopefully they aren't. I had a quick grep for 'req->max_rate' under drivers/clk and there's no driver using abs on that field. Maxime --rvbzj4d27cgjtg4p Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZImWPgAKCRDj7w1vZxhR xWqqAQDtRJu+7X2t9w8kMiWSgFzQ9bh/myP2kVaGllLA7Ryp4gEA8nCo9oZhnPp0 paQV2Ot+629yys6nYCty3z7AzXB2Jw4= =Dq2e -----END PGP SIGNATURE----- --rvbzj4d27cgjtg4p--