Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3713685rwb; Tue, 20 Sep 2022 03:46:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7N7MoECXP6Bsn818aaYBpqz3+615BYMtzB12W3sQD6pTp89CJMCHHjY33dYyE1SuE5oe+e X-Received: by 2002:a17:907:7633:b0:781:96f0:1bfa with SMTP id jy19-20020a170907763300b0078196f01bfamr3950051ejc.321.1663670761144; Tue, 20 Sep 2022 03:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663670761; cv=none; d=google.com; s=arc-20160816; b=fRweCwDg4MKexXAaUjsnYgS2AhnNKvCVvGrEBAB9qAe0t9ksRc5S5he/qhpRoGuuJ6 P6zq/PxOoGwQCqfDpQGFJRR3pC6wGpXc6zxPLKsa/6gqEpCO9HSl9ukRv4Zs4WYNJVeC W4MhYHUMCpdLqbI26sIUoKmEjCoS4QKxkQfasH1BCRwWmF3h+07OhHh1s0uytQhgShgI bGy5GLCws7Tzqv3q0keAZPvVIXraumpZ4sceHrwaZrAMu0OUQVHkHJvXGJhkG4mE7Fhf tBOeVa3Sioh1Cec+oZouxOQ/DpXYdrsmMfl4aaV9zeG1+9B5+MhwTr1OxA/rkttjDQhy 0RFQ== 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=VvdWG94KRMgznlW2RgcVe0QCkg1EPZIhqOU3XFa6nvY=; b=aAxX1ZFIdX5UfQax6krvLGkBwEfR7hk0z7V8ZIw97w2bb7fvnXqzUlWIgw0EWDPQIr buIHqfWj14xCEB6c/xu+3K8lYHKEbGfqavGqR4vvuTjDf2O+dD15BK09UBM5cLS4jRNi LbCAyeQ2cziDVjcZzAFPWJ2ELD111PtLUPDj9YuzEotYN5CS4eMyccxa7GzxB6vktFl8 qaq1gvlwnPa0xAfyvE8TQRjqvM3T3zlKoGtYD37/RNpYgqKv5Yh0HYSGbGUJ0utj/ww0 qPRetR+u3yim5MM0lK/gpe7VOKPtUgEEa7we9OfzY0GGPfsMarnOCtpnpZN4QgeCPIOc YtpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j8nABKC8; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs13-20020a0564020c4d00b00451abbd33ccsi1298335edb.320.2022.09.20.03.45.35; Tue, 20 Sep 2022 03:46:01 -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=@intel.com header.s=Intel header.b=j8nABKC8; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbiITKjO (ORCPT + 99 others); Tue, 20 Sep 2022 06:39:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbiITKiY (ORCPT ); Tue, 20 Sep 2022 06:38:24 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE9A72EE7; Tue, 20 Sep 2022 03:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663670212; x=1695206212; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ESeT68QBp14fZse7on7nqGxb5SnUIDEmkBvolLY55Fo=; b=j8nABKC8JEeI8yE58udQZGCNWm/32kxyW8vENwYH7V9pu274EsMsPWNS zsZXVfNiWNlaRyNO0WKj5ORHiLULkFmMOVY0z2x9+BTgNJrBTTzjmUOC1 Mm9Ik0lLSUPSy6vKrxo3jh+RVdD+epmXAayl2F9SGzjC8lU5ZTAFd0QeB 7xRXRiPWZblsMIFAgS9Uc/8LXBlLLhLBmvLf2snvharCsMzsQXfCrPPu3 oWTS5+71aNqEmXPCp0/SarJQITFUQW1DPbgEzlFx57McKDhmsNgbs7gMh z3AF0YKWSS46d1OFsSk8JA8j/Dh6/WEK8cz7W8DwYSyuVvrIrIxIZ4ajS Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10475"; a="361398152" X-IronPort-AV: E=Sophos;i="5.93,330,1654585200"; d="scan'208";a="361398152" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2022 03:36:51 -0700 X-IronPort-AV: E=Sophos;i="5.93,330,1654585200"; d="scan'208";a="618865967" Received: from punajuuri.fi.intel.com (HELO paasikivi.fi.intel.com) ([10.237.72.43]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2022 03:36:48 -0700 Received: from paasikivi.fi.intel.com (localhost [127.0.0.1]) by paasikivi.fi.intel.com (Postfix) with SMTP id 3F528200DA; Tue, 20 Sep 2022 13:36:46 +0300 (EEST) Date: Tue, 20 Sep 2022 10:36:46 +0000 From: Sakari Ailus To: Jacopo Mondi Cc: Marco Felsch , Stephen Boyd , linux-clk@vger.kernel.org, mchehab@kernel.org, laurent.pinchart+renesas@ideasonboard.com, akinobu.mita@gmail.com, jacopo+renesas@jmondi.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] media: mt9m111: add V4L2_CID_LINK_FREQ support Message-ID: References: <20220916135713.143890-1-m.felsch@pengutronix.de> <20220919130829.ddoe2ajnrarkywgy@pengutronix.de> <20220920085617.7cfflloegh7en4mj@pengutronix.de> <20220920091933.kokk4le3cxpw4hvp@lati> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220920091933.kokk4le3cxpw4hvp@lati> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 Jacopo, On Tue, Sep 20, 2022 at 11:19:33AM +0200, Jacopo Mondi wrote: > Hello > > On Tue, Sep 20, 2022 at 10:56:17AM +0200, Marco Felsch wrote: > > Hi Sakari, > > > > On 22-09-19, Sakari Ailus wrote: > > > > ... > > > > > > > > + ret = clk_prepare_enable(mt9m111->clk); > > > > > > + if (ret < 0) > > > > > > + return ret; > > > > > > + > > > > > > + extclk_rate = clk_get_rate(mt9m111->clk); > > > > > > + clk_disable_unprepare(mt9m111->clk); > > > > > > > > > > I don't think you'll need to enable a clock to just get its frequency. > > > > > > > > The official API states that you need to turn on the clk before > > > > requesting it and it makes sense. Also there is a new helper > > > > devm_clk_get_enabled() which addresses simple clk usage since most of > > > > drivers don't enable it before requesting the rate. > > Had the same question on v1 and Marco pointed me to the clk_get_rate() > documentation > https://elixir.bootlin.com/linux/v6.0-rc1/source/include/linux/clk.h#L682 > > which indeed specifies > "This is only valid once the clock source has been enabled." > > However none (or very few) of the linux-media i2c drivers actually do > that. I'm not aware of any. That's indeed what the documentation says. Also clk_enable() documentation says that "If the clock can not be enabled/disabled, this should return success". So I wonder how much can you trust it. ;-) > > I have added in cc the clk framework maintainer to see if he can help > shed some light on this Thanks. But yes, to make this work in general case, one would need a way to ensure the frequency is the one assigned in DT and that it won't change. Getting the frequency (in an unreliable way?) isn't perfect but better than nothing. So far I haven't heard of issues in practice though. -- Regards, Sakari Ailus