From patchwork Wed Dec 12 10:57:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153569 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1679399ljp; Wed, 12 Dec 2018 02:57:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XuZyq2AJoHPif17DeKAeAWIZIVlLC5dsl7vaOgupnWSaCe0kltoJ9HkhW9yeDOxYj1ARjE X-Received: by 2002:a62:938f:: with SMTP id r15mr19652607pfk.27.1544612273508; Wed, 12 Dec 2018 02:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544612273; cv=none; d=google.com; s=arc-20160816; b=seF0H8vrkyz7m9WHvwZm3lOKvpETh14Qus9/LPHk2WnCxfpzJJsyW4z8U5d5WsnmFv 8pWsJZQ9tNw7PUuf4QuP8mJrG0k5uwIdzuwWD5VwdQGB5qcZg1V3L2bLcmIAis4amMtg qkAE6lLfoUMkhV891WRnHkfvh2JC+YO0R5bCXuEggpp/jcumVDI94f6STR898bUKoLeM Dglw0SsqKsr0I4nTptJotk9LRaMQuJWgaEXORPzdRg4QKoIVRuFYmGvHf3R3qKKRHNj0 /f0/lzzRoDoCP8EhEjUEv1dEvmwJA17Qk/vW6/SV2mdmkk5iNH/mLfugSNPBQpGRm7bA og7Q== 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=a5kLi4xuwk7dpMQcurWuHvhYASg5acLmavueiEtTxTk=; b=VGyD6m1Qv0iO0X5AEHFwJZ0E6vuKhtclAopGpNwwnss69Rt8veEbENhLb5TfhPA5V6 jgXgNPKjlv20KmSfHLqxOOp4/KCUb3QrVjV7CoFTYFW/TJKCLfbf/4CCzdHy3ZYhSb92 9mKrgMBfJCYm98kmf4Rr0VHFEmTaTZDyZbAB7woUmADnprx7tLm03iihvk90k+rTH2Xi QTL/l1U0rK7loGuNsHfETIgbGaLKhndlEpEQ4TPl48ujBcG66RZGIIoK1juo+4mCrYwf 3qdeFxNkv7QxrNY3b/tjNlj6ADYMPGucgt67hliiD1/IKwYsTROzHlk3AJbPShbMv15e t4Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fEnLiF31; 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 b4si14042153pgk.350.2018.12.12.02.57.53; Wed, 12 Dec 2018 02:57:53 -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=fEnLiF31; 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 S1727266AbeLLK5v (ORCPT + 31 others); Wed, 12 Dec 2018 05:57:51 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45287 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726842AbeLLK5u (ORCPT ); Wed, 12 Dec 2018 05:57:50 -0500 Received: by mail-pl1-f196.google.com with SMTP id a14so8434817plm.12 for ; Wed, 12 Dec 2018 02:57:50 -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=a5kLi4xuwk7dpMQcurWuHvhYASg5acLmavueiEtTxTk=; b=fEnLiF31ENthjSEay6GYdC4yQO4wtTnRTh0ZrBobbwmNGml2sASHWOMsN43O5t4bQ0 FU/o2D4z0RGFUZozFNk2gIMWbECLMXgRaO9jK6mCiQhW4Jyfd10gVeVKx8gKe8jrniBe UBnsXVP5+R19EZ9szMeWR3kw5gJiWfEx86Gco= 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=a5kLi4xuwk7dpMQcurWuHvhYASg5acLmavueiEtTxTk=; b=f8jiR3gThGxVEr77mn/uWGGv416VS0L54yTOmApoykw+PSqN6HzU3izfgFMK1ZO8gp SCuCBtAiXxxH3bA6+nbzUqXBU2kg4jsiA1FyXrYamYNdS/7/c1YIHXdUIAh3NhMySbun Yn0Yny+RFDBQ2WNBdIyTi/N9FJmmVutcGhaISkE1MJPqiOotFfwyb1H4TcnBzJ9pb5on 3bg/r60b53PYKiFobAtqLbWwOXVfErGSMIU17NCKceC2I8NnqsyB14sVS8bQgSbFZ/L3 uqQzozgkDGGZyR5yJousPo0OrooI28mS2r8MVG9swzNlPjYqGSpvdRNjh/pNZ2QYTOLd jXKQ== X-Gm-Message-State: AA+aEWY367WYhqTttxPi2GiAsV8GvHU8QJaPWql5hvWJhWiFb2YjzY2K dDYSJ3dvuXZFbgsyf+mY/J79WQ== X-Received: by 2002:a17:902:1682:: with SMTP id h2mr19339386plh.243.1544612269932; Wed, 12 Dec 2018 02:57:49 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id u8sm23413177pfl.16.2018.12.12.02.57.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 02:57:49 -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 1/6] PM / Domains: Make genpd performance states orthogonal to the idlestates Date: Wed, 12 Dec 2018 16:27:24 +0530 Message-Id: <48a7fc66faec9ac5c157b0cadcdaeb07bfe78781.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 From: Ulf Hansson 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. Tested-by: Rajendra Nayak Acked-by: Viresh Kumar Signed-off-by: Ulf Hansson Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 8e554e6a82a2..4a4e39d12354 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; From patchwork Wed Dec 12 10:57:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153570 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1679425ljp; Wed, 12 Dec 2018 02:57:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/WNmppfKnePL9iqTLEOVJfl9ivXCdU/gchvq5QNNh6D30nL/SR0v/zlfX66lZrMDLwR+N29 X-Received: by 2002:a17:902:541:: with SMTP id 59mr19769489plf.88.1544612275383; Wed, 12 Dec 2018 02:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544612275; cv=none; d=google.com; s=arc-20160816; b=JAboJkeQWnsP8+ed/V2FrGT1uo3wWDtsZ4lPNmm9avSrHwpAx4fGlzqoon/gWhGpX8 /17TAqOsjM8QNhx/qbsyemi1b4vW527Yes7AIHh3DlZy0V65qJQBzsxNwyht21xY+C10 eVL/qFtG+yf0Ro3X/J36bpkAlw6vYUkYGdjeO+5iZg16KgVHZ9LPjkgl7VfX+l0En1b2 +r/qenSSTnlE7MWu0FdU5i7J9mQcmUPbr0aj8Cs09Cn+37gI33qxOXcYcNKEOzNEAkSs 5T/Xg4EamN/2E7Eizcy3LVMLcnLYgY3dwolYtRrveUPwp13pH39cSXBp/uxuq6EZjvHf bkoQ== 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=2LwDno6pPq3+62WWHDum9qZ80rXO5n5aGPdUmxZHq/s=; b=WxhnvCsJoZeBshWhZfwEKhkSRqhVdhq3KJ/71artWzr14g8ySOpp0BzN5YNCo2W9se m1bJFjoShbQg1l0ALo2K1RMXTzpDczzoI3kJeUGuDmnpH3vv1o5D9SHM6U0vEGQiGGdT Od/fipgUL/a+QHq0p/Ofya0su4Wj0bTP+v/R5OxMKsrQFp16Japud2vo/IkhSRmevOMH xe9qJVZQO09uy8881Ma3O+pCZlAqvEicvidRtN/zkKcZzvZgX3XhOo1+pXThvLFWxZp3 BdHJdMQj0k2yOt7Wpr9Y56ts/LoboW1ukRKheOG07XUZZWxK5/7xGd6OWSvTZzE2qop9 po2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="cp/5Dlox"; 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 b4si14042153pgk.350.2018.12.12.02.57.55; Wed, 12 Dec 2018 02:57:55 -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="cp/5Dlox"; 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 S1727283AbeLLK5y (ORCPT + 31 others); Wed, 12 Dec 2018 05:57:54 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35244 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbeLLK5x (ORCPT ); Wed, 12 Dec 2018 05:57:53 -0500 Received: by mail-pf1-f193.google.com with SMTP id z9so8712279pfi.2 for ; Wed, 12 Dec 2018 02:57:53 -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=2LwDno6pPq3+62WWHDum9qZ80rXO5n5aGPdUmxZHq/s=; b=cp/5DloxzSyYYKEYpPoupB7nKkWCn4Y797pFKu1xK54mYGiDFdvKKl5Mc6insysd36 dQIJINwWf2ynGwlxCPYmYwBERSB8Z1gGGj1N3qcA3KYKgNFYtEd5HbhuxjvLuZRdswVR WaWiqyaUOC+dzreOlCz1L92A1pAlDQvAHmFMk= 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=2LwDno6pPq3+62WWHDum9qZ80rXO5n5aGPdUmxZHq/s=; b=XSz/of3QCWfiMWvco9tmGGIv+zhbyALumUl/Hl53NMOrkHhRausZja3DI6JlzrO7mT cxYH7u+0OHfVfvlLGVyptwsNF3N2fuxi/ACNvDTNVY+DXb6yxFCgXXRc4AheP98R6vOk mH3EFDXxN9TBDY3ez+jpFNPB6Hvqji9+hi8SpRw72jTtBhnKv/gui7pU+5SyzGtZ7ZwJ 7gVd3Ozt/pflmW5Np5WyUF8EdMcCypMJozMa0WrpG4tIPjgGGJ0O5O4HByWPwXSiFp4l bYDlXFkNqYrLcjrC/i0WzMAMyjNm8Lpc7Lu+e9/y6rsoLP0U1a8CdxqY/VMhhVROf1Zj yIOA== X-Gm-Message-State: AA+aEWYITSsR1Bkv3V/95FUzB8J3L8SMwPPbi0cGZKEVlSjoR6bj/+o0 2IHclGzejNRltFaUbubqlrHD/A== X-Received: by 2002:a63:7c13:: with SMTP id x19mr17597162pgc.45.1544612272831; Wed, 12 Dec 2018 02:57:52 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id 4sm38982244pfq.10.2018.12.12.02.57.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 02:57:52 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 2/6] OPP: Improve _find_table_of_opp_np() Date: Wed, 12 Dec 2018 16:27:25 +0530 Message-Id: <184bbc28f982752cc040f0b9286516c3897e2808.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 Make _find_table_of_opp_np() more efficient by using of_get_parent() to find the parent OPP table node. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 3ef7f38c0986..8e57d257be77 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -114,19 +114,25 @@ static struct device_node *of_parse_required_opp(struct device_node *np, static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np) { struct opp_table *opp_table; - struct dev_pm_opp *opp; + struct device_node *opp_table_np; lockdep_assert_held(&opp_table_lock); + opp_table_np = of_get_parent(opp_np); + if (!opp_table_np) + goto err; + + /* It is safe to put the node now as all we need now is its address */ + of_node_put(opp_table_np); + list_for_each_entry(opp_table, &opp_tables, node) { - opp = _find_opp_of_np(opp_table, opp_np); - if (opp) { - dev_pm_opp_put(opp); + if (opp_table_np == opp_table->np) { _get_opp_table_kref(opp_table); return opp_table; } } +err: return ERR_PTR(-ENODEV); } From patchwork Wed Dec 12 10:57:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153571 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1679500ljp; Wed, 12 Dec 2018 02:58:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/WiFgw//Uvd0Cmfw4RK1yFguHE7N4JGYq9QzDSELY7umGybtAZTbzubJc2ireYzEkAA0l7K X-Received: by 2002:a17:902:d202:: with SMTP id t2mr19724490ply.193.1544612281227; Wed, 12 Dec 2018 02:58:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544612281; cv=none; d=google.com; s=arc-20160816; b=cw2KvVpIdxmVVRcCdjwMXlu1cwsfS1utybR1glfqOdPGugDRODQv4ntF06OkZR0KTa Ba/jD3DzypfbYUIOereMDQVmNkBCpCmBfmR4256FUWrWwBnewoiL7pnl9JMnC96BoWom 1uWyKg4Jx2uPTXKiB/p9pIEJ1WRBbf/E0SZxF6CO4nOpSQXvC/UIK+dmg+LHZzHZSvYe j2c4biLrm/vW5u6fLV6ma9RurcLafKIrr1Cc2jKxNXUiqy+Pc7pW7lPH/MXVJ5sS9wHC ySgkjIMd70Sfqbfz0tvvUwJbOy/w2A1bNZIv6LDUHX7ufo1AXWuR0rYt5paSa9An/Asi AFYA== 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=AJkZNwTNld7Hpxnxwr+8YYYZfRYJuI5JuELm3hvUKug=; b=Dhfb2LYvF3ViYkGTG1f4vKpx5KvVEwd4esOzwMzdhA+VbvDtehr3yG7rMrS8vlSrdD QBdGONZj6ahs/V2JAiV3xb5h50SURp0ivUWVMB/Q1sLwiJICjbblFZmPU0SOmsYG7ZLZ f1mNXmL6LLrPsa6eCWs7X4VCAJDrhOARnvRPTTMkbYGiCqtJWbPZY7pHgbHhzvsFAQYU Ap8+yPjOB0B4nfFUBHaOkKmdhkLcmy62Eh7SNMgTnY6aVhY8O5W4+DNrPZI852CakMBQ IbrVCDSfCKYZSnfVzBqH5p6SFfsmCSROz5GkMRrlhedv42CS8Ji2wlS62IS2fBetZ+7s RTCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zse5bIBP; 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 q127si16383713pfq.19.2018.12.12.02.58.00; Wed, 12 Dec 2018 02:58:01 -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=Zse5bIBP; 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 S1727301AbeLLK56 (ORCPT + 31 others); Wed, 12 Dec 2018 05:57:58 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35249 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbeLLK55 (ORCPT ); Wed, 12 Dec 2018 05:57:57 -0500 Received: by mail-pf1-f195.google.com with SMTP id z9so8712346pfi.2 for ; Wed, 12 Dec 2018 02:57: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=AJkZNwTNld7Hpxnxwr+8YYYZfRYJuI5JuELm3hvUKug=; b=Zse5bIBPWkBFc0yO+2qjktnsKSHuh/M57oSFih7IYz06V4bnmlKgxbkdAi8rlVEr3f FPT0KcD1QTX0iNyN2ZBYDuL5cKzsi8FIRA3X2TJOHK1LBjgDa2kJrO9BsCMryw9tc8zJ z8SMX9FtHUhd95TveNOfmPBavHHE2iKG9Bsew= 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=AJkZNwTNld7Hpxnxwr+8YYYZfRYJuI5JuELm3hvUKug=; b=jMTnaun06Tn2Bg8XQ5BiSR97BESrde601tY44Uer9pHbEkCY1/L/oyQQv0TLhepdvf kew+R9HP5n3IAVx/bOzjQ3IeI6M9v0J4t0Q02j6xJEtv+D52TAaWaWryPKy7hjMpDJ/N 5wsIu6uYFdnNh3W3mqEH8E7KOAAwgWhEFNrkeM+THl7Q8Ce8wzFwXJAudRgRvasBm8cw 8layyJXFZ9xLhrU44Kl+EYygy8m6m2qW8c737eauC0TbEdDjkYTlcHCevjqzmo+DVfzZ cXabM1d9Eite0Z2H7K59mZw9elktTzvgBwVjQPxqW7TsVRhYNig7fgOtN8rYWdtb+cOd kmSQ== X-Gm-Message-State: AA+aEWbzr0V4dNvwL99f3bWHjK8gZkBBSt6ex2tJXNUvVLmT0p6HavzX Qo2l6bPJ5MJhVp1pwPfdsLZflg== X-Received: by 2002:a63:2744:: with SMTP id n65mr17720584pgn.65.1544612276357; Wed, 12 Dec 2018 02:57:56 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id 84sm40430253pfk.134.2018.12.12.02.57.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 02:57:55 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 3/6] OPP: Add dev_pm_opp_xlate_performance_state() helper Date: Wed, 12 Dec 2018 16:27:26 +0530 Message-Id: <6ea171c4f791aae3281e49077893f76ad4c55677.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 dev_pm_genpd_set_performance_state() needs to handle performance state propagation going forward. Currently this routine only gets the required performance state of the device's genpd as an argument, but it doesn't know how to translate that to master genpd(s) of the device's genpd. Introduce a new helper dev_pm_opp_xlate_performance_state() which will be used to translate from performance state of a device (or genpd sub-domain) to another device (or master genpd). Normally the src_table (of genpd sub-domain) will have the "required_opps" property set to point to one of the OPPs in the dst_table (of master genpd), but in some cases the genpd and its master have one to one mapping of performance states and so none of them have the "required-opps" property set. Return the performance state of the src_table as it is in such cases. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 59 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++ 2 files changed, 66 insertions(+) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 98e60f0ed8b0..386095e2f4f7 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1713,6 +1713,65 @@ void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, dev_err(virt_dev, "Failed to find required device entry\n"); } +/** + * dev_pm_opp_xlate_performance_state() - Find required OPP's pstate for src_table. + * @src_table: OPP table which has dst_table as one of its required OPP table. + * @dst_table: Required OPP table of the src_table. + * @pstate: Current performance state of the src_table. + * + * This Returns pstate of the OPP (present in @dst_table) pointed out by the + * "required-opps" property of the OPP (present in @src_table) which has + * performance state set to @pstate. + * + * Return: Positive performance state on success, otherwise 0 on errors. + */ +unsigned int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, + struct opp_table *dst_table, + unsigned int pstate) +{ + struct dev_pm_opp *opp; + unsigned int dest_pstate = 0; + int i; + + /* + * Normally the src_table will have the "required_opps" property set to + * point to one of the OPPs in the dst_table, but in some cases the + * genpd and its master have one to one mapping of performance states + * and so none of them have the "required-opps" property set. Return the + * pstate of the src_table as it is in such cases. + */ + if (!src_table->required_opp_count) + return pstate; + + for (i = 0; i < src_table->required_opp_count; i++) { + if (src_table->required_opp_tables[i]->np == dst_table->np) + break; + } + + if (unlikely(i == src_table->required_opp_count)) { + pr_err("%s: Couldn't find matching OPP table (%p: %p)\n", + __func__, src_table, dst_table); + return 0; + } + + mutex_lock(&src_table->lock); + + list_for_each_entry(opp, &src_table->opp_list, node) { + if (opp->pstate == pstate) { + dest_pstate = opp->required_opps[i]->pstate; + goto unlock; + } + } + + pr_err("%s: Couldn't find matching OPP (%p: %p)\n", __func__, src_table, + dst_table); + +unlock: + mutex_unlock(&src_table->lock); + + return dest_pstate; +} + /** * dev_pm_opp_add() - Add an OPP table from a table definitions * @dev: device for which we do this operation diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2b2c3fd985ab..5a64a81a1789 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -128,6 +128,7 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*s void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev, struct device *virt_dev, int index); void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev); +unsigned int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); @@ -280,6 +281,12 @@ static inline struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev } static inline void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev) {} + +static inline unsigned int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) +{ + return 0; +} + static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) { return -ENOTSUPP; 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; From patchwork Wed Dec 12 10:57:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153574 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1679634ljp; Wed, 12 Dec 2018 02:58:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/UPeNu8+anRCBG5JyXVtfz3tT533d/mLhkWtfaeEdIrF1F8fvaiH06i1l9z8FfpEXL8VOzf X-Received: by 2002:a17:902:22f:: with SMTP id 44mr19293330plc.137.1544612291459; Wed, 12 Dec 2018 02:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544612291; cv=none; d=google.com; s=arc-20160816; b=of2ky1Q/1YJtKIES4Dc3nK2WT0rc2Tq6+dDiPDHJlj1G1sabjE/QHbD7o4uMKrZYYl 1PO7o5BSTyhE09Q2k4mcnTcZD6w7eCa5tH3VyEYMQe5zUbTlU8109KZYJQpp5zcYvIIQ J24lFsPOteU5GLKGkLocPT7W64jyBhb/PNiKqC1JLUi3Kf9vkF5QONA7oeVnGQ8y/eOF asmI7dxARBdT3g2KxBTH7OM+FkmcvzrleG68esDcB8LINiV53/HFqizn/8AXsDb3l/HI VaL3LpeO74qfvuCne8xhsc9FT4epLEVjYtcpCrTAB40GOh8oby3mypSslERKuA4LREL0 Xx7A== 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=o6OdClubF4RfL9e05GmhHLx7Ei4hstJaBiTl97uuPI8=; b=jS6gTUiZihEdMyt7tZTe7+YMCryzNhXOvzIh4nwgfA5Us1HnU9hm0xzOuj9WLpEPy+ /URYSB7FNx1psNhATvfBvucKZLbvZVRhXiL7K/LjUfA2M8B0g/5+M+0/mDpb7lKA0YJO ex2oFvdu5u2f2OtKjiyX43ggXwLunWVJqtdtkLtBx6qMpoO8ePz37g5QNbGo2ssE6DIZ S6HHACP9JV7MBPnqrfDXvKdX9fNfNU+ZHC26CDz9SPJH9GftiWBzcBYgenyvgmBEfkgN 6A/TCRdCEFl4ZbGieidbxZqPkJVgI9rP/4Ix4p0AaO5moNNDdIcYhM0i243kg2baa3FJ Iulg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h+iqgxNa; 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 n67si15450072pfk.34.2018.12.12.02.58.11; Wed, 12 Dec 2018 02:58:11 -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=h+iqgxNa; 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 S1727347AbeLLK6J (ORCPT + 31 others); Wed, 12 Dec 2018 05:58:09 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34136 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727302AbeLLK6G (ORCPT ); Wed, 12 Dec 2018 05:58:06 -0500 Received: by mail-pl1-f194.google.com with SMTP id w4so8456103plz.1 for ; Wed, 12 Dec 2018 02:58:06 -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=o6OdClubF4RfL9e05GmhHLx7Ei4hstJaBiTl97uuPI8=; b=h+iqgxNa/x6wXA7miuOUX5zrFMVjNFZHOu6qUD0o9RpqbtK3QJ9oiEDppegHtytORq +BGsVThazgEY3qtWaySy/zDbYm19yrGzsdaGz9FLAVUr7yr4kDHkxsnrbkFw37ugvk2i /uLGZPIpanZscY37gu7l2Hcdh8uxyXQ9tOSc4= 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=o6OdClubF4RfL9e05GmhHLx7Ei4hstJaBiTl97uuPI8=; b=DArA1Dkm1DHya4qdfmOrcixbFKS/13UVHWsarZUIW2Cawhx8EcKhABDe8N+fJDE2zR bMqssk1DeOP/27Cf2kzZOnGJtQznaU1qxoywGMxdUY8Vz0b9OFTDK6RFgm/Jv9bVksji rs36iWKmKf+7B++8FHcdHU5ADn4FLyhHr3DxEocXsmUIjLyPYXOAWjwr9Uy5QohYjXba P5Kfq+vLekVvc0HqJbY7nDDSENQW0Z8VNQHEbr9NbMUeRLRUjro7M/89aNGbVakMIWW/ v0ALi+xQxXQJxsEY6p6pUmrAn5ePM6VR77B5pmsnQk+cDOx3h8tJ8kMgowzGoAC/Rqrf eFFQ== X-Gm-Message-State: AA+aEWZCpRK+O8GKLipl/EOEMYT9Zs86yzw1a/f4PYaEdGuDqalukinZ wSpVBUC8XC33r/+5C6IMNO1EqA== X-Received: by 2002:a17:902:2aaa:: with SMTP id j39mr19893330plb.335.1544612286046; Wed, 12 Dec 2018 02:58:06 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id 69sm31751751pgg.86.2018.12.12.02.58.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 02:58:05 -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 6/6] PM / Domains: Propagate performance state updates Date: Wed, 12 Dec 2018 16:27:29 +0530 Message-Id: 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 This commit updates genpd core to start propagating performance state updates to master domains that have their set_performance_state() callback set. Currently a genpd only handles the performance state requirements from the devices under its control. This commit extends that to also handle the performance state requirement(s) put on the master genpd by its sub-domains. There is a separate value required for each master that the genpd has and so a new field is added to the struct gpd_link (link->performance_state), which represents the link between a genpd and its master. The struct gpd_link also got another field prev_performance_state, which is used by genpd core as a temporary variable during transitions. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 105 ++++++++++++++++++++++++++++++------ include/linux/pm_domain.h | 4 ++ 2 files changed, 94 insertions(+), 15 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 32ecbefbd191..5e0479b2e976 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,24 +239,90 @@ 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, int depth); + static int _genpd_set_performance_state(struct generic_pm_domain *genpd, - unsigned int state) + unsigned int state, int depth) { + struct generic_pm_domain *master; + struct gpd_link *link; + unsigned int master_state; int ret; + /* Propagate to masters of genpd */ + list_for_each_entry(link, &genpd->slave_links, slave_node) { + master = link->master; + + if (!master->set_performance_state) + continue; + + if (unlikely(!state)) { + master_state = 0; + } else { + /* Find master's performance state */ + master_state = dev_pm_opp_xlate_performance_state(genpd->opp_table, + master->opp_table, state); + if (unlikely(!master_state)) { + ret = -EINVAL; + goto err; + } + } + + genpd_lock_nested(master, depth + 1); + + link->prev_performance_state = link->performance_state; + link->performance_state = master_state; + ret = _genpd_reeval_performance_state(master, master_state, + depth + 1); + if (ret) + link->performance_state = link->prev_performance_state; + + genpd_unlock(master); + + if (ret) + goto err; + } + ret = genpd->set_performance_state(genpd, state); if (ret) - return ret; + goto err; genpd->performance_state = state; return 0; + +err: + /* Encountered an error, lets rollback */ + list_for_each_entry_continue_reverse(link, &genpd->slave_links, + slave_node) { + master = link->master; + + if (!master->set_performance_state) + continue; + + genpd_lock_nested(master, depth + 1); + + master_state = link->prev_performance_state; + link->performance_state = master_state; + + if (_genpd_reeval_performance_state(master, master_state, + depth + 1)) { + pr_err("%s: Failed to roll back to %d performance state\n", + master->name, master_state); + } + + genpd_unlock(master); + } + + return ret; } static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, - unsigned int state) + unsigned int state, int depth) { struct generic_pm_domain_data *pd_data; struct pm_domain_data *pdd; + struct gpd_link *link; /* New requested state is same as Max requested state */ if (state == genpd->performance_state) @@ -274,21 +340,30 @@ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, 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. + * Traverse all sub-domains within the domain. This can be + * done without any additional locking as the link->performance_state + * field is protected by the master genpd->lock, which is already taken. + * + * Also note that link->performance_state (subdomain's performance state + * requirement to master domain) is different from + * link->slave->performance_state (current performance state requirement + * of the devices/sub-domains of the subdomain) and so can have a + * different value. + * + * Note that we also take vote from powered-off sub-domains into account + * as the same is done for devices right now. */ + list_for_each_entry(link, &genpd->master_links, master_node) { + if (link->performance_state > state) + state = link->performance_state; + } + + if (state == genpd->performance_state) + return 0; update_state: - return _genpd_set_performance_state(genpd, state); + return _genpd_set_performance_state(genpd, state, depth); } /** @@ -332,7 +407,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) prev = gpd_data->performance_state; gpd_data->performance_state = state; - ret = _genpd_reeval_performance_state(genpd, state); + ret = _genpd_reeval_performance_state(genpd, state, 0); if (ret) gpd_data->performance_state = prev; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 9ad101362aef..dd364abb649a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -136,6 +136,10 @@ struct gpd_link { struct list_head master_node; struct generic_pm_domain *slave; struct list_head slave_node; + + /* Sub-domain's per-master domain performance state */ + unsigned int performance_state; + unsigned int prev_performance_state; }; struct gpd_timing_data {