From patchwork Fri Dec 14 10:15:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153804 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881690ljp; Fri, 14 Dec 2018 02:15:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/WJHPPt/+ZArnILRNQIBvZEW04PKAf7XrE7LYGgR1EOawP4EEqi5yeqGeiRIhoy6SkZxk8w X-Received: by 2002:a63:2b01:: with SMTP id r1mr2144361pgr.432.1544782545895; Fri, 14 Dec 2018 02:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782545; cv=none; d=google.com; s=arc-20160816; b=wNHxwiKpgKrCrYxlCQLtmSoRcNu3/FloWTbMNHuj/qKISOipqA4vZ3+zH/HoTcXtqa RRLdYG4mjooyXUuSD88Jywog2j7Jom/FI8ltdtyogu2Zh+tWg0EoSsFwHCnD/IkD6Nql MKe6W5BUaDIyzu7lcvxGOejkbZ+7EC+jV6eifYQ9ry9rJpp1tJbHGg9itpKxro/MDnkx bcr2FCNQgCvvFeJr0A3hfFdSnMfIu7H8aDX0rHZ85AfCB2zBwF8EbK2KQElzzrim/6Oa rSs+fWc7zxjsSVzocXdmp0VWyfZSOkV7qVFKQDks9B1CBDDpW0oIver+NHUbhV+YSaIO 5vGQ== 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=NQQ8+qTBYTN7MwFFezSvMdLptkcV2B586qQZHdT6CL1d3vA5gJwSfTyo4WLuOBt8Ja ipqeWLhFx6yg6j7IaxDtqxdc4+hH7mrK2zRIbp0F/EuspEiWihWpMCdgUk+/IP/hJYjy zZH2uiWJeW22wYAUDpVh/z45Wo/EPXlq0TkZob/pt3j3RoCjEEW4HRcd1yuV+ZdOGxBS cff5UQpglnS7B1ZYgzYIS1aMkUVefhmCnvusdQ/gDfX6WuxTNaDUtd8YDHhdiYhcRyWM +lc7S8LzsmhqqJrb6WviuctLxlSgS8NxpIImIQlrSb8sqxuAbXDn6UKZ7t/rcuDHAYfZ B3Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HQrMDzUq; 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 z4si3660084pgl.16.2018.12.14.02.15.45; Fri, 14 Dec 2018 02:15:45 -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=HQrMDzUq; 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 S1729486AbeLNKPo (ORCPT + 31 others); Fri, 14 Dec 2018 05:15:44 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35170 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728829AbeLNKPm (ORCPT ); Fri, 14 Dec 2018 05:15:42 -0500 Received: by mail-pl1-f195.google.com with SMTP id p8so2541962plo.2 for ; Fri, 14 Dec 2018 02:15:42 -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=HQrMDzUqh3MUYQIsDHDucLjzhFpViI0N/rtfVw4d1bhzFgHCKawj+qxQCgLU/kTnPM Iagdiv7rUyhq4WsM3jCFOcO4FGkEdyRWtKoUXL9p/Fvq7f2PLGQSqdoe+w3qAOJpvduE bEKyAoYUWI8pFOLmUCpZZV/d87yuWc6Izqo4Q= 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=A+fEVWNOIrBHR2c9eyNO1XyNQV9Hgg/YDZpcQHQZh+wLTaqGN+y2aLuoCoeJbBKqHI Uddvtiu88wbEQIk/VH9OarH7MkilO1ZYnPLdUSPsDpRL4w2dluPUhU2ezntqx1lpz7yh ufvwbVtMPN9kIF6/ZbrQuv00kbdHisywMAA98s0P+k79uFhBSRhCPJk0A68zYQb6benG px8Bx/UO1fb5uJNgilFrTMRprgz8ES0kMtwIP2zQ8NLGOheP7Vz+gltITMmaTCVvBxOW BpXPivsnbpCwf1WLSg8VEXsrSPc5Ul+HsDWmBqbJOJAwlb9ZPi17wvV9bn9w3bQUO9H0 K0vQ== X-Gm-Message-State: AA+aEWYhXWbG+0GHipVqSUsFBVNRKxASODC5utlKE3H2qa0DBVkYKg++ piBGkegfi3Yvo2+CZigeaRH11A== X-Received: by 2002:a17:902:bb98:: with SMTP id m24mr2237750pls.71.1544782541779; Fri, 14 Dec 2018 02:15:41 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id p24sm6290090pfk.155.2018.12.14.02.15.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:41 -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 1/7] PM / Domains: Make genpd performance states orthogonal to the idlestates Date: Fri, 14 Dec 2018 15:45:27 +0530 Message-Id: <48a7fc66faec9ac5c157b0cadcdaeb07bfe78781.1544782279.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 Fri Dec 14 10:15:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153807 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881841ljp; Fri, 14 Dec 2018 02:15:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xpsb194YZb+mUc/WBXNDUVQqaZFvOHYjRn15IgWS/qK99RflB1Ig81HzpDTN4t2dPbG3k7 X-Received: by 2002:a62:5c41:: with SMTP id q62mr2283360pfb.171.1544782556453; Fri, 14 Dec 2018 02:15:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782556; cv=none; d=google.com; s=arc-20160816; b=SwDrw+iksjxevoOiS0hLLD3byRmIYjIXafLqfCqnMDyTe9yYRpdwshrHXvabeCLpFp J4qdh7HenqnrT+ABiE/KM5RILCa2d536CSlO9ou86vezrb8PJTvU1nosTSjlYuuY4cGb HXPdXkdBY6tPep43QJmfbJSMrBHB/fNaeDx8nn1QcSKsdpOVy1lKN6g12RF92PBkBy1d pO/RhqrUuaOHbBrFvEpP+QgdUF3Mow5oSywX2U+HanQ8/g+vIcEnsJmga/nSImC0nmGT ox/b/DbuVXtReb3W5DNomxItsvXKR15v/5pymC0PfAV1jvx1+3UJ2WeYiSHdXF7UszrK jDKg== 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=xyjawys4UfIoyfyJqxfe5ExEUR+bqqWyP70n7MDXOvA=; b=INGMn1GLiXdrBA9eNiiifV0Zp7P6UqBd6xybYRLKzDK7rjTwm2FFIZm13VL7V6+tdk MWdGGaww97brbzxwnjJyi6JsF9TetNtUJ6SpDSajm0CaSUMv9KJR6KZvoyLGakSEonR7 LHFPX/DqgTN9AQPRgXwk8nOt/fk0IAWHOyRbLN3Wc1EZebomxwnGcmuHlIxQd7H7ARl9 fxK/SxzKwGcIOkN24F31umIsCJf3ZGCOmG09BuvHTX9KeeoKjOe8Uh205Tum5trmY6WR A9fNE1vDAggg8BsqbnjRJwbf8/PvtFa4C5RIU758taa5oU1lgOQL8uEAolkCk6rrOlzO FsfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=khDtGEfV; 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 184si3729638pgj.329.2018.12.14.02.15.56; Fri, 14 Dec 2018 02:15:56 -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=khDtGEfV; 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 S1729600AbeLNKPy (ORCPT + 31 others); Fri, 14 Dec 2018 05:15:54 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40695 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729554AbeLNKPv (ORCPT ); Fri, 14 Dec 2018 05:15:51 -0500 Received: by mail-pf1-f196.google.com with SMTP id i12so2619742pfo.7 for ; Fri, 14 Dec 2018 02:15: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=xyjawys4UfIoyfyJqxfe5ExEUR+bqqWyP70n7MDXOvA=; b=khDtGEfVB/sQdSXhCsKW1uxgppS0APiKDXcuRJvBpegeebjDiue+kswR4jYdpva13/ wGzp8Dvnkmt97N42PG3bc3VO+Tsuwol5McAJ/ACOsWIKWn49t37WATWrR1A1qyrB1fkE 1plqUL7bHf9qHgCAd/+gDA7bzi+UhVLxMULLE= 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=xyjawys4UfIoyfyJqxfe5ExEUR+bqqWyP70n7MDXOvA=; b=P4iBk1t1EfMv+mjB4oukUNVSDHy9BUeomq5sGU04vyniWu4ycf1SM2BfenbtnDJYmO qvbBFds+S46dV6eI0QllxdbL9msqsujw5mgGOTD3NhGfUddmfWnbjGc/T7MIsCRLHwfh 8WONizSU+l0zDnwZtkqy/S8LBwEkFBDrJqBE0bHM0y2XrRT3caVEQZkOI+/RY18fYvP0 Jnv/yhVU/6FW6N/t4C3BCcgTKB8xepkpN34AVFwzTiw6uqzn7y+cbkpo21Na7e+tLbto g+DeKg/mRzEUmDe2k2lCyMyEculL//Stdb0xWhZlp4549xcFv4+Q4OOiMGHJRSj0QcBX egiA== X-Gm-Message-State: AA+aEWasYxKgql/yfpO7p3l5ohSEBL+4p5kWacNGKVG5YK7fiolgRUyy JZbN5wZkEIHF2qJPgaW4gMlLfw== X-Received: by 2002:a62:a510:: with SMTP id v16mr2276882pfm.18.1544782550346; Fri, 14 Dec 2018 02:15:50 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id u87sm10663737pfi.2.2018.12.14.02.15.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:49 -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 V4 4/7] OPP: Don't return 0 on error from of_get_required_opp_performance_state() Date: Fri, 14 Dec 2018 15:45:30 +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 of_get_required_opp_performance_state() returns 0 on errors currently and a positive performance state otherwise. Since 0 is a valid performance state (representing off), it would be better if this routine returns negative values on error. That will also make it behave similar to dev_pm_opp_xlate_performance_state(), which also returns performance states and returns negative values on error. Change the return type of the function to "int" in order to return negative values. This doesn't have any users for now and so no other part of the kernel will be impacted with this change. Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 10 +++++----- include/linux/pm_opp.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) -- 2.19.1.568.g152ad8e3369a Reviewed-by: Ulf Hansson diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 8e57d257be77..68b512846d72 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -995,19 +995,19 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_sharing_cpus); * Returns the performance state of the OPP pointed out by the "required-opps" * property at @index in @np. * - * Return: Positive performance state on success, otherwise 0 on errors. + * Return: Zero or positive performance state on success, otherwise negative + * value on errors. */ -unsigned int of_get_required_opp_performance_state(struct device_node *np, - int index) +int of_get_required_opp_performance_state(struct device_node *np, int index) { struct dev_pm_opp *opp; struct device_node *required_np; struct opp_table *opp_table; - unsigned int pstate = 0; + int pstate = -EINVAL; required_np = of_parse_required_opp(np, index); if (!required_np) - return 0; + return -EINVAL; opp_table = _find_table_of_opp_np(required_np); if (IS_ERR(opp_table)) { diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 0b04c2093eb9..0a2a88e5a383 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -321,7 +321,7 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); -unsigned int of_get_required_opp_performance_state(struct device_node *np, int index); +int of_get_required_opp_performance_state(struct device_node *np, int index); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -360,9 +360,9 @@ static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) { return NULL; } -static inline unsigned int of_get_required_opp_performance_state(struct device_node *np, int index) +static inline int of_get_required_opp_performance_state(struct device_node *np, int index) { - return 0; + return -ENOTSUPP; } #endif From patchwork Fri Dec 14 10:15:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153808 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881873ljp; Fri, 14 Dec 2018 02:15:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1jVFzQKwf8uZQtD3lhFePQ8SvEFLd0Bm6/eCKF35ECNqiR/6sbixI7DCoYUbbasxiQJh5 X-Received: by 2002:a62:f54f:: with SMTP id n76mr2255138pfh.59.1544782559518; Fri, 14 Dec 2018 02:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782559; cv=none; d=google.com; s=arc-20160816; b=F83pbpLlb6dUyL+zoiQXgugMaFS+pg5UnY/T6TdtNujNexY4FOswfQTenDm9AhVZj6 JJtkfvPiWM3EA+3cMQR+HHJtcPTXO+vE/WhbDRpiPTx2C65v8YDL058sVHHhK5vqUa11 Y6+yBPdvD3J73VIcJTAVykeh/n8rEtrUUSVf7yk4WRv+cgqNSW4YMAYVAbXf0AcFnzXM yLd79eFDIr/Pst7MMdwkEWZscgKDz1sOqmHzB+SWVV7JkT6KFTB48bJEQXVWujnPo6QK bEQSA6a1qK6AAe7/p3q12J/Rwjqw2mHMY5KYZPDzShW8DGXMQYjk/mIw6yfVtYH5+Pzo iOYw== 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=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=k+q3LXH3CjWgakw/f+YYrq0Qe9WevdcYeHt4ahB0coVepVALesjxUuAyz97HkK3ZA0 km71xQZN70TYS67GnzQwxVsHuOJfsSRaaG3GgrusopXgfl/1NQyWm5lgeI05UURq9uKg x6p7rxvjJCx92zrUbdOzK//OnhFTtcSD5uvL9FrkYHCa0ojZMUf3P0o0f/v5neL9onjP Gf5MPZEKZFEotgB+8qpHpEXiGd5Zi1HSuyhkHUGKeKH7sf8hicqHaKQnAYYToJTG9BYt YO0KzH8sqo3ZeonS6YSrpbwBo+xrI3/w0YHu8ussgIPGZ5p76lIDGQDJB8/nmeYnlvwH qKMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jLZVNYXP; 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 r77si3710707pfa.186.2018.12.14.02.15.59; Fri, 14 Dec 2018 02:15:59 -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=jLZVNYXP; 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 S1729620AbeLNKP6 (ORCPT + 31 others); Fri, 14 Dec 2018 05:15:58 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34376 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729585AbeLNKPy (ORCPT ); Fri, 14 Dec 2018 05:15:54 -0500 Received: by mail-pf1-f193.google.com with SMTP id h3so2637398pfg.1 for ; Fri, 14 Dec 2018 02:15: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=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=jLZVNYXPI8sRndhzeySNVUXvkyvSG49GfBR/xdeF0n3/NHg6+M/EExbHnlCNgjqPz7 8hRFRtD9qzcoDO6pChiptapv7mwFljOBo3jh9X+o8n+yKKexkqvQ1MynFB4KGlY39doT T94oOcFY21nPgyZY/zFogY9VzEpRSYvuPabGc= 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=88unu+wr5jKW9r3TtHtSlTHkq7xupIQjYSmWeaTu8BE=; b=FGhuUK3IPmPLC9eVX49x3fnssT1KLnFtI15XkuRldlOJCoeMlGSrHTLNFQA16nezHk jmobp6jsu9ZIXwCiwjtKL6N4nDdrU+P92T7874zb4xIC//WJkntOBS52tK6nhJZ1gGMO NBX9Wv3zlXpa/eE3ivW0S0eTIY17uqgHPBLUDi03nDUJaVLbCxVYapX9QUFeeIUYGHGE B6DaHCuXTvE7I3a1fuEL8JfKBFEPEHrme0KUhjQI4Tnq218aeG69e8tel+A0GH0tEGeN GVECRZ7TSqbhF1+WRv71cBJgVIb2qyV7U3WLeXYV1D594zZMvj4Hoom9LRigANKCcujf asWQ== X-Gm-Message-State: AA+aEWZMIAjtf76gh/K0cxfs+tQVqXJDnoWrp3mX0LyS6ARUGamtzNtw HGp6zPV/ipJIRv145unbsDwnwA== X-Received: by 2002:a63:fd0a:: with SMTP id d10mr2208487pgh.164.1544782553378; Fri, 14 Dec 2018 02:15:53 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id t24sm5697214pfh.21.2018.12.14.02.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:52 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Len Brown , Pavel Machek 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 5/7] PM / Domains: Save OPP table pointer in genpd Date: Fri, 14 Dec 2018 15:45:31 +0530 Message-Id: <5603371d1ad204a7314a3618d362d583b555f6b6.1544782279.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() will be required to call dev_pm_opp_xlate_performance_state() going forward to translate from performance state of a sub-domain to performance state of its master. And dev_pm_opp_xlate_performance_state() needs pointers to the OPP tables of both genpd and its master. Lets fetch and save them while the OPP tables are added. Fetching the OPP tables should never fail as we just added the OPP tables and so add a WARN_ON() for such a bug instead of full error paths. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 23 +++++++++++++++++++++-- include/linux/pm_domain.h | 2 ++ 2 files changed, 23 insertions(+), 2 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 4a4e39d12354..1e98c637e069 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1896,12 +1896,21 @@ int of_genpd_add_provider_simple(struct device_node *np, ret); goto unlock; } + + /* + * Save table for faster processing while setting performance + * state. + */ + genpd->opp_table = dev_pm_opp_get_opp_table(&genpd->dev); + WARN_ON(!genpd->opp_table); } ret = genpd_add_provider(np, genpd_xlate_simple, genpd); if (ret) { - if (genpd->set_performance_state) + if (genpd->set_performance_state) { + dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); + } goto unlock; } @@ -1954,6 +1963,13 @@ int of_genpd_add_provider_onecell(struct device_node *np, i, ret); goto error; } + + /* + * Save table for faster processing while setting + * performance state. + */ + genpd->opp_table = dev_pm_opp_get_opp_table_indexed(&genpd->dev, i); + WARN_ON(!genpd->opp_table); } genpd->provider = &np->fwnode; @@ -1978,8 +1994,10 @@ int of_genpd_add_provider_onecell(struct device_node *np, genpd->provider = NULL; genpd->has_provider = false; - if (genpd->set_performance_state) + if (genpd->set_performance_state) { + dev_pm_opp_put_opp_table(genpd->opp_table); dev_pm_opp_of_remove_table(&genpd->dev); + } } mutex_unlock(&gpd_list_lock); @@ -2013,6 +2031,7 @@ void of_genpd_del_provider(struct device_node *np) if (!gpd->set_performance_state) continue; + dev_pm_opp_put_opp_table(gpd->opp_table); dev_pm_opp_of_remove_table(&gpd->dev); } } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 642036952553..9ad101362aef 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -73,6 +73,7 @@ struct genpd_power_state { struct genpd_lock_ops; struct dev_pm_opp; +struct opp_table; struct generic_pm_domain { struct device dev; @@ -94,6 +95,7 @@ struct generic_pm_domain { unsigned int performance_state; /* Aggregated max performance state */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); + struct opp_table *opp_table; /* OPP table of the genpd */ unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd, From patchwork Fri Dec 14 10:15:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153809 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881907ljp; Fri, 14 Dec 2018 02:16:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/V3B2ESIAJHoCjEqpF5fpH4EQP7e721rFy1iXnoZWtHPWvF953i6ThF9J2uRZQcV5AmsdEg X-Received: by 2002:a63:7d06:: with SMTP id y6mr2137136pgc.171.1544782563722; Fri, 14 Dec 2018 02:16:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782563; cv=none; d=google.com; s=arc-20160816; b=CJEN5OTpIKQicoqobyPF6sGfym1/2Y+EzUK9C7G0RUNdo6BW0mtOaDhvrmxp7JrM3i gLc8fiMk3pb7tO/RTyyH8RRgyS07ff2qkT1Tx97xFHOmfXYLbyuKOy5J+OrtJ7kd12vZ I3Rgg657US7dJzLHFZLn/f/Lqq34ovDvazFcd0zpIG58bwYp9Glh5d417lIixiUABjGM n46CNmuGfhTlo0jgMZk6ST6ZSMpGKqLtVvQaCykRs3WLo3fZko84epPgz2kZzPWb3UUL gbSjdVgcuIvdIetTFSwIN1J8jGlP9uFeWv16cnaHyrsyEujyGOsQQ0fUAM0fXwNJbeYc wb1g== 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=GuwS/J0VRMUUsTtu4AOCAiCLWgTA0AmO9JSD70SaiQk=; b=CAceHI37aWSuwsp1Hhh/67cMlWibYiFZyP9PbWBkFveWN6ad90LAR6gP4hhVMbXrvp kz/2rTNsoOY3rAfS6xl+58s+/XYf1W0oL3W8SmgXvsUD3VgckEu1PYck4nJYUrrKvcCL dqZz9+6NtcaZYa4rK0WPU8k2ki6we3OUjeHDvIwY7Pwd0hw1o8F2EiRVFH5e/rFozMbI IV+BeywPGKCIu8R+dPNRQt51G2CcQXPCDeRyPC2WbZe3Po6t5AnBJq9szP2mt/ffy66k AtcjVAyzcq1Xxc1X8ROZCrc86AJ2cPm2SzLXG4YJ7B7w7BynGfSlZY1pNdWpkaHmRvmo Mb2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VU1LNQg1; 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 r77si3710707pfa.186.2018.12.14.02.16.03; Fri, 14 Dec 2018 02:16:03 -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=VU1LNQg1; 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 S1729657AbeLNKQC (ORCPT + 31 others); Fri, 14 Dec 2018 05:16:02 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:32856 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729624AbeLNKP7 (ORCPT ); Fri, 14 Dec 2018 05:15:59 -0500 Received: by mail-pg1-f194.google.com with SMTP id z11so2516759pgu.0 for ; Fri, 14 Dec 2018 02:15:59 -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=GuwS/J0VRMUUsTtu4AOCAiCLWgTA0AmO9JSD70SaiQk=; b=VU1LNQg12XoWRQsPmxfL2kqW9a5aUSOuaM2mQcAPorUuaHGO6YvNZVCmjqU9i/eIIt fs03GzcarocK5NeZkre3RGce7WeMcgRK0kk7eibnfwWd94CwOM0f1wrqf7d+AERTsp20 9EoLFoKTwcEyNhvJThmwovtYTS3qutHGRdjTM= 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=GuwS/J0VRMUUsTtu4AOCAiCLWgTA0AmO9JSD70SaiQk=; b=EJ0BKhvesBgFFbLZ4hmMe9ksnf6wTnhe7+EYpr96v8zWDTauu/udctmBta8/T+E/2K F3cq3uVm8Fv6yF+atgAbb4c3D1sOg64Ja8q9HqFbgt30/eRavLRbjK7V9KlNPIRHArvM 9mwovIA4F54xqZMueAiaOsp4hOeaIpVr4QC44oytEcWylZLm3RHwU37vt1VkYRwzF6Pt 5D8mzA7wK4QKMVk17wFW3rrgkeHR+kFACuvxYuxhVCXcw7rZLljt/7VSmSW36EXtwxe8 EI7+gTq4oxzEtd/LgvSf7C7qFB6zVQopq1VCu2WkpsIZ+KgIm77YdBebO7rk75A9BiTg 1PMQ== X-Gm-Message-State: AA+aEWYKeKK2cXw9fnV4MII7Mkk4dz9V1HsRkSYV86IMJFyB5zvxgrIC Prnbp3j2b/VrfrGUOeX9fd/ik3Grb+A= X-Received: by 2002:a65:4142:: with SMTP id x2mr2117023pgp.356.1544782559125; Fri, 14 Dec 2018 02:15:59 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id b4sm4870265pgq.65.2018.12.14.02.15.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:58 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Len Brown , Pavel Machek 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 7/7] PM / Domains: Propagate performance state updates Date: Fri, 14 Dec 2018 15:45:33 +0530 Message-Id: <0c7ef1300e212f0ae06ccf10398f8c9453c064a5.1544782279.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 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. On a call to dev_pm_genpd_set_performance_state(), the genpd core first updates the performance state of the masters of the device's genpd and then updates the performance state of the genpd. The masters do the same and propagate performance state updates to their masters before updating their own. The performance state transition from genpd to its master is done with the help of dev_pm_opp_xlate_performance_state(), which looks at the OPP tables of both the domains to translate the state. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 93 ++++++++++++++++++++++++++++++++----- include/linux/pm_domain.h | 4 ++ 2 files changed, 86 insertions(+), 11 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 808ba41b6580..611c0ccbad5f 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -244,6 +244,7 @@ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, { 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) @@ -262,31 +263,101 @@ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, } /* - * 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; + } + return state; } static int _genpd_set_performance_state(struct generic_pm_domain *genpd, - unsigned int state) + unsigned int state, int depth) { - int ret; + struct generic_pm_domain *master; + struct gpd_link *link; + int master_state, ret; if (state == genpd->performance_state) return 0; + /* Propagate to masters of genpd */ + list_for_each_entry(link, &genpd->slave_links, slave_node) { + master = link->master; + + if (!master->set_performance_state) + continue; + + /* Find master's performance state */ + ret = dev_pm_opp_xlate_performance_state(genpd->opp_table, + master->opp_table, + state); + if (unlikely(ret < 0)) + goto err; + + master_state = ret; + + genpd_lock_nested(master, depth + 1); + + link->prev_performance_state = link->performance_state; + link->performance_state = master_state; + master_state = _genpd_reeval_performance_state(master, + master_state); + ret = _genpd_set_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; + + master_state = _genpd_reeval_performance_state(master, + master_state); + if (_genpd_set_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; } /** @@ -331,7 +402,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) gpd_data->performance_state = state; state = _genpd_reeval_performance_state(genpd, state); - ret = _genpd_set_performance_state(genpd, state); + ret = _genpd_set_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 {