From patchwork Wed Dec 12 10:57:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153573 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1679583ljp; Wed, 12 Dec 2018 02:58:08 -0800 (PST) X-Google-Smtp-Source: AFSGD/XCzCkuhDhDWnZrV9IaWhHA5lT33UxEXHMU16cQeUXkrOK//AVczQvQxfqU0PhtyjlIYfiG X-Received: by 2002:a62:d005:: with SMTP id p5mr19784444pfg.175.1544612288290; Wed, 12 Dec 2018 02:58:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544612288; cv=none; d=google.com; s=arc-20160816; b=ZxR5nEPpfjb/oExefVoRREh7Xhta4QGOmUlYcQHQZRTyR3kh30EYqeyKr8iU0rwAl5 fO8pMXAxOko34kCFfyjhTaI0esp1IQLjUzmHkoeE/249XMCn7xiwW1l+hoviJPbOUAwk lV28wTrLT67DPSPkXd2NK6W66wO1ayTFkwBq98m8oo0uEO6govsC6zGoUCO0UIxpXcQz C1ZYlQi4yBkp6BkzMrFL33Sk5WvWCXjuXk2z0GCxmsV5sHoIVTa5TM0DhWpc+OuCwQCG rLRzMeJuj61QvOInJrlsnk8lEFtMamDBe81pQcqDJFOO4uR3jUN0Sr7F8fIbuzHYsyai TLjw== 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=z6NgWUw1lJ1tXqc1WKyoMXFmTwlvDqOcRTcyO/vcEI0=; b=U+ylDO8lSPTX+kw9Ynh9weMsK5ASDxwRyzbiMeacOp07I6gWexOXRjIjVZ5qTK/vNk ArWMq2Poj2sIHB9IpXOVPnxhbe2E586eakuMsfGKq1aUYUK1PpLxS8DpszHJDGa04cHy 34iVRNSYniEJ148CMzey38BkrZvS3pR0C9jZge6Z9PHznPOwlVRRbnO32KcP1OxZ72KN /j1NU7O+dYihY1V9MNQA04uhAK3or8Rdq+6kbCbNfq3pglfgdxvH0K2KHKdzSmKoK/hZ cElfVL+F2JmLGQiOV+EeTJnb4wcZn5Hy0Km+SUNYTQ+8wA8secJg3WifAdbd4QPN+jKV /WMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LbC4bfM3; 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 f34si14716144pgm.318.2018.12.12.02.58.08; Wed, 12 Dec 2018 02:58:08 -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=LbC4bfM3; 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 S1727333AbeLLK6G (ORCPT + 31 others); Wed, 12 Dec 2018 05:58:06 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:32918 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727302AbeLLK6D (ORCPT ); Wed, 12 Dec 2018 05:58:03 -0500 Received: by mail-pf1-f193.google.com with SMTP id c123so8724786pfb.0 for ; Wed, 12 Dec 2018 02:58:03 -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=z6NgWUw1lJ1tXqc1WKyoMXFmTwlvDqOcRTcyO/vcEI0=; b=LbC4bfM36KSfUk5o6CDIqbn5bhmGTEdG0x06MAHHI8ykcrXJsDDIz3hd8cvztrhgjK j36FQiU7+8sHmXBMPte6x0Q2wAQ7thSkPi1O5n/eOPgJ6u8gKKyij0jyscRWdo7MXgpe 8WfEI8X47+WhJuGfQ+N8+bVrIcbgFjFKve/Bw= 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=z6NgWUw1lJ1tXqc1WKyoMXFmTwlvDqOcRTcyO/vcEI0=; b=YzdOr+zuuUGLznrLVSNNOh+hjb5nM5rerOoQJHnAVwd/7T/3c0f0igYjWvkC6XJsuQ jE1p3xDP3Y2kdkxxgkYAWT3jdwWmj4r4O7ubzybnLAVlXxBe4p3i9wfx9sDnoC8jwRRw iUcDrJ9PNzBd+S45yp6AeUbM/nre6HIyZ9pW8/cUdHfXzfbalOWQ93ZnkM9OhyDCEc3w 8QbjLaIpWPoH07qz7pyEVVseaLZZWBHpH9Xsy2jJG//7IWNJJiasbcBQT7NZIDLzZOG3 9CMX4kSZUf14MkRFdimePvwIalWAwdipreOxlJiFF3DvIzJatAKIJjJFp3+EOeJXCFbu nC0A== X-Gm-Message-State: AA+aEWYlA3kCM9nHIyxjRGnUXR8qZKR3qljlORmmFt44vR7//FENzqm8 iB3HV4DoAo5SyE8PYgheiqKFww== X-Received: by 2002:a63:1b48:: with SMTP id b8mr17939588pgm.187.1544612282767; Wed, 12 Dec 2018 02:58:02 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id v12sm25370916pgg.41.2018.12.12.02.58.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 02:58:02 -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 V3 5/6] PM / Domains: Factorize dev_pm_genpd_set_performance_state() Date: Wed, 12 Dec 2018 16:27:28 +0530 Message-Id: <729bf6e3b2f434df7e11370d01bc8b0a6f80da5a.1544611890.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. Acked-by: Ulf Hansson Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 96 +++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 40 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1e98c637e069..32ecbefbd191 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,6 +239,58 @@ 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: + return _genpd_set_performance_state(genpd, state); +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -257,10 +309,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 +332,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: - ret = genpd->set_performance_state(genpd, state); - if (ret) { + ret = _genpd_reeval_performance_state(genpd, state); + if (ret) gpd_data->performance_state = prev; - goto unlock; - } - genpd->performance_state = state; - -unlock: genpd_unlock(genpd); return ret;