From patchwork Wed Jun 2 10:12:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 452489 Delivered-To: patches@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp429548jao; Wed, 2 Jun 2021 03:12:34 -0700 (PDT) X-Received: by 2002:a2e:b0f2:: with SMTP id h18mr13847791ljl.244.1622628754634; Wed, 02 Jun 2021 03:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622628754; cv=none; d=google.com; s=arc-20160816; b=Lt2LyciQbGjKcc05Ejyf4kv/YAAoTaY2meY74GmRMs/rHSvmtAIYfR9r6BT+YI9VR+ OZRZ19h2nuT6j+xckHStCIWeI21BrMDJaAZ8Xg53MyWZF2f4WyxS93NLKw/lAba8UCnF 2wtNAn0kDZT+r57dNqSxbvlGej9OdvtqcyVpOiJNErvQvFEXl5WFJ5tpMZ6jBgxfrtpy T/ADQ6bwYc6ROzs3RCKraFrc4IR1lJg2lc16lJoSZI/ML8gf4xn0gzklP3H0CLa3012L ukktq1eVJH2R7mj7AzOJEivufUDBmyWgC8SQ+XisuiNl3Q4/y1CpjQsy1eAZY/pwsInm Hs1g== 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=C0PrEdqIlPYceQIvyi2h1VFOj+MhO3lHQ6Qic3TwKKo=; b=NBjokPe0y0vG6dV3tnSGH9RzWmD+SsSIog76pUQJQz0oVGQj1MvH/1yQYU86wEGuLc yAuwZFPsdI+YDnMDafnz4YSrgBVsWTRTLGblYX0zcQPPjJTtjtKD8Eic1OxmFc2H9bJr vwiQJfRcvhymJ+uVX9ebuZ3Ke/jUN3SGLHZiyY7n7z0NzlrI5yHlJKmcOqIZtYkTC2P/ GwjtKRiMOlcn/465WXx4LoAQk151A39hMUzcgb4sAqZKgU5Zryc1n3Kq8ZjIn2td2JWv lSh81t82Kwzy/T13pP9DvPU/HFIrlvhzQyp56/R80cLEqJrCNjMW3bgs6CzrZCZWq0Xn 2iFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKjLMkzj; 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 d16sor8791910lji.17.2021.06.02.03.12.34 for (Google Transport Security); Wed, 02 Jun 2021 03:12:34 -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=EKjLMkzj; 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=C0PrEdqIlPYceQIvyi2h1VFOj+MhO3lHQ6Qic3TwKKo=; b=EKjLMkzjNM5QGZZKAD4GkhTXZVGHf1OP7Nrl6TRvTAVse+F7+u9GF2TiD674xJhTFH 7L0niNMYpu7RF17IZF0iW0vkyzAAEtdj/RO5oV3gAWO+HjU22L4sXVMcHvjKC14gRiGD jsDabqkAp19sUFwQWKFZgB6LoEGS+PiO13sACnS59dGHV7OK3qIgj6bHu+Jo+RJrX1ri sftgT/pWXlmtVx9QqxPJkJpfJKU1sF3bqLVqXeHSzncWTDBpnpoVZJeGhKuW5/+Hs0gQ 5CJvHdza4iOu+DKpTHLJWSKJ6HpjiyWCdlUKfOpZJ+d8ylSzqu4XfBGUEKa/K03viRaO djKw== 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=C0PrEdqIlPYceQIvyi2h1VFOj+MhO3lHQ6Qic3TwKKo=; b=twEKPNV2DJ7rHy0ymvm4j2f3enZIgburq0NQ+lNu76TrZXvmfYDWtlMBga0uKfCchG BIO5IRjERaxFIupnKo6PlcERsuEwSEk97y6PcCe8/5U3dzwZSS4Wi9IpOIdLbDsJGWjb 7rmvk5ATZ/eldlU326kDFyzqq7npj8HC854elAB/NeVeLM9EspliLBKhY8+4zx42L3Fw QNhtxyi9q4mk8VrzL2VQnLPMktreeGbk1fG2K+rQHPlPBxvuN8oYy46lvQ48lG8OJqCP KhEYGrviL7V0NMndLT4yAGV6Ww4GdpJLbPdfuMtYrs+Uu5bPkfG29pnjr8mQVPZkpvFl fu5A== X-Gm-Message-State: AOAM532nXXsP+olXfgK/RbsjeFFMjSMcMdE+5r3e5jLS9z2AMMCsjuuY yjbPEXv6QYZ0hE98uECz+0LLlkVZ X-Google-Smtp-Source: ABdhPJyvYiEkPGa6Y6AXlYz/GT2pKU67zMM7rOxx5eSGTfjkkvNFuKoqZs0Td+mGvfPkiPvwGnNaUw== X-Received: by 2002:a2e:b0c8:: with SMTP id g8mr6076534ljl.453.1622628754305; Wed, 02 Jun 2021 03:12:34 -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 y35sm1948938lfa.122.2021.06.02.03.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 03:12:33 -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 3/3] PM: domains: Drop/restore performance state votes for devices at system PM Date: Wed, 2 Jun 2021 12:12:15 +0200 Message-Id: <20210602101215.78094-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210602101215.78094-1-ulf.hansson@linaro.org> References: <20210602101215.78094-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 --- drivers/base/power/domain.c | 14 ++++++++++++++ include/linux/pm_domain.h | 1 + 2 files changed, 15 insertions(+) -- 2.25.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 81b9d4652b90..8487f1690deb 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1162,6 +1162,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; @@ -1192,6 +1193,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff) } genpd_lock(genpd); + gpd_data->pm_saved_pstate = genpd_drop_performance_state(dev); genpd->suspended_count++; genpd_sync_power_off(genpd, true, 0); genpd_unlock(genpd); @@ -1221,6 +1223,7 @@ static int genpd_suspend_noirq(struct device *dev) */ static int genpd_resume_noirq(struct device *dev) { + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); struct generic_pm_domain *genpd; int ret; @@ -1236,6 +1239,8 @@ static int genpd_resume_noirq(struct device *dev) genpd_lock(genpd); genpd_sync_power_on(genpd, true, 0); genpd->suspended_count--; + if (gpd_data->pm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->pm_saved_pstate); genpd_unlock(genpd); if (genpd->dev_ops.stop && genpd->dev_ops.start && @@ -1331,6 +1336,7 @@ static int genpd_poweroff_noirq(struct device *dev) */ static int genpd_restore_noirq(struct device *dev) { + struct generic_pm_domain_data *gpd_data = dev_gpd_data(dev); struct generic_pm_domain *genpd; int ret = 0; @@ -1355,6 +1361,8 @@ static int genpd_restore_noirq(struct device *dev) } genpd_sync_power_on(genpd, true, 0); + if (gpd_data->pm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->pm_saved_pstate); genpd_unlock(genpd); if (genpd->dev_ops.stop && genpd->dev_ops.start && @@ -1400,23 +1408,29 @@ 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_saved_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--; + if(gpd_data->pm_saved_pstate) + genpd_set_performance_state(dev, gpd_data->pm_saved_pstate); } if (use_lock) diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index c3d6c15788a3..3eb215ac8adf 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_saved_pstate; + unsigned int pm_saved_pstate; ktime_t next_wakeup; void *data; };