From patchwork Thu Apr 12 11:14:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133246 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573586ljb; Thu, 12 Apr 2018 04:14:52 -0700 (PDT) X-Received: by 10.46.135.214 with SMTP id v22mr405413ljj.94.1523531692619; Thu, 12 Apr 2018 04:14:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531692; cv=none; d=google.com; s=arc-20160816; b=F3NtewmvUXEgBfCSIKeO3HKXT4y1BMSLTH9PanQvMe5LpzHqE0EcYVV9OOR40qH16W EexFY8zjUhKQnKj9E64Cbmyy8lNe4PREgVIzkyQLz7SvIY8jYy7iKLLC47ess7khxH6W SGI28etINxQTVD/JSr/sBBmWbnGRUnGm+YEvtl/NxLq6ElcgoeI42vp35E5o6w9epPeA SAbHHN3Ita1+LCluG7ue8dswrGXwqrLY7WYcYH+f0zyia0wBY0mRB7uXE3f29a2/RYuu KNYO169++JgyKIlC9k26eDCneAWdSqw3HG0tJkznfiXaHoDXhl+6FUwnW7ajSdFlwHP6 4Xkw== 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=Mx+RGhiRqfre3W/WyaHvY+aHcTyzCVXc3AJ3mbA+OgY=; b=xNeSPI1PhoGRyrb7ehhHvJCjpzfhHVeBQvP78V3h2H5S/iVq8x75XPTqiRr9tlJ/9N jaY4tG5SgZjaR7mWeZ35ayQNcH5PoJqMM0fSH6HY4XfeIE1XnybPEds6Eg8mvL+O6pvt ajtSLr28Z7j1oWvRAhenT8sjWH3oE1tiW52FrZPCWn/ikJOKXlhhOoeAAQq9Ha/rGTi1 WN2vBk4wZ4OvJcXAu3+gPPWXCxOFp0SaZlokTEaNPAcJjJr/kLdPDJ7bEYUNeodeBaV7 TuFGm7/vYhmEVlQNcNi7iTy/xy/ty1WCJgq6nlAdoYadkpkGovYpPXd2EE0UuJS3pilB nN4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PTq6GgbV; 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 a10-v6sor906398lfc.54.2018.04.12.04.14.52 for (Google Transport Security); Thu, 12 Apr 2018 04:14:52 -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=PTq6GgbV; 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=Mx+RGhiRqfre3W/WyaHvY+aHcTyzCVXc3AJ3mbA+OgY=; b=PTq6GgbViTeFVVmnU/gnK5B1RilQtrROzeTEE45l5QqAB1Ui6nCKvHr/5wjt0zzeHd MSiPk0EmztBplhxIreT7AN+CYUwphjoU4SasKbjZLjnATSsxXuCcnjyCpF1Ko0gpZPDB 7K8gcRMnCJjcczpaIfDJ8c4cYS94bspXGWs8s= 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=Mx+RGhiRqfre3W/WyaHvY+aHcTyzCVXc3AJ3mbA+OgY=; b=dsFWDqHDVYcQ6bW05R8pi9s9pOJmC+bYn3vTbS7diMRsTP6NfHfjDr9uyHKUrtoj61 B9Ofyzdl6wqKcq8N++JzYVnfD+7FUqFZuwCMqlQJJR9STboNGTqTFyhdW9QrvvZKxu6y ADLU5SgBBGqwDUjXxxmUxvik/NxRISZP0l+yVAXzFeCm6eQh7f0deHls8/GESmRHLOjE BIv1j1m534AM99fQMlQGPTkUZ2KlIPB3ZQ4VmmLEbK5w/pcyfkG1G/15U1N0lZHuS31J oeO+zm8C6BV+kqONWVCO5KwhdySr6ohZTa0hmTl8Mz06Vn+6ILVaetBsZB9QWoGsYOf2 4rrg== X-Gm-Message-State: ALQs6tBkRpohcNPhz+rNBSpW/Z/hAKITbG+g5MufpLM5RUetuoJ49hcz BPVHWEEmqk04Mp5RBEzlrlk+idF3 X-Google-Smtp-Source: AIpwx49RR0120qo7r+xtTtooCM+h7X0fKOvKwAAexpC7j0K2cFxogxpk/X7ED5M1b2fJ/wsxP25PZA== X-Received: by 2002:a19:7dc4:: with SMTP id y187-v6mr5083167lfc.2.1523531692350; Thu, 12 Apr 2018 04:14:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:51 -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 v7 08/26] PM / Domains: Extend genpd CPU governor to cope with QoS constraints Date: Thu, 12 Apr 2018 13:14:13 +0200 Message-Id: <1523531671-27491-9-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-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 1aad557..03d4e94 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 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,