From patchwork Mon Nov 5 06:36:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 150141 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2242374ljp; Sun, 4 Nov 2018 22:37:23 -0800 (PST) X-Google-Smtp-Source: AJdET5dHcw4c1ICNwXMmImeyRtRHZkC2i8YCYKCWvtIsQWwH9jptZ7kh/BO+IPpH82tf3Z0ovvkP X-Received: by 2002:a63:7d0f:: with SMTP id y15-v6mr9412518pgc.171.1541399843782; Sun, 04 Nov 2018 22:37:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541399843; cv=none; d=google.com; s=arc-20160816; b=pxOFdzqsG8p0Ld7bikfqNGtlIOiMbJBHMA9fezaOE7VqhZA61zmSdL0wKM25D4aP6s jDOQI8DxxnyvKqDT6uaYry5tFmeGstImycqM4RClR5pkPaBBWZU9hZwFhGQcfOKncqT5 DGGlt867mt7GM6WJzE3TJGXnP/xSXSu2FW+Cb/yCKO05W09JYQHiJskdddN7jXAD5FiI 2XE1vZmj7V+REahmFuTt0NXJ+m3mZMMyuz5poWK6qzb+M0AMqz2HK41a8KXpVVX+t2ea s61JDNE+kTU3gzwbFaS9px+Xh34joogiK57q5Wa/qUbGkJzbeCY7Sft7iPN5z8ylROHj BDBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OTLJoVN5MMvVsPcSQkjRuLaNcVa7Qww7gt9pAH6Lr8g=; b=ZWgO30vzqlW0h+tgVBO1BFkjTPqBjkZcvXnQg5TfiauwTFkl801VVmcJsxWtniS/OV RoaMc9ml/KJlyozqrNZ9QPoxXOPkqTDfDm17PytGnEOaSzue18U2JA825g0LzA2DxdMj 8qI4hxNMqsAGFGXRg1DjpulXctRZ435Qn66e3fuyZC85OEj022gQT3f6s6gkThUMQkyJ Bc7ANKavQIrOkHw8MrG85VuWIUgKX2oI0O4P6+I3gbiMqy1Zm7JEmTlA/Vxr+MDwT6S6 a8Z0ziqRyKHT7/+rAoWnUmkba92EHmwDvTjYB8ETfaVDl3lJVVVJOqhL+agAfctL6BZY nWVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQ4ZDR4z; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si42023076pgw.401.2018.11.04.22.37.23; Sun, 04 Nov 2018 22:37:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQ4ZDR4z; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729462AbeKEPz1 (ORCPT + 11 others); Mon, 5 Nov 2018 10:55:27 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45423 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729461AbeKEPz0 (ORCPT ); Mon, 5 Nov 2018 10:55:26 -0500 Received: by mail-pl1-f194.google.com with SMTP id o19-v6so3929416pll.12 for ; Sun, 04 Nov 2018 22:37:20 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=OTLJoVN5MMvVsPcSQkjRuLaNcVa7Qww7gt9pAH6Lr8g=; b=eQ4ZDR4zxeQ4zqmCfhat2+B6osV3DKaHIS04eIZ1r4ALYqveT91QcWVWqZg6cYxFVj THKU2ML7zxiXa7E3oWKx+ZHUpXr0kFlDJNAynDRAxQZJnMIIvyDo5qzCioDnNypZeBmg c1Caqp57G8aux6i4Z62Vi2M98jfLVWJaEhH2Y= 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:mime-version:content-transfer-encoding; bh=OTLJoVN5MMvVsPcSQkjRuLaNcVa7Qww7gt9pAH6Lr8g=; b=QMv1WaJuxLmFNKgb4PDl6wuja9sR+wUf1h9zA2VMvRz9KjT+UEIviruBGTn3eYcv2e jfs16FK8eu2xpcqmQRTT9yscoGF/96lQNj8I2eNrB0+CEqfO10Gba5nSQnq/I9sW0gF9 YJKV0KcPuZGAsau911zjr0KSTBZqQ1BJB+bNhI2JRULaJ0col2dTajJq4+MGFtUB1Y1/ BvsI11AKX+ls8oReeQiXuRUUtAvCDiSWrX1XSfxRp/wqVCo4ruj04oBBhLqxtU8kXkAn qhUayzAWOLMU8DvUu1HL7ETxROyl9fsdF1CMNLvINhm79ob4ANagaLJY/kpzZLqDnn89 lAdw== X-Gm-Message-State: AGRZ1gIiTyRqgR02JHpNovMkbL4OtrANOlVE7fnUjJbd9iR5r5vT86EJ wyU3evPSWZ4+ko2oBMHhM3LaTQ== X-Received: by 2002:a17:902:74c4:: with SMTP id f4-v6mr21229811plt.52.1541399840064; Sun, 04 Nov 2018 22:37:20 -0800 (PST) Received: from localhost ([171.61.116.174]) by smtp.gmail.com with ESMTPSA id e204-v6sm6986750pfh.68.2018.11.04.22.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Nov 2018 22:37:19 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, "Rafael J. Wysocki" , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , niklas.cassel@linaro.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] PM / Domains: Factorize dev_pm_genpd_set_performance_state() Date: Mon, 5 Nov 2018 12:06:45 +0530 Message-Id: X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Separate out _genpd_set_performance_state() and _genpd_reeval_performance_state() from dev_pm_genpd_set_performance_state() to handle performance state update related stuff. This will be used by a later commit. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 104 +++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 43 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 0d928359b880..6d2e9b3406f1 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,6 +239,62 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd) static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} #endif +static int _genpd_set_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + int ret; + + if (!genpd_status_on(genpd)) + goto out; + + ret = genpd->set_performance_state(genpd, state); + if (ret) + return ret; + +out: + genpd->performance_state = state; + return 0; +} + +static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + struct generic_pm_domain_data *pd_data; + struct pm_domain_data *pdd; + + /* New requested state is same as Max requested state */ + if (state == genpd->performance_state) + return 0; + + /* New requested state is higher than Max requested state */ + if (state > genpd->performance_state) + goto update_state; + + /* Traverse all devices within the domain */ + list_for_each_entry(pdd, &genpd->dev_list, list_node) { + pd_data = to_gpd_data(pdd); + + if (pd_data->performance_state > state) + state = pd_data->performance_state; + } + + if (state == genpd->performance_state) + return 0; + + /* + * We aren't propagating performance state changes of a subdomain to its + * masters as we don't have hardware that needs it. Over that, the + * performance states of subdomain and its masters may not have + * one-to-one mapping and would require additional information. We can + * get back to this once we have hardware that needs it. For that + * reason, we don't have to consider performance state of the subdomains + * of genpd here. + */ + +update_state: + return _genpd_set_performance_state(genpd, state); +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -257,10 +313,9 @@ static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { struct generic_pm_domain *genpd; - struct generic_pm_domain_data *gpd_data, *pd_data; - struct pm_domain_data *pdd; + struct generic_pm_domain_data *gpd_data; unsigned int prev; - int ret = 0; + int ret; genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) @@ -281,47 +336,10 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) prev = gpd_data->performance_state; gpd_data->performance_state = state; - /* New requested state is same as Max requested state */ - if (state == genpd->performance_state) - goto unlock; - - /* New requested state is higher than Max requested state */ - if (state > genpd->performance_state) - goto update_state; - - /* Traverse all devices within the domain */ - list_for_each_entry(pdd, &genpd->dev_list, list_node) { - pd_data = to_gpd_data(pdd); - - if (pd_data->performance_state > state) - state = pd_data->performance_state; - } - - if (state == genpd->performance_state) - goto unlock; - - /* - * We aren't propagating performance state changes of a subdomain to its - * masters as we don't have hardware that needs it. Over that, the - * performance states of subdomain and its masters may not have - * one-to-one mapping and would require additional information. We can - * get back to this once we have hardware that needs it. For that - * reason, we don't have to consider performance state of the subdomains - * of genpd here. - */ - -update_state: - if (genpd_status_on(genpd)) { - ret = genpd->set_performance_state(genpd, state); - if (ret) { - gpd_data->performance_state = prev; - goto unlock; - } - } - - genpd->performance_state = state; + ret = _genpd_reeval_performance_state(genpd, state); + if (ret) + gpd_data->performance_state = prev; -unlock: genpd_unlock(genpd); return ret;