From patchwork Wed Jun 20 17:22:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 139376 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1050573lji; Wed, 20 Jun 2018 10:22:49 -0700 (PDT) X-Received: by 2002:a2e:18b:: with SMTP id f11-v6mr14719305lji.83.1529515369792; Wed, 20 Jun 2018 10:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515369; cv=none; d=google.com; s=arc-20160816; b=L8+s2QdeHIxEm9kjSBWNmZdg9rVZPCvT1DcMiki0PtmK2CrvtdrHKpCd1k9E1gXTdj cNzYrnedtt9jc0XI3pAuEQB8NYpt0B1+3r5FbZwqjXUXQY7ujKwTim9C2vCAfoETjNnk HvaQJRQfO3Oi7SWFOBZB9uTMNiPUGBmu9ln44J7dN1+fLzB0lNWytAm0Tldz4Wl6gaRj 4TGoiR9mSx5f9fs8J6P3uVcbFK/F//P47KqdNZRJXar0JMneRbvaROvrbvrf1zOlzV3X OQjKnJjIpY/bk2KC283SgCPtdcZkbG4lQuqgdf74jpgea0eGVWhxbm0AFt0ILXvqkcmF Lwig== 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=vnYluIpcEHC+tsAsU0zpoMH7H2eRLG9C8FtOsJ0eLNk=; b=ZRhFVOBeSlXWUlWnU2mR5y2gmf5YR2vW22/QHKQ6EvstliLBbf371acew282wGQZAV NRkcteXidhdwBaDICizPY2dPLQU4Vw3YFgnF/lyMB7oJdpE4Ak+3UsbM9Nwn3iYWLI/2 MQcbgXvuhwHaUbipgvhTipSjY8TGigiVDYNF9s35sEQ31EslKCgyddzzL0h1lhU6SRoR jFSwvMAb3AIkJZ00I5b+tupzP3VUpmveiHjsuFj7qoNvimnnDpyOdL8tiNQbNTFt7vWB DSUjv3R5H3OnhCbRDNvJkUM5cbSyngXEw2tMBXecvIWiJ13M+kzxZ/ziTdw3Sy+gKudM cpyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9fuIxNS; 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 x28-v6sor730009ljb.114.2018.06.20.10.22.49 for (Google Transport Security); Wed, 20 Jun 2018 10:22:49 -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=A9fuIxNS; 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=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=BNYzN/a30peLOnCqDoP2sQ8o5B6wrgI2+ni+uduf9w+0NIhUr/BvsUBjVSbvo9248w bwrstBnkbHDUZsw+WUjMWY9wHJg6Usn+AZtgD8mh8b7Wa7xxziOwYAap0B12BNusUd+Y 0seDzXMPTLoAXdZwyGB8w4SveVs94rgsC7a+rbG5DgmMDEoCGDyIDs+CfxxhjI8PXBMu HIVdKe/7bycHUhKwVjgulfNMtVbZ+0BKRr5WrI5UGyv17sAFFwAcK1dvKbTO7rok6b56 AklZ3ycVSXl4i/9IKXMJi5vlx/jepyy+sxy+IXBhKW7WdLW8eMFyTTIdE47qndROK+MI xH5Q== X-Gm-Message-State: APt69E3rN6RZT+BgVh3XmdaEup3JcksezCYrRLFivBFSqnIbEThV/ygq IdS1ytt/NF+PNYciPgXVdNrb1cfo X-Google-Smtp-Source: ADUXVKK84Q1LGQnNiTjybKUAInQtHrhH0fvzJOM/HZa6SCmBbdy9GJRiOUal7GTkipBNB47dsvQi5g== X-Received: by 2002:a2e:1092:: with SMTP id 18-v6mr15640303ljq.115.1529515369568; Wed, 20 Jun 2018 10:22:49 -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 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> 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.17.1 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,