From patchwork Wed Mar 14 16:58:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131677 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410407edg; Wed, 14 Mar 2018 09:59:17 -0700 (PDT) X-Received: by 2002:a19:7dd4:: with SMTP id y203-v6mr4165857lfc.32.1521046757026; Wed, 14 Mar 2018 09:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046757; cv=none; d=google.com; s=arc-20160816; b=t8OClHVspD769hv1ZPGCuwRKFa4akU8O7cW8TN0ZmSy7wc7eBBNU69LDqhNILqRIO6 y6pu8qXCRBg6644q8Wl22PvkbIlNtdoI6NZS3uYg33+ft2yWXAlP+f/bt9rLd+swtDJQ 2qWsjFADxUTJmcfDMIpnRgm9TjqHsG8+6nQL7ah+j1sI3Cz9+plwFk+Z/JBimZ2Vq/v4 A5Y5nfroDsr9M5fV6RfaGqtlACBILvjcC6ap/k8FvJpP7kn9rjhuyKojXE+bUTxBM1y8 EWi6EB6OUPOaJojoohXI+p626XpJwfXlZnaLyQXhmAwygipNJf/HziN+Mnv/HwWeP4GT boXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=qJ5foxI1lz7tFzUTVz3PNndWcphNzNOcxqj0edilI7A=; b=nDavT/kQsVtcpTnLzMJJPk/uzGkQgZ2cBK8zs5TabGiBZgqcp552ZlV23ArD9zkzdU 1VReFiH8syJTvaO0/6l/qlNlKr8pnFdVQGjmX69sdNpvg/m+4/W8dbGR6xWgi7EA+Bo3 sgdnNNuWvPiKtwG9g1LuM84hbGHMdtvQEFjFsZqYdW4R+od/qRGSkh4S1KbpqmQQkr4j zvDf3RKXyzdUV7ewLVmKrwQ+4EyjTqBlBiRKZNdrlF5RfzUlB/ZfFa4QYdIrZv48KFwN YPnTmBIw2kV6WXSMN/TL9t6f2onUlIfkvWqtGAWUgnXkDVUxNl0q70+z5s0nRv7TD/n1 DP2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A28n0O+6; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e24-v6sor863948lfb.64.2018.03.14.09.59.16 for (Google Transport Security); Wed, 14 Mar 2018 09:59:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A28n0O+6; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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; bh=qJ5foxI1lz7tFzUTVz3PNndWcphNzNOcxqj0edilI7A=; b=A28n0O+6B5GtByYBN3+Hn0H/Uzq6Hl6EdlwLOaWEoDXUlm1iIW+9rLQQnavBvbuuAB xWhpEt4d2EvABN++oX5aL/lUBckI+llkMrT0mHvWb78siH9P1tvdamT+GLSRhtImc434 qWAeX39IWr5jjCqaJMCiOygCIYUyD7zfDeNPA= 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=qJ5foxI1lz7tFzUTVz3PNndWcphNzNOcxqj0edilI7A=; b=NHLEEyHnTWN3e3t79Zfzrr06JJGF0J6QFBhVT0v8LKcNgXDn1SSmM5HgZvlPmDh+bv atjtOJXOwUcpzCDmg0xD3aZW+Tf1EM4EMQVjjNkW1GnQH7JEc1g5YeVW2mukHlQQRSzB XxApfglUZNx72fiuWEmypbpoDVz+5l8H0fM7N/pR4jHRZVq822C7lDO92vEmep7uIELJ 6NVwwFsFjeix5+oore1mFZFtz0QAXC3CtwSkXRCa2uY6DvQ8YgYGKwkpllYrt+4sEWuh sA5sTtbGsex7gYPqS47A2NluN96jqLhNF94PCc/hQUsE7mX1XroUeSAoLHWYg75fn2Ih RJZw== X-Gm-Message-State: AElRT7HlBhQUleWL8hBmJrlyih8cWLha+xAqJyf4XHmTJaphrW6LqFEi KoN+PhXMIGjrwysEMh/IughSaR6A X-Google-Smtp-Source: AG47ELuhxqVYigt32oLkl5ebTYlGhgNzggotEhXyoY3DbQdXkNXTX/6QxkO6Ee9XNVFiWF0S8J+VdQ== X-Received: by 2002:a19:181b:: with SMTP id o27-v6mr3776139lfi.132.1521046756692; Wed, 14 Mar 2018 09:59:16 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:16 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 08/25] PM / Domains: Extend genpd CPU governor to cope with QoS constraints Date: Wed, 14 Mar 2018 17:58:18 +0100 Message-Id: <1521046715-30683-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.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(-) -- 2.7.4 diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 70565a8..2f162bc 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; @@ -275,9 +282,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) /* * Find the deepest idle state, that has its residency value satisfied. - * 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; @@ -310,6 +317,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 8f60181..e7910d2 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -77,6 +77,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,