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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3136C4332F for ; Wed, 27 Oct 2021 15:06:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1A27610C7 for ; Wed, 27 Oct 2021 15:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237833AbhJ0PJX (ORCPT ); Wed, 27 Oct 2021 11:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242657AbhJ0PJX (ORCPT ); Wed, 27 Oct 2021 11:09:23 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8A8C061570 for ; Wed, 27 Oct 2021 08:06:57 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 17so2067800ljq.0 for ; Wed, 27 Oct 2021 08:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eEeOc3SRoTkeXEKVHoRlTI3OBL2wUysOvGNTyGSpDRc=; b=vBrX1hroP2zBuvD1iKJmnG7LMigUVOYCCUjI8nNnhrOkTN5QjBm3VWoeIohRkK94mM 0iA0f/MUpH4lU1LpX3SUAg9Qb9ffQA0/D8+lP5Yzp3hO1Oc/dXHRmqswxRuT9K08TkOO JxqtHG9LNOmuEPBOqsrakS8A/PnsDc4pWHFk4nsd1CWrbhV3CP6XgVEYZVsOFiX/FjzB 9hgAWNpXsxKJufJeQdlXOK36M6tMtnDPGse1nNhXhUmjKb5V5lpoDBCxHytpfbgd1la/ VwvSyqBmg75weHCA9Vnyf+aKIJjXvgL/syNjDNOWymJZFrIy8+prLwST1MBBhfHGFO6k aaQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eEeOc3SRoTkeXEKVHoRlTI3OBL2wUysOvGNTyGSpDRc=; b=HMleKtt9FZZcUn2G53MeZo4PXCXFe7HgCFiQPydZgZeUKZwCR3Xu5W1x88lmvOKtIY 6rAn0kbeoiPPwzoYSSiCM7LyWdQOcI6K19GUgFwTyuAbAxjE22cj3VBVqI0uDHJG0QUg Jq4P7P2JA4Crx7aGqBYGhfHy45PDJE5rRXO7cBPEruzlxkkI23bu1KfanVRrjmeh8ZRh bTLEua14TXmaAOafvAUD0evMtlktFs6/X49U2nH+fDP3269D+MrcVNowgdNFnOxCuPEI n/8lOIL9Ym7afOcXRucZm5TY/EznStjKIfgTOXIqXsBv6dmePStQHMmr37Yw2DqFUAOy 5+eA== X-Gm-Message-State: AOAM532ppD+x5l4ikz3OHu3jU47XOEhAYtRsUCRV6RPXCRqHKxf1Lcp5 cVkTxU5KxKktN1A9YJQ6ZzbeoU3krObfra62wQrV9Q== X-Google-Smtp-Source: ABdhPJysjKT4Qj/n7/ftR0oVtnZjTh7iTetwxvNQGH0ktAIGHoCGiRAbJE5llFkaZZ7c+ePHtcATzAPymmbQqNT848A= X-Received: by 2002:a05:651c:11c4:: with SMTP id z4mr33240531ljo.463.1635347215604; Wed, 27 Oct 2021 08:06:55 -0700 (PDT) MIME-Version: 1.0 References: <20211025224032.21012-1-digetx@gmail.com> <20211025224032.21012-2-digetx@gmail.com> In-Reply-To: <20211025224032.21012-2-digetx@gmail.com> From: Ulf Hansson Date: Wed, 27 Oct 2021 17:06:19 +0200 Message-ID: Subject: Re: [PATCH v14 01/39] soc/tegra: Enable runtime PM during OPP state-syncing To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Viresh Kumar , Stephen Boyd , Peter De Schrijver , Mikko Perttunen , Lee Jones , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Nishanth Menon , Adrian Hunter , Michael Turquette , linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, linux-pwm@vger.kernel.org, linux-mmc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-clk@vger.kernel.org, David Heidelberg Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On Tue, 26 Oct 2021 at 00:45, Dmitry Osipenko wrote: > > GENPD core now can set up domain's performance state properly while device > is RPM-suspended. Runtime PM of a device must be enabled during setup > because GENPD checks whether device is suspended and check doesn't work > while RPM is disabled. Instead of replicating the boilerplate RPM-enable > code around OPP helper for each driver, let's make OPP helper to take care > of enabling it. > > Signed-off-by: Dmitry Osipenko Just a minor nitpick, see below. Nevertheless feel free to add: Reviewed-by: Ulf Hansson Kind regards Uffe > --- > drivers/soc/tegra/common.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c > index cd33e99249c3..d930a2b4facc 100644 > --- a/drivers/soc/tegra/common.c > +++ b/drivers/soc/tegra/common.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -43,6 +44,7 @@ static int tegra_core_dev_init_opp_state(struct device *dev) > { > unsigned long rate; > struct clk *clk; > + bool rpm_enabled; > int err; > > clk = devm_clk_get(dev, NULL); > @@ -57,8 +59,22 @@ static int tegra_core_dev_init_opp_state(struct device *dev) > return -EINVAL; > } > > + /* > + * Runtime PM of the device must be enabled in order to set up > + * GENPD's performance properly because GENPD core checks whether > + * device is suspended and this check doesn't work while RPM is > + * disabled. > + */ > + rpm_enabled = pm_runtime_enabled(dev); > + if (!rpm_enabled) > + pm_runtime_enable(dev); This makes sure the OPP vote below gets cached in genpd for the device. Instead, the vote is done the next time the device gets runtime resumed. I don't have an issue doing it like this, but at the same time it does remove some flexibility for the drivers/subsystem that calls tegra_core_dev_init_opp_state(). Isn't it better to leave this to be flexible - or you prefer to have it done like this for everybody? > + > /* first dummy rate-setting initializes voltage vote */ > err = dev_pm_opp_set_rate(dev, rate); > + > + if (!rpm_enabled) > + pm_runtime_disable(dev); > + > if (err) { > dev_err(dev, "failed to initialize OPP clock: %d\n", err); > return err; Kind regards Uffe