Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp968660rwi; Wed, 26 Oct 2022 09:13:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HDwPCzEvRRlwm6wVZpG3osLI3JmHNiNlGkusbSiqFSU+IcmsHRYZfkmY4Dy+RAfDcgTm4 X-Received: by 2002:a17:907:da7:b0:791:8f57:6860 with SMTP id go39-20020a1709070da700b007918f576860mr39067217ejc.509.1666800785429; Wed, 26 Oct 2022 09:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666800785; cv=none; d=google.com; s=arc-20160816; b=z1OiANHqadqhPCwRV4+HWsByHV795nHrsx0f4aplk8eKUIyUPcnxIR9Ac7jUp7r+64 NBY0F48U9U0g7IxErtit1l/1nFLpYqhAx8opfwcax6+JkIb643+jexS+fXnZprMmfye0 hCAx2VhZ6ZDrigzglSWI+hEIvxYb4SP4i7FxZBVUlaq/4bkBKHGGGDuSRj4wtZKmlwlK B2N7E3BfdpTzE3eVSzqKkdqk6pHfCTTiO6yyq8nxi4T7u5ffVMRVk/P3bhwrtKOZHJCl /KXn7EC9aMcx3xLxBtDY3GYK6qWfDzpx0ne8Tgw81iixHfQ34YlSkQbl7FCSSTBIsp1x 3Hkw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:feedback-id:dkim-signature:dkim-signature; bh=SU+Ad1TB02X4bG+6rU4go6fxe2AOrcCnpEjbJ7vBIl4=; b=yOvGb7zvQXoHoEjaxQ7BQEQFU19TsDehVOnRvVI+d8VAgHBiAU1S41vKyie+ocIdcn rMVTtZY3DxgMXnDhRzvXozzJJn5ueBjZq9OEVaQObXHyiUlxk2tH0FqqxlX9S+bCLFMQ BCeEaPppJDII5wRdxD//tokIzGkXMs+xbHLC5K5InGQlR7oe41T9n0EAIujg1tOOdadg SUYUBzVR107zcdIufJsFSrdk5sX4E8Bl/js7WsVUpnWW9LrgORdd6p7LJl/4aNXTyBe+ 1vcxcNuJwJzDnl1nensTwWJ2qXys2gKrZmU2db5QuDVCtf4yrA5fWrGn+sQsoy3qXouO B9Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=vHMmuduI; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OdyM38Vd; 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 du21-20020a17090772d500b0078dcddc1b8csi6737462ejc.788.2022.10.26.09.12.18; Wed, 26 Oct 2022 09:13:05 -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=fm3 header.b=vHMmuduI; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OdyM38Vd; 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 S234665AbiJZQK4 (ORCPT + 99 others); Wed, 26 Oct 2022 12:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbiJZQKy (ORCPT ); Wed, 26 Oct 2022 12:10:54 -0400 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0F67E6B; Wed, 26 Oct 2022 09:10:52 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 49416580171; Wed, 26 Oct 2022 12:10:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 26 Oct 2022 12:10:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding: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=fm3; t=1666800652; x= 1666807852; bh=SU+Ad1TB02X4bG+6rU4go6fxe2AOrcCnpEjbJ7vBIl4=; b=v HMmuduII+52zoJL58dXTsski1Sb9SHoH0YIX5V7C5e9wJWAIuv9pqKwe7fdgDn9F OsuXtsXflGGOx1yN7cARkoy3H90OeFupSPKJMOu5sVRMO2EpZ9XXxxhesPaSAZp/ hvilY8j9DYap4s8nfD2KO8vXJkjZKK5h0lWNZPdT6KCXQaQN/WcdVSZBAl/Qq1Xr iMxo8gpiuyndMIRRRvXfP1Sxe6NTUvpspg19puqMsO6M5IO4brBDuwypn/+vmmCF 6i3bD/ffk1qA10SbNAaMBqZvmdJlH1mpnxKPKjejzvXDJLVBzu72oCLlgONCYigc pK2Zm/wH9RFV9fiFhfVhw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm3; t=1666800652; x= 1666807852; bh=SU+Ad1TB02X4bG+6rU4go6fxe2AOrcCnpEjbJ7vBIl4=; b=O dyM38VdrcZz1OsekiaWmYVLhadIFPmGInB5UwGG+8sNBE6t64NEN381s1GMJb36O Idix6UgV/gTq6+q75A/k6s5wpc3+z/WgvzXu8SH6PG6uOObCkxk8u5q6Gljy11N2 rvV1uOghHa9caq7grs6hzm0ZeTBJVwtLkdiNcv94PG8v3xkXJmMxss20w3J8pmdB 91JDdCpfvtYLrc1AA+cDpPXITKnR3ld40cKd+9wvHdmhlP8oVovi7UleQqA4ons+ Qq43S/NDBoxEf+/N9QiB2ISWycntcKfOuxbxJC7V9cIOLy2ROeN6SLbrurTSYoIz 94QBGXekrMy4otn2H5V0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtddvgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffvvefukfhfgggtugfgjgesthhqredttddtvdenucfhrhhomhepmhgrgihi mhgvsegtvghrnhhordhtvggthhenucggtffrrghtthgvrhhnpedvtefggeffuefhkedufe ffgffhgfehheetheeghfffkeduhfegffeukeelvdejgfenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtg hh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 26 Oct 2022 12:10:51 -0400 (EDT) From: maxime@cerno.tech Date: Wed, 26 Oct 2022 18:10:48 +0200 To: Dave Stevenson Cc: Daniel Vetter , Emma Anholt , Michael Turquette , Stephen Boyd , Ray Jui , Florian Fainelli , David Airlie , Broadcom internal kernel review list , Scott Branden , Stefan Wahren , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dom Cobley , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org Subject: Re: [PATCH v4 4/7] drm/vc4: hdmi: Fix hdmi_enable_4kp60 detection Message-ID: <20221026161048.qsiurbhlova4ndud@houat> References: <20220815-rpi-fix-4k-60-v4-0-a1b40526df3e@cerno.tech> <20220815-rpi-fix-4k-60-v4-4-a1b40526df3e@cerno.tech> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: 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,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 Hi Dave, Thanks for your review On Wed, Oct 26, 2022 at 04:36:04PM +0100, Dave Stevenson wrote: > On Wed, 26 Oct 2022 at 16:27, Dave Stevenson > wrote: > > > > On Thu, 20 Oct 2022 at 10:14, wrote: > > > > > > In order to support higher HDMI frequencies, users have to set the > > > hdmi_enable_4kp60 parameter in their config.txt file. > > > > > > We were detecting this so far by calling clk_round_rate() on the core > > > clock with the frequency we're supposed to run at when one of those > > > modes is enabled. Whether or not the parameter was enabled could then= be > > > inferred by the returned rate since the maximum clock rate reported by > > > the firmware was one of the side effect of setting that parameter. > > > > > > However, the recent clock rework we did changed what clk_round_rate() > > > was returning to always return the minimum allowed, and thus this test > > > wasn't reliable anymore. > > > > > > Let's use the new clk_get_max_rate() function to reliably determine t= he > > > maximum rate allowed on that clock and fix the 4k@60Hz output. > > > > > > Fixes: e9d6cea2af1c ("clk: bcm: rpi: Run some clocks at the minimum r= ate allowed") > > > Signed-off-by: Maxime Ripard > > > > Reviewed-by: Dave Stevenson > > > > > --- > > > drivers/gpu/drm/vc4/vc4_hdmi.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4= _hdmi.c > > > index 64f9feabf43e..87961d4de5aa 100644 > > > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > > > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > > > @@ -46,6 +46,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -3429,7 +3430,7 @@ static int vc4_hdmi_bind(struct device *dev, st= ruct device *master, void *data) > > > > > > if (variant->max_pixel_clock =3D=3D 600000000) { > > > struct vc4_dev *vc4 =3D to_vc4_dev(drm); > > > - long max_rate =3D clk_round_rate(vc4->hvs->core_clk, = 550000000); > > > + unsigned long max_rate =3D rpi_firmware_clk_get_max_r= ate(vc4->hvs->core_clk); >=20 > Actually minor nit: > rpi_firmware_clk_get_max_rate returns an unsigned int. > AFAICT we don't need the range of unsigned long in any subsequent > code, so I think it could just be unsigned int here. >=20 > clk_round_rate returned a long, and therefore previously it did have to b= e that. Yeah, I was actually two-minded about this. rpi_firmware_clk_get_max_rate() indeed returns an unsigned long, because that's what the firmware returns. But the clock framework uses unsigned long to store all its frequencies, and in our case here in clk_set_min_rate(). I don't mind changing it to unsigned int here if you prefer to, and if you're fine with the rest of the patches I can fix it up while applying the patches. Maxime