From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 035CEC4338F for ; Mon, 23 Aug 2021 20:24:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4DB760C51 for ; Mon, 23 Aug 2021 20:24:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B4DB760C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B697289B65; Mon, 23 Aug 2021 20:24:06 +0000 (UTC) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D1A589B65 for ; Mon, 23 Aug 2021 20:24:06 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id j12so19221866ljg.10 for ; Mon, 23 Aug 2021 13:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=J41x529VlTspZMrpThFHJLBr2g65jbs1WO5P40LCen4=; b=okYdM6r/OEM+GpVMmndUDSUnFuATe7k+UqV9Xd6SnEB6FCQnedxeMEPVsABonqs4N4 bW0CUVBYgP/wVgNhvKRjjJZHkQWqjAfdAXHaWOprlSkmDVUGTjWH0QHqHe/JDzPhBYMW VS78dI9TbqWyfxbPdEd9M68PCp/85z5U4mMqUTiCNVQcQnpHeloJ5A8DDCAgG+UndNk2 4AMRro0QimKicKoXkXK7fx6Xlty7DPO0Rz/T7e7AYrMNjr1lsW8oLXtit6l5wdRItw9Y 0sCrelfgm2KgdesCrJhygLOJ6k4XDHAPdBtXpSk4O9XXGH416S+WsJAn5UMZlTogyo6e LVmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=J41x529VlTspZMrpThFHJLBr2g65jbs1WO5P40LCen4=; b=J3lMgA1DCww+GD5D3H0wMrDzy2GATdgr7zoI4ydCOlZ76eQVUME7hD8zfmDWToYCII sCqpGggU1VKdRdJvsKnasE4F0Lr9RnkT1itByJjrh8NccyW2PRLCgKqMqziUGjj37DfZ r0WQAxfYA9pU4Y40z6ENFElEc0pwJAVg26KGvplaowXyLgh9lcfe2f5uPiX06+92lxep c6EUrH/R19w58dkzZCv4PL+xZ6K7L+k+1XtvzU3COWNmGAC0Tg0SrokqiPskl/O/oR2E ujq2YEFDpRRqN/pTslmLA1WRXAH6AlI30LD1e/YB4qfpwpThmrStsSmgFYyKysKSJHUk DxZA== X-Gm-Message-State: AOAM531f5R4w1C1SF4+tM8Q/0BWd7DU2e8jkxZqgNXKXz8QHWsV1bovS DOQ5dPNfi6+B3QIpHnKHGFA= X-Google-Smtp-Source: ABdhPJwqnW4H12JkFByYZki5F25wX7CFl/4OxdrLQBKSJLK7Hp+HrjfGNLOpxwFObeZey6c6a7G84A== X-Received: by 2002:a2e:a4db:: with SMTP id p27mr29314648ljm.161.1629750244353; Mon, 23 Aug 2021 13:24:04 -0700 (PDT) Received: from [192.168.2.145] (46-138-120-72.dynamic.spd-mgts.ru. [46.138.120.72]) by smtp.googlemail.com with ESMTPSA id r2sm854722ljj.14.2021.08.23.13.24.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Aug 2021 13:24:03 -0700 (PDT) Subject: Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper To: Ulf Hansson , Viresh Kumar Cc: Thierry Reding , Jonathan Hunter , Viresh Kumar , Stephen Boyd , Peter De Schrijver , Mikko Perttunen , Peter Chen , Mark Brown , Lee Jones , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Nishanth Menon , Vignesh Raghavendra , Richard Weinberger , Miquel Raynal , Lucas Stach , Stefan Agner , Adrian Hunter , Mauro Carvalho Chehab , Rob Herring , Michael Turquette , Linux Kernel Mailing List , linux-tegra , Linux PM , Linux USB List , linux-staging@lists.linux.dev, linux-spi@vger.kernel.org, linux-pwm@vger.kernel.org, linux-mtd@lists.infradead.org, linux-mmc , Linux Media Mailing List , dri-devel , DTML , linux-clk References: <080469b3-612b-3a34-86e5-7037a64de2fe@gmail.com> <20210818055849.ybfajzu75ecpdrbn@vireshk-i7> <20210818062723.dqamssfkf7lf7cf7@vireshk-i7> <20210818091417.dvlnsxlgybdsn76x@vireshk-i7> <20210819061617.r4kuqxafjstrv3kt@vireshk-i7> <20210820051843.5mueqpnjbqt3zdzc@vireshk-i7> From: Dmitry Osipenko Message-ID: <085d1a2e-57b0-222e-c569-12f3c6bc8161@gmail.com> Date: Mon, 23 Aug 2021 23:24:02 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 20.08.2021 15:57, Ulf Hansson пишет: ... >> We already have similar APIs, so that won't be a problem. We also have >> a mechanism inside the OPP core, frequency based, which is used to >> guess the current OPP. Maybe we can enhance and use that directly >> here. > > After reading the last reply from Dmitry, I am starting to think that > the problem he is facing can be described and solved in a much easier > way. > > If I am correct, it looks like we don't need to add APIs to get OPPs > for a clock rate or set initial performance state values according to > the HW in genpd. > > See my other response to Dmitry, let's see where that leads us. I'm going to start preparing v9 with GENPD performance state syncing moved into driver's probe where appropriate. It's not clear to me whether it will be okay to add a generic OPP syncing by clock rate or should it be a Tegra-specific helper. Viresh, what do you think about this generic OPP helper: /** * dev_pm_opp_sync_with_clk_rate() - Sync OPP state with clock rate * @dev: device for which we do this operation * * Sync OPP table state with the current clock rate of device. * * Return: 0 on success or a negative error value. */ int dev_pm_opp_sync_with_clk_rate(struct device *dev) { struct opp_table *opp_table; int ret = 0; /* Device may not have OPP table */ opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) return 0; /* Device may not use clock */ if (IS_ERR(opp_table->clk)) goto put_table; /* Device may have empty OPP table */ if (!_get_opp_count(opp_table)) goto put_table; ret = dev_pm_opp_set_rate(dev, clk_get_rate(opp_table->clk)); put_table: /* Drop reference taken by _find_opp_table() */ dev_pm_opp_put_opp_table(opp_table); return ret; } EXPORT_SYMBOL_GPL(dev_pm_opp_sync_with_clk_rate);