Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8108962rwn; Wed, 14 Sep 2022 09:04:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5QCR/3ywJb3fumjHxR0Qx4WzuQoGoqhdc8GJU3qhIUmZyfTKuaRrGoOIEo+qGd2jG5yfw7 X-Received: by 2002:a17:907:78d:b0:740:33e1:998 with SMTP id xd13-20020a170907078d00b0074033e10998mr26520542ejb.162.1663171477844; Wed, 14 Sep 2022 09:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663171477; cv=none; d=google.com; s=arc-20160816; b=GNGBjLXhjLICOVQh+Q6jXZ/RPAZnwPu3STISDK5c1GXJkLjuNYMMhF4Vth5aDB5n0/ BVMg4Hgsg8p28WNmB8D1m6s0GszoZQyiykaZ2cWXz1z2Z2WhYDS4DurafqxVvy644Jd5 X3dfoZCddlEyvM6t7h/ZJWqL3+QA8Vz9JHWfvB+o/yTpg8wBK3S/s1SpGEUUNaPP3uDT QCH8yKB6cZUkRJfwcu/tB1xQtKwPSYQeaiDiZRxBqu2c+oI4juKcnGFqjlr7Xspi+xsz +Sf990Yd2QBJrh09XC06JfoJHZdlfBLLXAgHIkG8Gm89W/oItYW14MxgwWF6b3C0Zg15 wQ8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:date:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=y8YG58tcnkoxXCr9HmyqvSjvH6ZAhQd4Kt7SmIfh/G8=; b=LZYs9wrQ0elRI7lAPsr1607dNBa23wy70wNcT7grbiZ/jxoGXac0lPQ6NzHpixHS90 QJXp4AlmdTWseb2kjOplWaeZHre4l8KKe6u49CO5mFf4X37FBENCn/DS6quS0v3+6/pd KlXQbNrSFbh6k0wJP+WHi2bWJPA40jV/fgJ6+K+izwxJ5bSORAQiaCOcItN+7g1EV25w KE425WWL+4NXQJnwC4PfslFIh2WeCByeoGn8rvNQF5JibYVVKYE0S6N6mR9PuWJMqMxs AfL7F9EyoOMiXVpd3hZLRP6pWtzqzgjjk0QKC7RwQa7cHXI4EG2GsmDyaiDlr7EJGx5Y z4SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C1M6MQGr; 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 sd16-20020a1709076e1000b0077082de48b1si298618ejc.894.2022.09.14.09.04.09; Wed, 14 Sep 2022 09:04: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=@kernel.org header.s=k20201202 header.b=C1M6MQGr; 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 S230255AbiINPuo (ORCPT + 99 others); Wed, 14 Sep 2022 11:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230267AbiINPuh (ORCPT ); Wed, 14 Sep 2022 11:50:37 -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 C813B5720F; Wed, 14 Sep 2022 08:50:36 -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 3A44261782; Wed, 14 Sep 2022 15:50:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88E45C433C1; Wed, 14 Sep 2022 15:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663170635; bh=S28EkrNLwS69diRhkX+rhYqUGi8w409B1c6Xk4uXdA4=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=C1M6MQGrR9MJB1trIJC+waXGVZ4KZTTS+JTEOpiEsWCK7+PWOVMNeHPvSp5Zl4s8J hHMEIylwNYQu3JpzME1k3+hI7h8ay3mg8Fyq4l/C+ahofwmf0Rn3jdPCSzhKqsnDrx kysQUItpAD3rBHGQLray2SjAX1d2+eCxXKLh3tDQHNB9cyN3oCMEsDVHIY4mDkxNH6 anaFqGtVu5W6ZNvtaBld6rImlbyjnnJ9hJP5j/LOhvlg2dlMMqaT5gS/zFChRTCGrh 1ShOEbmH3O+HVdVPwSmLqlIKfrr+nNcBJclbNQrjDOz8WoD/FudG4ZvVFX0Tv2SM7J CrNyxNvTJ96EQ== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220815-rpi-fix-4k-60-v1-2-c52bd642f7c6@cerno.tech> References: <20220815-rpi-fix-4k-60-v1-0-c52bd642f7c6@cerno.tech> <20220815-rpi-fix-4k-60-v1-2-c52bd642f7c6@cerno.tech> Subject: Re: [PATCH v1 2/7] clk: bcm: rpi: Add a function to retrieve the maximum From: Stephen Boyd Cc: Maxime Ripard , linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, Dom Cobley , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org To: Broadcom internal kernel review list , Daniel Vetter , David Airlie , Emma Anholt , Florian Fainelli , Maxime Ripard , Maxime Ripard , Michael Turquette , Ray Jui , Scott Branden Date: Wed, 14 Sep 2022 08:50:33 -0700 User-Agent: alot/0.10 Message-Id: <20220914155035.88E45C433C1@smtp.kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Quoting Maxime Ripard (2022-08-15 08:31:24) > @@ -254,6 +255,33 @@ static int raspberrypi_fw_dumb_determine_rate(struct= clk_hw *hw, > return 0; > } > =20 > +unsigned long rpi_firmware_clk_get_max_rate(struct clk *clk) > +{ > + const struct raspberrypi_clk_data *data; > + struct raspberrypi_clk *rpi; > + struct clk_hw *hw; > + u32 max_rate; > + int ret; > + > + if (!clk) > + return 0; > + > + hw =3D __clk_get_hw(clk); Ideally we don't add more users of this API. I should document that :/ It begs the question though, why do we need this API to take a 'struct clk'? Can it simply hardcode the data->id value for the clk you care about and call rpi_firmware_property() directly (or some wrapper of it)? Furthermore, I wonder if even that part needs to be implemented. Why not make a direct call to rpi_firmware_property() and get the max rate? All of that can live in the drm driver. Making it a generic API that takes a 'struct clk' means that it looks like any clk can be passed, when that isn't true. It would be better to restrict it to the one use case so that the scope of the problem doesn't grow. I understand that it duplicates a few lines of code, but that looks like a fair tradeoff vs. exposing an API that can be used for other clks in the future. > + if (!hw) > + return 0; > + > + data =3D clk_hw_to_data(hw); > + rpi =3D data->rpi; > + ret =3D raspberrypi_clock_property(rpi->firmware, data, > + RPI_FIRMWARE_GET_MAX_CLOCK_RATE, > + &max_rate);