From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4100D3FC0 for ; Mon, 23 Aug 2021 20:24:06 +0000 (UTC) Received: by mail-lj1-f176.google.com with SMTP id h1so5405487ljl.9 for ; Mon, 23 Aug 2021 13:24:06 -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=fk33QesvZbYPCzaR+nRM0QL4/TyvR46p73egdY/W45RMq92pu4wZDnboprk3CxGwEY wvk7SpZRYgJL6q8OhwGdeoJ0kAFf5Z/t/daWkBann/KijlbAFbcU2zOpEjs4u8GB06NL 8VhT/maMQEFcfsDQRY6KKO0GftTP10hEAYUJrcg9TK9ZzKSnOeBRxwUD8xNE3daI4tNq 2/UIALgkMgB2PSqCGlufeRL1spRno+2/2MaLrev4q0Uy2LAST05KkHRenOihNEbEC49j OsCHnavjC1sZ/0Q0Tgi21CjSa6LZgH+BDKmcJJ3BOpj0iPAPRjSdTdHxhTG3VdM7ULgD 7fIA== X-Gm-Message-State: AOAM533gr1pXDmHleR/JYIZie0/UJccbsAKarn3QV7DoBF2oTTC/irRx uYYxeiIb1vxVijnVwhIYEJw= 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 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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);