From patchwork Fri Dec 14 10:15:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153810 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1882074ljp; Fri, 14 Dec 2018 02:16:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/X4Kdzmnj8d/TOlfW0sShA6cXcC3OXdxEZzas1TUyqIR/UM66aSfrHuoBiNnomX7Y3c2tVx X-Received: by 2002:a17:902:2868:: with SMTP id e95mr2284830plb.317.1544782573252; Fri, 14 Dec 2018 02:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782573; cv=none; d=google.com; s=arc-20160816; b=ZFdM38jqQ1uyNRItcy1/e0TykQTCK3qsi/KyMsFHRpeSUxPp49oIBCNB1sOGDF3jag 2IxrjpBDjMm5TlLYQmUDjEvooA7WKaG5xygH9jMAQqm4K7lQSYSIjN025vDv3un01C63 swgPCdbaYInhbkypzDfB7h1+1vN4Oy2C1J4v33rwVOquzPtU+l0Y8FNdqIKpE07Yfd/T XcIuQ8Bz8sOYf9IQoKvLt6n0HlMRxmGu43mCqx2ffn5dCWkyH6Rm2QpvQifyQMbxm5jD e9PGi8iweOIR+KmgCiepgz49+4VauN9k8CLkY4Dur3Rd/GE1G/AU7zwdabHHB7lhXc0T yKPg== 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=oMuVu8n3ZWdRbQbhEMy90Uj7CKk0/3mUfjD2e/MUMn0=; b=sJu1Q+Qj7a41OzUe9k37rm8sWDU2aXYW/sout5JMJyTlMgUu2JFjuGhQpWTQB1+gQf +Y3ciqD/+Ud7O+7IYU8jZgbDGsnAqQLU21cF4olGj55fwFWoy/qLUTtwdAZgnp5bVkc1 Tq3DQgxrTJKei1TKLfyCtdVPzUdpZLUky5OUuytldpPSfWAsbbfCEJA/BpMUAlFbxPNW NxVs7q8EfpPAiqqYcZbFQnaXNQYkh24SZFt/lTxK0qrsFccEDl5PHK1Ya+cr8jHYdNPd RoQUiRg+Fgz/UahVvGHtK4L/oohYnEUAiul4EQbkMA69P6jhXQ5V6klubgvML3Jg4xPK HKzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M067d3ml; 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 r197si4254426pfc.116.2018.12.14.02.16.12; Fri, 14 Dec 2018 02:16:13 -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=M067d3ml; 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 S1728881AbeLNKQM (ORCPT + 11 others); Fri, 14 Dec 2018 05:16:12 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41248 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729601AbeLNKP5 (ORCPT ); Fri, 14 Dec 2018 05:15:57 -0500 Received: by mail-pf1-f196.google.com with SMTP id b7so2613463pfi.8 for ; Fri, 14 Dec 2018 02:15:56 -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=oMuVu8n3ZWdRbQbhEMy90Uj7CKk0/3mUfjD2e/MUMn0=; b=M067d3mlqJZnjoZ6EfwLLzsP0gOVKArU5HUpi9pSuQQwWwKtbwfhoSZAj16RvErXA0 +ozZSMVoLrL+OOnAJhFn85fqIajezry3r1RNBLHY5qoHeMW1y7hD0bcHogfN2NvoxhMe 8GzGbec6hmUnBDxrcmXceXeePzBOmbmpuK13U= 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=oMuVu8n3ZWdRbQbhEMy90Uj7CKk0/3mUfjD2e/MUMn0=; b=n1XwVTDp39ZkRPWi3XGwcbN890XSlpur66wChIX+jHpx3kMwA+NpVGtY1sKiCEzcIu d5TXqF9l2cU5xjDZICnwUbodq+lUUYJrWuPUh+jvuzrrTA5ezQsl+Ww8qUovng0ZmYq+ lzTGLxCFTHCoXepIac5AGX/iH2B6xA2MJNB7LZVHgd1fMppmW1gePJx7R2BTNHyY6maQ 8NaRflWDsgOxr6csegGQ/zOdGaEWXeZWGJcjfjp7iCO6oLS3sFtnPbPIerhQNG12bW/V u/QpqlXDkrTvP+4+y4h0F8K6TOMrCV8R+EtdbBaF/VLdfSvWBNta8u+7niz538aKsfDb Q8/w== X-Gm-Message-State: AA+aEWZwyafC0D+RomW8RRShxEpilvPHUIZErhVbUCJXwJIJM2QFUwTD Gffg9Vf4kx4v0uSRGQdpgeqapw== X-Received: by 2002:a62:de06:: with SMTP id h6mr2339573pfg.158.1544782556201; Fri, 14 Dec 2018 02:15:56 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id y71sm9960187pfi.123.2018.12.14.02.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:55 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 6/7] PM / Domains: Factorize dev_pm_genpd_set_performance_state() Date: Fri, 14 Dec 2018 15:45:32 +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. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 95 +++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 40 deletions(-) -- 2.19.1.568.g152ad8e3369a Reviewed-by: Ulf Hansson diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1e98c637e069..808ba41b6580 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,6 +239,56 @@ 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_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 state; + + /* New requested state is higher than Max requested state */ + if (state > genpd->performance_state) + return 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; + } + + /* + * 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. + */ + return state; +} + +static int _genpd_set_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + int ret; + + if (state == genpd->performance_state) + return 0; + + ret = genpd->set_performance_state(genpd, state); + if (ret) + return ret; + + genpd->performance_state = state; + return 0; +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -257,10 +307,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,45 +330,11 @@ 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: - ret = genpd->set_performance_state(genpd, state); - if (ret) { + state = _genpd_reeval_performance_state(genpd, state); + ret = _genpd_set_performance_state(genpd, state); + if (ret) gpd_data->performance_state = prev; - goto unlock; - } - genpd->performance_state = state; - -unlock: genpd_unlock(genpd); return ret;