Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1035678imm; Wed, 20 Jun 2018 10:28:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLwDZRyrCnpeUJTY+8YW18ZxOnHumKo6pZaqxwqu74Bp3cGCnrkMbH1g2/vnphE5N7NG5pq X-Received: by 2002:a63:5401:: with SMTP id i1-v6mr19174665pgb.187.1529515701472; Wed, 20 Jun 2018 10:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515701; cv=none; d=google.com; s=arc-20160816; b=OLlFBHZtzERuwacXeDsl6NBUoI/Zx7Y/0cWSo4fqCvfty13cRfHtVquY/veWk/wEcw x2PGTiVHfGilpfiWtQwIyKuwQK11p+Np8XgaNCQdZbCpjEkuHgsYbe+QN68T/X4Sp5D9 jnnb/mn34g8wO/0azRcIYIBTR0j3btXWKizquh6Etl5N9T/BemRUabYRFASR3a83IJER 1r9G+NgVzjbvtt7Ep9xPCdUJmtBJph5Uu6EMICs2gUdy0gPpY4nwduu5Jp2rPF9vTqXg 0njXzprCyv8fwPlbMcxDXOdo8yUUhyyOhFifVY/JccK89a/d7m4pd2TwynoAeTjh8IF4 J/iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=dZPw96Ey2MvxZ3MY7b3qOM5rFdk5RpduTuJTQEySRyUoAtdux4Nc5FOTyyUMvq/j5/ LV5GsGbvZvyPKhOGFKV6O906ub/PeU/5jcaRLRxr6fQtbk5xQstXAATk/mDQbHLH3KPh H/F2e9rSp9qrguM/4VozY0W4B967/TC6tRGcJOpZoUXFeheZHU13JQvtbcf1+elJN5VB AgeVxUbxqV7R1W2zoOPj0jY6Bcxv91lIPcG/05pdtLiPoiiFLyS8CSxrG6DEQych1a9L p+yhoftbJduMv0lWZw0H+XTppsEv/SUyHyIYurtKfnkf6bSMpeOZ7D0vP7GJ/3oBiSPc tg9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9fuIxNS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si2818404plx.286.2018.06.20.10.28.07; Wed, 20 Jun 2018 10:28:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9fuIxNS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932220AbeFTRWz (ORCPT + 99 others); Wed, 20 Jun 2018 13:22:55 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:41706 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754527AbeFTRWv (ORCPT ); Wed, 20 Jun 2018 13:22:51 -0400 Received: by mail-lf0-f67.google.com with SMTP id d24-v6so462342lfa.8 for ; Wed, 20 Jun 2018 10:22:50 -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; bh=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=A9fuIxNS3uBRahtGY3yF8BJX+KBopB0YlNuVvX9MTh+xt1z7j1iKkK9AELwlTF7KCl Rd/7Y/OeF6eDwgvDCt+aqtfnX8WxW1mYntnkQ3QBpQP5Z2bR6+dLVx+eNEIMg8natOdz MdlfGI3j2PSCpKmKUQiReapNtTpQ9lJlo6Q9g= 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; bh=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=kRbGQgzvJ+6hOKXMyynAd4YrZTywoL5w4DP3Oyilcfxirb3Vn1OvPUxnCyQjujrt4K 2qCzTq4U2oq7M6di7+yWNDdhp03PHCtsM82PUWyGSn8qu4tDbhdBeXCHCQKQunnIzIXg 2arR945kBI+AE/YkASInsfXEdf3NuX/XuF02gsGnEp8uekAhCjsk1vVWErlJdiHJOv0j uo9vgjubJz6TPHRR1ovKtssaIpQyVDfAHtdUD1MDSoNuUbhTn9ZGGGNlRNVi3rQPjJcb +VfprzEVHOiEknhfjo0m0IGbUWAM7OTuSIRTk9J/ddNPl2YilGcvVNnaCDHHG1q0Hz1f uFSA== X-Gm-Message-State: APt69E1OWV2rjTQX9bnL6Chk1+V+IMxdgvq5NJdZG+7GkspJmpBbZoj3 MXsp1qw4Weqk08kOQMkP2YlrFw== X-Received: by 2002:a2e:1092:: with SMTP id 18-v6mr15640303ljq.115.1529515369568; Wed, 20 Jun 2018 10:22:49 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b2-v6sm514441lji.85.2018.06.20.10.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:48 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 08/26] PM / Domains: Extend genpd CPU governor to cope with QoS constraints Date: Wed, 20 Jun 2018 19:22:08 +0200 Message-Id: <20180620172226.15012-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CPU devices and other regular devices may share the same PM domain and may also be hierarchically related via subdomains. In either case, all devices including CPUs, may be attached to a PM domain managed by genpd, that has an idle state with an enter/exit latency. Let's take these latencies into account in the state selection process by genpd's governor for CPUs. This means the governor, pm_domain_cpu_gov, becomes extended to satisfy both a state's residency and a potential dev PM QoS constraint. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/base/power/domain_governor.c | 15 +++++++++++---- include/linux/pm_domain.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 1aad55719537..03d4e9454ce9 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -214,8 +214,10 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) struct generic_pm_domain *genpd = pd_to_genpd(pd); struct gpd_link *link; - if (!genpd->max_off_time_changed) + if (!genpd->max_off_time_changed) { + genpd->state_idx = genpd->cached_power_down_state_idx; return genpd->cached_power_down_ok; + } /* * We have to invalidate the cached results for the masters, so @@ -240,6 +242,7 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) genpd->state_idx--; } + genpd->cached_power_down_state_idx = genpd->state_idx; return genpd->cached_power_down_ok; } @@ -255,6 +258,10 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) s64 idle_duration_ns; int cpu, i; + /* Validate dev PM QoS constraints. */ + if (!default_power_down_ok(pd)) + return false; + if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN)) return true; @@ -276,9 +283,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) /* * Find the deepest idle state that has its residency value satisfied * and by also taking into account the power off latency for the state. - * Start at the deepest supported state. + * Start at the state picked by the dev PM QoS constraint validation. */ - i = genpd->state_count - 1; + i = genpd->state_idx; do { if (!genpd->states[i].residency_ns) break; @@ -312,6 +319,6 @@ struct dev_power_governor pm_domain_always_on_gov = { }; struct dev_power_governor pm_domain_cpu_gov = { - .suspend_ok = NULL, + .suspend_ok = default_suspend_ok, .power_down_ok = cpu_power_down_ok, }; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 97901c833108..dbc69721cad8 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -81,6 +81,7 @@ struct generic_pm_domain { s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; bool cached_power_down_ok; + bool cached_power_down_state_idx; int (*attach_dev)(struct generic_pm_domain *domain, struct device *dev); void (*detach_dev)(struct generic_pm_domain *domain, -- 2.17.1