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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 2BD87C4320A for ; Thu, 2 Sep 2021 10:16:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15782600AA for ; Thu, 2 Sep 2021 10:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241924AbhIBKRt (ORCPT ); Thu, 2 Sep 2021 06:17:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236589AbhIBKRm (ORCPT ); Thu, 2 Sep 2021 06:17:42 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF1EAC061757 for ; Thu, 2 Sep 2021 03:16:43 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id s3so2526976ljp.11 for ; Thu, 02 Sep 2021 03:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q8gHKZlIfNMsE2pwpZyxC6yykTeyy3ncWsPcdI97ZBw=; b=Oz8M17UZ6Gx8M9KbOtjRmP3bgfiYuuxEHm6LOcO2pUnB9laFx5UVB5VKthK6ntGR0x cgOiXgmpxCBMTPt/U5URfmDm6XbHPMzJPBpI8F9nPcS+UPXKuUjf9oO6SsetA3IbfmGh zjk9F3KXuQ/XWjnP2i6TL9e7xb5KIWe2AoGuVI3F013ag+8+I8dOKA2qxSRwxORsd7WE pju3HKN/TnJi0qfjLLYp9ZNuqr0/mWb+6mbuC8HIyNI4UYHCT0kiYobL4YoyUXJpPTnW 8nFlCLi9dH+VxjezfhukcYdstS5keqcN+GyypIPpk2DtDWWXlg9sYWKqg7huXgJyvhP7 w0Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q8gHKZlIfNMsE2pwpZyxC6yykTeyy3ncWsPcdI97ZBw=; b=Oej1uH3V2771gl/S9dfoBDyj2TuCu3BwluMqsSFKcc8biDTi7cbJBfVw5gudqsgQ1a 5sNV8VSe/D5iAxij6fcz2UAs7+omxOGhBSQWEKehifq4uXgSS/C0TktHIXhKCzSG5zDB VisToKHpFYu30BYJO0yGaoqCpwvs8Q0ouf4oyE3l80+fi06ULKLnPrtDvgxeQMesEAlc FPKP7wHgiSl8yWZOzwuQF1hckRRhhnXX4w/NHgbFAlbZmVTFvqIK+8ZX9ni9a3AdnGOY 6QUxFNZanrqQgARBYbyUfFz3mksM5a3Tm86A25Muw1weHV3RrY8fMmcSgXsDMfDmdbnS 4yIw== X-Gm-Message-State: AOAM531NAyn/Ds3XSokNv7l4XgSSIXlH8P0aEfN+esbTCyWtq7UxwhAy FWaybCggMSwyh9vq9JZaxD8P/w== X-Google-Smtp-Source: ABdhPJzB9h6Twzy69IlKpaCmsSc174yIyH9MuvDLdUFpiBXC0tvx5XVeFz7kIcQaHw3PYf6tMNnYrA== X-Received: by 2002:a2e:5758:: with SMTP id r24mr1849768ljd.432.1630577802207; Thu, 02 Sep 2021 03:16:42 -0700 (PDT) Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id s4sm155897lfd.53.2021.09.02.03.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 03:16:41 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , Dmitry Osipenko , linux-pm@vger.kernel.org Cc: Dmitry Baryshkov , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 3/3] PM: domains: Add a ->dev_get_performance_state() callback to genpd Date: Thu, 2 Sep 2021 12:16:34 +0200 Message-Id: <20210902101634.827187-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210902101634.827187-1-ulf.hansson@linaro.org> References: <20210902101634.827187-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hardware may be preprogrammed to a specific performance state, which may not be zero initially during boot. This may lead to that genpd's current performance state becomes inconsistent with the state of the hardware. To deal with this, the driver for a device that is being attached to its genpd, need to request an initial performance state vote, which is typically done by calling some of the OPP APIs while probing. In some cases this would lead to boilerplate code in the drivers. Let's make it possible to avoid this, by adding a new optional callback to genpd and invoke it per device during the attach process. In this way, the genpd provider driver can inform genpd about the initial performance state that is needed for the device. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 8 +++++--- include/linux/pm_domain.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 800adf831cae..1a6f3538af8d 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2640,13 +2640,15 @@ static void genpd_dev_pm_sync(struct device *dev) genpd_queue_power_off_work(pd); } -static int genpd_get_default_performance_state(struct device *dev, +static int genpd_get_default_performance_state(struct generic_pm_domain *genpd, + struct device *dev, unsigned int index) { int pstate = of_get_required_opp_performance_state(dev->of_node, index); if (pstate == -ENODEV || pstate == -EOPNOTSUPP) - return 0; + pstate = genpd->dev_get_performance_state ? + genpd->dev_get_performance_state(genpd, dev) : 0; return pstate; } @@ -2701,7 +2703,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev, } /* Set the default performance state */ - pstate = genpd_get_default_performance_state(dev, index); + pstate = genpd_get_default_performance_state(pd, dev, index); if (pstate < 0) { ret = pstate; goto err; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 21a0577305ef..da694489a05a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -131,6 +131,8 @@ struct generic_pm_domain { struct opp_table *opp_table; /* OPP table of the genpd */ unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, struct dev_pm_opp *opp); + int (*dev_get_performance_state)(struct generic_pm_domain *genpd, + struct device *dev); int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); struct gpd_dev_ops dev_ops; -- 2.25.1