From patchwork Mon Nov 26 08:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 151992 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5345648ljp; Mon, 26 Nov 2018 00:10:33 -0800 (PST) X-Google-Smtp-Source: AFSGD/VWogsVI+nqERVU6y6w1YlsxqusjqWevlg0eODdhsVbQMyGcT56f+W8pxBcQ4cuhLczM7xI X-Received: by 2002:a17:902:4d46:: with SMTP id o6mr25479190plh.302.1543219832915; Mon, 26 Nov 2018 00:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543219832; cv=none; d=google.com; s=arc-20160816; b=DA6MCaqheDH4GraMe5i/l4hYpSrhLvK2cFpLYcKMWwWavU3MsAGoQCDlvlqrxwn4sA 8FygYxwU6mVXm2LlCA0SVGDq/lPUfeyrnyuAsEGbuv7mRrO9VJ0FKrX6GzV4Bznm7IsL prvbLX1QKxCuqF90blMV4nUATKTZ68bw//waR7Paynh1TPepryj4+mFlfhGOrv/Q4kum thtyV4b/1kjhLkGLKksEIuh5UxMO42QPilovCKqVtQ2LBnlMuPLos1b8seklJVTOx6oY bodLxWtSKlrrtXuWDXAnTZbXKkJ3Gze4K41VGPFYQlF1YB6xoFL3EORCFRF9Fa7aDOYq 8fhQ== 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=8dZ2xNG0wrY9M18CIWOaB56vm2msQMB1AEL61XjNEVo=; b=sCogn39ffRSYCYWNufUrUOHTiF6dHDOXGg3MfeS7ydWcm2bpREVEWmzTG0W9BUui0S d+pE9+oQ6WQdN6n7DAWaMiipTUxfOPo+YDR01V8gDXl3LjmWy5aJuZ8z8Kb8r3jdREIw iJb/ompOZqUUS/xEuI0o6ArZZNI6Cd1s/gw0Obc0CsLtn6Z9U77/MXqHAdAEb+1/xqFv xoQ6POynzqY1ITvbFzFUPfDLU+HypBYMsxHMAZf02zSDwXWM0wTNXSd9Y9IX/tU/NwE3 e1G9G+Gg0rRpZjtCQvMqb7Qf+CjNstVNudIPPf6jKKsOWkt84YfJpQGRB1c5Ak+F+N4J UMwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLQ+7HTQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 x66si19905180pfk.73.2018.11.26.00.10.32; Mon, 26 Nov 2018 00:10:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=QLQ+7HTQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726460AbeKZTDt (ORCPT + 32 others); Mon, 26 Nov 2018 14:03:49 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33091 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeKZTDt (ORCPT ); Mon, 26 Nov 2018 14:03:49 -0500 Received: by mail-pl1-f194.google.com with SMTP id z23so13501402plo.0 for ; Mon, 26 Nov 2018 00:10:30 -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=8dZ2xNG0wrY9M18CIWOaB56vm2msQMB1AEL61XjNEVo=; b=QLQ+7HTQdMzShJXE7t+Oz9eWOxQdypgCasgsGB7kGoxExkPT34ic6ehUvvVl2iXkWd yIIk7EAD1BChWJmt874dyKhY1jpS/HovTG4+28bU7F10g6+qJl8bB3Pm5fiSVoSPO+FD WsNvEZnNo/G+1Y/bYClJb1vxET6pXtQ9WZcfo= 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=8dZ2xNG0wrY9M18CIWOaB56vm2msQMB1AEL61XjNEVo=; b=UQcByOjv9oficmbvcYhabwvD2Mfp46GzFHCI+97fkfSvKdFy+HOlFgC2HZjwc+uZ7l s7rgX+yZBflenjwtmE3SSeWDvyqK+YcSCVSUJEB4eLefJtJZfk6NjPP+Rkg2tL1c7Pqr uYcwKyvqaSWXGrs1/Sl3mccAViwBLjueJp4kGMW0Zrpq5Yy4VJLZhH5ObIA331SPvdGB dKMoTiUjc9+VfCpISxQP08Usuo1Lt9WuVXVfU2hWv7VE+OhF0CfV70+P0u2Af2b5hsfH r2jku9N6NbaFEMy3pcihYYm0SXPjZdkC/RtUsXB5MBY/My6NAST32uDmXKItj4KpCTPv DMhQ== X-Gm-Message-State: AA+aEWYk1bIX2vMwrx6fPTR6NyeuKoaUAKr+JgrWfOkK54dY/PMOgk45 as4jO1jAb/cCdovt0Jx9vWHF/A== X-Received: by 2002:a17:902:b592:: with SMTP id a18mr26996386pls.182.1543219829636; Mon, 26 Nov 2018 00:10:29 -0800 (PST) Received: from localhost ([122.172.88.116]) by smtp.gmail.com with ESMTPSA id l64sm70802998pge.73.2018.11.26.00.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Nov 2018 00:10:29 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 4/5] PM / Domains: Factorize dev_pm_genpd_set_performance_state() Date: Mon, 26 Nov 2018 13:40:03 +0530 Message-Id: <401e29cb9e8d762e076253220f4a5dc22464e9fa.1543219386.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 105 +++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 43 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 0d928359b880..d6b389a9f678 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,6 +239,63 @@ 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; + + ret = genpd->set_performance_state(genpd, state); + if (ret) + return ret; + + 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: + if (!genpd_status_on(genpd)) { + genpd->performance_state = state; + return 0; + } + + return _genpd_set_performance_state(genpd, state); +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -257,10 +314,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 +337,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;