From patchwork Thu Sep 2 10:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 505734 Delivered-To: patches@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1078675jai; Thu, 2 Sep 2021 03:16:42 -0700 (PDT) X-Received: by 2002:a2e:1556:: with SMTP id 22mr1827746ljv.253.1630577802559; Thu, 02 Sep 2021 03:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630577802; cv=none; d=google.com; s=arc-20160816; b=OViHwSl1f/AJP1jhXB5rGH37JBpxZte9sXYM9C7r1aAUFhH/YzVU80nkJmnuv4Wzi9 X15Xy8HF7iW8qDGxQOOuvhyOR+clMcLNiRkff+yxgm35D1Y2nupRhCU5WZL+Qd0c/8Yu ZNwk6FPfjMZG0a/ohgrn9sTThLXlPBM30RY+olxk3PsejlPIRmOYrzfchiAc3NJtrS0F GYAhjG35+OdsK5kVWhQ12VHpGGcsnTH1eyL54Ps6TfDmhLoJk8nif89NHo+Arx9tjC8v XyBV6r9aBgOmbFQdp54PHj1nWGyhuL6ZqY3E8Gd7oxfqo2klt5H7AB5QGVv/2I0D+3Jj arEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Q8gHKZlIfNMsE2pwpZyxC6yykTeyy3ncWsPcdI97ZBw=; b=IrPzP+IwRZHi0p4d1HOXL+OZ6qXm1putrlr2MH6OvpO+FYHh3kfbCDdrbVN5rdBLty 5oy7lsPWyMWZ3hMAEccUhMUIDkcFOX/H/LfR6mIza07ufpmLT1ryv8zwFCs/HVijz120 tUtssSVZG5XCveN8qb8WtreFZTnwk2gtwZGcK7gWcu4PNc1jvYAXo9Fur7ewHecES+cQ XKGi8P/zDnKuA+YYKjKoRfwp/aUBY49Sg4vk5Bf3iRWB8PJMuRUvwAU1x8F8Ru63rsbR nTICkOXkfEao3z62aWSl8aYzaymW9kewMQqEEwPb4MTJDe62X4ctCwdblptFKlyL+kt9 gAeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oz8M17UZ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id e14sor739999lji.12.2021.09.02.03.16.42 for (Google Transport Security); Thu, 02 Sep 2021 03:16:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Oz8M17UZ; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=oKmmTqSfCSfdZy1yC5/Z9KcfcNYwHoG+Umnd9FmD7ZD5439lIAjA8eKRPN9iOjrE7a 1d2V019smaMjfsyu+hpAC/iE6VR8XdTqnPgMWJdLpBIs58ajerjfseq04D71RFNiZwe8 GcL8Th/4NHa+21RLb5Qvf8P8bhulk7EvPAkc2uzWIREiKvNv+CkX7eo9WkTHc1H4abJ2 52KqzwSKQA5UkewKIShIVJ8qM4SWq/autbaDQisy1oHd3jT9iqOP3HBRQmbXwbYkAHAX ESfjmL0f1LRIQZCgXKbR89Q7Wkh5CfgsOj6vRsrxyu+MmKGJijibi99HEtyoI0VtFI6I myKw== X-Gm-Message-State: AOAM532asFzyEXtG8SZGfRTZeKoD8qKhncGFNaP+4FmFiMzMs0qgu1yu w4PzBxgXbDPJ08iZ8oaD6ACPcqV3 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) Return-Path: 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 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(-) -- 2.25.1 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;