From patchwork Tue Dec 11 10:04:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10723371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4944413BF for ; Tue, 11 Dec 2018 10:05:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 375642A486 for ; Tue, 11 Dec 2018 10:05:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27F7D2A120; Tue, 11 Dec 2018 10:05:03 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB7D2A120 for ; Tue, 11 Dec 2018 10:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726117AbeLKKFC (ORCPT ); Tue, 11 Dec 2018 05:05:02 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35926 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbeLKKFC (ORCPT ); Tue, 11 Dec 2018 05:05:02 -0500 Received: by mail-lf1-f66.google.com with SMTP id a16so10327516lfg.3 for ; Tue, 11 Dec 2018 02:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BKyhNUMH3pAdnZZ6tolvxpJR7jgAjax62ysYVHFn6ik=; b=XpXnGOCQJo9i3IQbeBeF+/14cS05+IKSuHNRPfA5B7WFQSgfNabBid7MdrlKSOCpeH z6ZR7vpLulDkcnrABfAGZuVz9XxknQX6lrZSrOlQ78NNKMKZBTk6wR8mLEosu/4G73+X 188uRu1/p6Yr+V9MXID265z2C3bHMeuRINuUM= 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; bh=BKyhNUMH3pAdnZZ6tolvxpJR7jgAjax62ysYVHFn6ik=; b=c4w71ab6ew/l5UxDSgVrm2eWVXxwOroYv6+sgJtR0S8IUPp/30o0PJgo6MhupOSg+/ 5jhTNk+okFTQ0ZhdJy+PFu8QLd/O7/RzWYIrB0fYVYTii2v+OKu6nIHn4VDFWf/swLBT lK2jfmnTNkEwZ0zmi7b8wFfbWiRuGVllzb17ayMlyUtnHrLRSkPwtQ8TV+38O17Ak24m vcxoPzJT1ARU6etYdMMYPFi0CzrrustyUoB7IyIRgSo1da8qvQOyLDV83IrsB37mDLMf H9Gtm3S/pRsRvls+y79LGknqZiBTgrdyoOERCHjFwI2VJbymPDdKpbDLP7A4RHITqN1p DiOw== X-Gm-Message-State: AA+aEWZ1SMEZV7tB0EHTcI7Pr4vGRV70STxUHX9Y/ddEg1hmGgFLMHKK lY1+VzKx1N6/nAs0R03VIQOZWA== X-Google-Smtp-Source: AFSGD/Wn1EjYa/2UVRaghy0a0XHhF6ykJA9vHvtAYvVyyv3DgMHm5qEhu/X2zFcv83E+ef56y/CCRg== X-Received: by 2002:a19:690d:: with SMTP id e13mr8857246lfc.84.1544522699756; Tue, 11 Dec 2018 02:04:59 -0800 (PST) Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 6sm2742920lfa.27.2018.12.11.02.04.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 02:04:59 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org Cc: Ulf Hansson , Rajendra Nayak , Vincent Guittot , Stephen Boyd , Mike Turquette , Graham Roff Subject: [PATCH v2] PM / Domains: Make genpd performance states orthogonal to the idlestates Date: Tue, 11 Dec 2018 11:04:55 +0100 Message-Id: <20181211100455.25905-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's quite questionable whether genpd internally should care about if the corresponding PM domain for a device is powered on, as to allow setting a new performance state for it. The assumptions creates an unnecessary limitation at this point, for both consumers and providers, but more importantly it also makes the code more complicated. Therefore, let's simplify the code to allow setting a performance state, by invoking the ->set_performance_state() callback, no matter whether the PM domain is powered on or off. Do note, this change means genpd providers needs to restore the performance state themselves during power on, via the ->power_on() callback. Moreover, they may also need to check that the PM domain is powered on, from their ->set_performance_state() callback, before deciding to update the state. Signed-off-by: Ulf Hansson Tested-by: Rajendra Nayak Acked-by: Viresh Kumar --- Changes in v2: - Clarified in the changelog, the new constraints this change put on genpd providers. --- drivers/base/power/domain.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7f38a92b444a..4c39ea1b2cf6 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -311,12 +311,10 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) */ update_state: - if (genpd_status_on(genpd)) { - ret = genpd->set_performance_state(genpd, state); - if (ret) { - gpd_data->performance_state = prev; - goto unlock; - } + ret = genpd->set_performance_state(genpd, state); + if (ret) { + gpd_data->performance_state = prev; + goto unlock; } genpd->performance_state = state; @@ -347,15 +345,6 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) return ret; elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start)); - - if (unlikely(genpd->set_performance_state)) { - ret = genpd->set_performance_state(genpd, genpd->performance_state); - if (ret) { - pr_warn("%s: Failed to set performance state %d (%d)\n", - genpd->name, genpd->performance_state, ret); - } - } - if (elapsed_ns <= genpd->states[state_idx].power_on_latency_ns) return ret;