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: 10478149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04CBB601D7 for ; Wed, 20 Jun 2018 17:27:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A9B28F2D for ; Wed, 20 Jun 2018 17:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC98428F3A; Wed, 20 Jun 2018 17:27:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 630D728F2D for ; Wed, 20 Jun 2018 17:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vcItnaobm7yzN7Gd8VXeh6c4sXmhFKfEy9F+AaCZZiM=; b=L/+PjLyFgfk9/UGNiWqAT+BdYq yGsW2G+Kwq5rQEA4dixuPZnaKOW7PhihwoEPnMfsHi6Flmy+r1Hw0OLtKMeTsMESEjXO8x/EPdVgf tv4YUTpRgu271qEORl6pZiGY2h8m5h6jrVVQCCVlSe9ZmHv4TU/BgPpx432QDjlSq2M+Yb95jha9l vNCfXag3nF/ZmtnRdAC0ziQmdi4DTr/PryiPHE4SnugWg8xWX/7h5/yajuG/kVpSJ4OHQx5O5rNm1 /6kpG0rQ6krfMTmDAD59wigu79k8qzgLlmC7MAnfPy3SfZ5p4PxuErXWeuAgiUyL4yyH6OXvSvObV eRa7LVUA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVgtb-0000sQ-RD; Wed, 20 Jun 2018 17:27:51 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVgov-0005X2-H7 for linux-arm-kernel@lists.infradead.org; Wed, 20 Jun 2018 17:23:14 +0000 Received: by mail-lf0-x242.google.com with SMTP id y20-v6so500817lfy.0 for ; Wed, 20 Jun 2018 10:22:51 -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=eu025KD+WoP38EVWDGQmer/QIueoKhoplh8rByF6/m9O896cWUEyaDg3d1KTBckPOo f+PxPi7wquO3i4cuJhDLIi2VeFUJ8aZGkdyayDn8hS5U6d8TK52VtsDvWhpHXQDksNEW pYqh/exPnJOFr9nUd6OhnFTnYMSgR++8VPfqeV8tFEDK+r6ohjbIkggJnAC0o4VTWJ/0 /WnegxPKfxEZdtnBcye06k0EhUw/2Sq2cQLIWoW4Sa1Cr/LohycbgZPbyb66RLvFWuGT jS5KB7ScsNE8e63+iYhO32kcYeaON4QeJ8cL8iP+W5e8iXtbJ5oGnXhQn3+ZFdAT98t8 cnWQ== X-Gm-Message-State: APt69E1fd/zTdPp4o8qWKBKKcU4JT4TDVNW4yeEJJnbD9X+yPTHIaz93 ByRweCNZeOnue+kJ3SzZrLI1Kw== 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) 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180620_102301_613492_7C07B258 X-CRM114-Status: GOOD ( 17.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Vincent Guittot , Juri Lelli , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , linux-arm-msm@vger.kernel.org, Daniel Lezcano , linux-kernel@vger.kernel.org, Lina Iyer , Rob Herring , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Lina Iyer MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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,