From patchwork Thu Jun 3 09:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 453241 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp114869jao; Thu, 3 Jun 2021 02:34:52 -0700 (PDT) X-Received: by 2002:a05:651c:119c:: with SMTP id w28mr28733607ljo.164.1622712892578; Thu, 03 Jun 2021 02:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622712892; cv=none; d=google.com; s=arc-20160816; b=ZPYL9SYMPfMwfy3FoiCyf3DmWnJq86hn80ltoA9BmyTTCFAJr44oZ1fDlN+dsyVHf4 edMUnjKFbdrvqnKbaBpH/w62BGQeGL8Z8PbqsWhL3HFBnMraL4GfHTs4I+BjUvrawS2v s51ZwnQO+ceuFmV24/99OwIPDedlyX17uzVd9U3CTy6vn9rUFIGsiInnvXSHyRMuY9Ta iCecERW+aGNNNY4Lse5hfbamGTHSibj/uIQc7ZEPGz/gwKSZi3LoO4bV6djiKlJk7a76 ie6uyixSprT4a7wnOJB83nTpAaXybgu8E5KxiYdv/SGP7dRfl/tH3qiJ6ufpF8UAUKhZ MCAg== 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=2Eupuj1h7Dw7kPQa+fb7IRdjjpTjghXD/2FhQTKixNA=; b=C+NioJ1hpp/WPBHPRThpC6spemr+f/lrNqEzzX4RXcykCdQWBPz2ilRY223jqfMvVN 38fcAGsWEd4F5ihqtPadrgGJOKSnyY0yv+VIlF4jDNKLdLGgeE/ArAZFgxW6I42fCS6x FnKTBNRmzZTMZYkVh9nFLihuZBvdpyeP/LJzjssGEdHGYoKSliVZbl+WEDhsaMu0ZhiS Eem/YxW5bDIY/GGrzSuWMeOv0IFQbhxavNdYYPHr5U4a6nWSgowT1Vbt8gtDI56erAa1 Nw+3zBaj0z6dEoVSU5UKOfQEoG3DU63XFg0z5DUb1d9wnjv6S/uROAVvtb/huz9z6o0M nIZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hcQbwMN5; 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 v14sor542883lfa.31.2021.06.03.02.34.52 for (Google Transport Security); Thu, 03 Jun 2021 02:34:52 -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=hcQbwMN5; 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=2Eupuj1h7Dw7kPQa+fb7IRdjjpTjghXD/2FhQTKixNA=; b=hcQbwMN5/aI9WJKYvwHHz/GG3QksGXbdsVkkESP4IrK/59OH/YfL+BT1qQEz4yOYJF pM1eUjngP4f4YU9m6RKyRwmxLYNcMSTeVU3SWwPHCt3N0LELKL5kkYTqppQ/kuIS8OwI 5H3DLjClqpVU3XzggiO0evKdjKd3oBVRn93YwIJJ/mDs+kRAts5iD33T4SUrMblAEOgT uNvU1jPYQnA7TYp0Z9lCCo7UYSFkAM2m1yLGB/bkE7qpbae4RwbQ0q59A0KCTjonfvBG /jr0QhgiI2imH57Xmr/4wALgz0lRX0s2e+aAJBcTBg+cm9HerJmp6K+aFYrttViuL7Zm ha1A== 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=2Eupuj1h7Dw7kPQa+fb7IRdjjpTjghXD/2FhQTKixNA=; b=n+fCaI9yAO0Ycx4DHPUln13J5jVfAO79DZ6d/sAbKro+IYCmkRBSOJ7UXQcJNXpTQ9 X45XfcSSdZrrN4Aq1P4ngpCMgXk5if5Swfd62MAmIkrnnp36oo2dbRmMUglI9p357o3p frcbu5RDH9eAEzSv3Zx82WYRC8sAB6+kDfNaX56ZsX9xJI66PfedMr1ZJotzGiBef9Ae zFjrt/p0Jlce2AHpDFBVpl8SpI4y2NGItNML/yZeRBD/eEWcHgyDWNeDkcjwJp2Rsb6W WoXuxYfAMP52hpvxhKT9o39nozbvn1ltRGVcui4ewSUdRR6I9UxlKBJ+x+0RlzvniBqp 7JpQ== X-Gm-Message-State: AOAM533SlTRjRoPKVRrFC5SBWdH28pMiOxqM3N45FUhXGc6G9rhoKdNV wtj/hDAykScEyituXgf/PoMVuqFR X-Google-Smtp-Source: ABdhPJzfFepIAELPykTVo92DbsNR/ePHrcAl9pHysFlUDtDOoxKp4oHrS5nShW8i+ND8w/C6Am15zw== X-Received: by 2002:a05:6512:696:: with SMTP id t22mr26277864lfe.581.1622712892227; Thu, 03 Jun 2021 02:34:52 -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 q4sm263373lfc.172.2021.06.03.02.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 02:34:51 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , Dmitry Osipenko , Jonathan Hunter , Thierry Reding , Rajendra Nayak , Stephan Gerhold , Roja Rani Yarubandi , Bjorn Andersson , Vincent Guittot , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] PM: domains: Drop/restore performance state votes for devices at system PM Date: Thu, 3 Jun 2021 11:34:38 +0200 Message-Id: <20210603093438.138705-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210603093438.138705-1-ulf.hansson@linaro.org> References: <20210603093438.138705-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Recent changes in genpd drops and restore performance state votes for devices during runtime PM. For the similar reasons, but to avoid the same kind of boilerplate code in device PM callbacks for system sleep in subsystems/drivers, let's drop and restore performance states votes in genpd for the attached devices during system sleep. Signed-off-by: Ulf Hansson --- Changes in v2: - Rebased. - A few cosmetic changes. --- drivers/base/power/domain.c | 9 +++++++++ include/linux/pm_domain.h | 1 + 2 files changed, 10 insertions(+) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e5d97174c254..a33e5b341f3f 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1171,6 +1171,7 @@ static int genpd_prepare(struct device *dev) */ static int genpd_finish_suspend(struct device *dev, bool poweroff) { + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); struct generic_pm_domain *genpd; int ret = 0; @@ -1201,6 +1202,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) } genpd_lock(genpd); + gpd_data->pm_pstate = genpd_drop_performance_state(dev); genpd->suspended_count++; genpd_sync_power_off(genpd, true, 0); genpd_unlock(genpd); @@ -1245,6 +1247,7 @@ static int genpd_resume_noirq(struct device *dev) genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0); genpd->suspended_count--; + genpd_restore_performance_state(dev, dev_gpd_data(dev)->pm_pstate); genpd_unlock(genpd); if (genpd->dev_ops.stop && genpd->dev_ops.start && @@ -1364,6 +1367,7 @@ static int genpd_restore_noirq(struct device *dev) } genpd_sync_power_on(genpd, true, 0); + genpd_restore_performance_state(dev, dev_gpd_data(dev)->pm_pstate); genpd_unlock(genpd); if (genpd->dev_ops.stop && genpd->dev_ops.start && @@ -1409,23 +1413,28 @@ static void genpd_complete(struct device *dev) static void genpd_switch_state(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; + struct generic_pm_domain_data *gpd_data; bool use_lock; genpd = dev_to_genpd_safe(dev); if (!genpd) return; + gpd_data = dev_gpd_data(dev); + use_lock = genpd_is_irq_safe(genpd); if (use_lock) genpd_lock(genpd); if (suspend) { + gpd_data->pm_pstate = genpd_drop_performance_state(dev); genpd->suspended_count++; genpd_sync_power_off(genpd, use_lock, 0); } else { genpd_sync_power_on(genpd, use_lock, 0); genpd->suspended_count--; + genpd_restore_performance_state(dev, gpd_data->pm_pstate); } if (use_lock) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 21a0577305ef..f6e9dc28621c 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -199,6 +199,7 @@ struct generic_pm_domain_data { int cpu; unsigned int performance_state; unsigned int rpm_pstate; + unsigned int pm_pstate; ktime_t next_wakeup; void *data; };