From patchwork Wed Aug 2 10:12:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 109202 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp2590590qge; Wed, 2 Aug 2017 03:13:00 -0700 (PDT) X-Received: by 10.84.139.195 with SMTP id 61mr3104518plr.445.1501668780715; Wed, 02 Aug 2017 03:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501668780; cv=none; d=google.com; s=arc-20160816; b=u2DYk2YBWWW1oLxemptq5TPL19Hw/heO/HWx/yCLHnJtl/1JiUh9FE9CmBzFHH7Mnp tFJsW7jEsNjmIT3WpLNdaHt7prPlfA7IgUf05H3SYk+UvXfxC6igSfNVXEeoBBmT+E+l Qaah+539VdZvjLeo6SDQ/E7Udxg23VBcrnJLb2fwx4fmDweNiXyUDnFT5PMwfiwTsfCm z9VMGrDzc5+ky34Dh9xIs9c09WVLub+NIXMFt2Gh/q2r9JnsanTPwmps1jjJ3W3U5bp3 AnvpHTH8ebU05wWAQ0UhEfaSBbU67rKUyH32x9wtqgPtDgW3s3cloyWF4i7DRTuZQGuA Zh0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=WBUWgEGGVTFYaONG0MiR/7EKcbkcCHMjIM/+DeFBQAM=; b=ZZKlIqhxq/bAIHx9Hed0/o1PmVxfESAsYfH3BatMPr4VHWRdRn7gJOjw1bnIZQNUsQ VE3YqgQqOQPYfLPljHcDhoXEd5/0XzpdPBl48zd5BOkmgUwLTy0WXao/WIxg7hCJeRXL okF/m38bP1FfVyZchUefWp+4V+g/n8vBiRCuH+wIeDtAi6eLWE2rGfB1Vg/+TRMmrx1p Z0icWcjau/hWTjz/HBeff0oykktnztWD/0dJpG+TP7mH8p0zz/zqiLhVZsXxD/V7z+wA 6/aucKRD3fnWw9DjgegZLrVjVP5NLnxK/5Z/LB946a/3PXgFzmnaOPSCbgMuaZx92Jjz D54A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=kQSVLLo6; 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 x11si21418147plm.792.2017.08.02.03.13.00; Wed, 02 Aug 2017 03:13:00 -0700 (PDT) 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.b=kQSVLLo6; 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 S1752832AbdHBKM4 (ORCPT + 25 others); Wed, 2 Aug 2017 06:12:56 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:36185 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751991AbdHBKMv (ORCPT ); Wed, 2 Aug 2017 06:12:51 -0400 Received: by mail-pg0-f48.google.com with SMTP id v77so13742488pgb.3 for ; Wed, 02 Aug 2017 03:12:51 -0700 (PDT) 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 :in-reply-to:references; bh=WBUWgEGGVTFYaONG0MiR/7EKcbkcCHMjIM/+DeFBQAM=; b=kQSVLLo60hXIxt9Tr2yPz82R3myHORX0Fu0lNzRYQFquBVQBrt7+skzqPZoE5lt2KT FdLJgEwoz4brrsWkH0b7Nk9JZmO+LC0ABn7NvYelpE4o84BH8Z/taQ7jvYfGVyky12kh vs2bh0LU8ydATdZN+7/RrbR5bCy34BxCAmJPM= 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:in-reply-to:references; bh=WBUWgEGGVTFYaONG0MiR/7EKcbkcCHMjIM/+DeFBQAM=; b=Y2lBqlMeGPIg1hCXCwXfFRv0UvuyhPTiZ11K1j18k2ljk1XpBzakeJIJrYI82trE+u WjKvrFTbFbMPlM6c7dnHypLDEE/ESyYyB2S5dPKl7ASErt1hqHwK1MNw+tfEBCsn1EAG pg7gd44otFKsBnOAg1RhNVVRND2DD0cNYQRP6Vq2gkVNCMeF5+uOWjw/TcmZjWcoDIsC pd+weJKGIl6ZyoE/9NwlB9CCvsuO/cw7E4lqiuSjz/pai9JhhVMSF011Xm9MWHUsx+En w+5yLdB7jAUtV1tjo9XtOdwhMgkzHAg64kXv29GRfwAIZv+ARzMgc+EoE8gE7p4Pg/ae yi3w== X-Gm-Message-State: AIVw1139bgDGDSMnxCUxuv8D+0vD9L8rQt4Tj0JEnmEHBHt7nEa9k0D/ 8ym4M5C9K3K7lq3w X-Received: by 10.99.117.94 with SMTP id f30mr22863858pgn.366.1501668770756; Wed, 02 Aug 2017 03:12:50 -0700 (PDT) Received: from localhost ([122.171.108.183]) by smtp.gmail.com with ESMTPSA id s4sm4892202pfk.71.2017.08.02.03.12.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Aug 2017 03:12:50 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, sudeep.holla@arm.com, linux-kernel@vger.kernel.org, Len Brown , Pavel Machek , Andy Gross , David Brown Subject: [PATCH V9 2/7] PM / Domains: Catch missing genpd_set_performance_state() in masters Date: Wed, 2 Aug 2017 15:42:33 +0530 Message-Id: <565fee348107f84f643c8f1a37a90a41654ea707.1501668354.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch catches the cases where dev_get_performance_state() callback is implemented for a genpd, but none of its masters or their masters (and so on) have implemented genpd_set_performance_state() callback. The internal performance state routines don't return 0 anymore for success, rather they return count of the domains whose performance state is updated and the top level routine checks for that. A zero value there would indicate that the genpd_set_performance_state() callbacks are missing in the master hierarchy of the device. This adds very little burden on the API and can be pretty useful. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 5f50d5295cd4..0922679c1d43 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -264,18 +264,20 @@ EXPORT_SYMBOL_GPL(dev_pm_genpd_has_performance_state); static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, int state, int depth); -/* Returns -ve errors or 0 on success */ +/* Returns -ve errors or number of domains whose performance is set */ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, int state, int depth) { struct generic_pm_domain *master; struct gpd_link *link; - int prev = genpd->performance_state, ret; + int prev = genpd->performance_state, ret, count = 0; if (genpd->genpd_set_performance_state) { ret = genpd->genpd_set_performance_state(genpd, state); if (ret) return ret; + + count = 1; } /* Propagate to masters of genpd */ @@ -286,13 +288,15 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, link->performance_state = state; ret = _genpd_reeval_performance_state(master, state, depth + 1); - if (ret) + if (ret < 0) link->performance_state = prev; genpd_unlock(master); - if (ret) + if (ret < 0) goto err; + + count += ret; } /* @@ -300,7 +304,7 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, * with those. */ genpd->performance_state = state; - return 0; + return count; err: /* Encountered an error, lets rollback */ @@ -310,7 +314,7 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, genpd_lock_nested(master, depth + 1); link->performance_state = prev; - if (_genpd_reeval_performance_state(master, prev, depth + 1)) { + if (_genpd_reeval_performance_state(master, prev, depth + 1) < 0) { pr_err("%s: Failed to roll back to %d performance state\n", master->name, prev); } @@ -352,7 +356,7 @@ static int _genpd_set_performance_state(struct generic_pm_domain *genpd, * - The locks are always taken in bottom->up order, i.e. subdomain first, * followed by its masters. * - * Returns -ve errors or 0 on success. + * Returns -ve errors or number of domains whose performance is set. */ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, int state, int depth) @@ -361,9 +365,14 @@ static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, struct pm_domain_data *pdd; struct gpd_link *link; - /* New requested state is same as Max requested state */ - if (state == genpd->performance_state) - return 0; + if (state == genpd->performance_state) { + /* + * New requested state is same as Max requested state, return 1 + * to distinguish from the case where none of the masters have + * set their genpd_set_performance_state() callback. + */ + return 1; + } /* New requested state is higher than Max requested state */ if (state > genpd->performance_state) @@ -451,7 +460,7 @@ int dev_pm_genpd_update_performance_state(struct device *dev, } ret = _genpd_reeval_performance_state(genpd, state, 0); - if (!ret) { + if (ret > 0) { /* * Since we are passing "state" to * _genpd_reeval_performance_state() as well, we don't need to @@ -460,6 +469,11 @@ int dev_pm_genpd_update_performance_state(struct device *dev, * state of master domain is updated. */ __genpd_dev_update_performance_state(dev, state); + ret = 0; + } else { + WARN(!ret, "%s: None of %s and its masters have provided genpd_set_performance_state()\n", + __func__, genpd->name); + ret = -ENODEV; } unlock: @@ -478,7 +492,7 @@ static int _genpd_on_update_performance_state(struct generic_pm_domain *genpd, return 0; ret = _genpd_set_performance_state(genpd, prev, depth); - if (ret) { + if (ret < 0) { pr_err("%s: Failed to restore performance state to %d (%d)\n", genpd->name, prev, ret); } else { @@ -497,7 +511,7 @@ static void _genpd_off_update_performance_state(struct generic_pm_domain *genpd, return; ret = _genpd_set_performance_state(genpd, 0, depth); - if (ret) { + if (ret < 0) { pr_err("%s: Failed to set performance state to 0 (%d)\n", genpd->name, ret); } else {