From patchwork Mon Jun 22 05:21:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50132 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C180E21594 for ; Mon, 22 Jun 2015 05:21:25 +0000 (UTC) Received: by wiea6 with SMTP id a6sf7121709wie.1 for ; Sun, 21 Jun 2015 22:21:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=0HIW9nPz7/qW8n6PPnTkqPOVDEjX+PNhdnBjqCxamso=; b=SKzm96yEa6dpwp5GXXTkrKT0N4IDNX3XKa5dP1eJJfU0/skIBrzuCCz8WRksMxKN6T hZ0ImmPjd7pywqk9aflFhUldLSXOHS11SziTKhH6ultoLDqXPyZxefys82UktStAwWyJ u8m/QfrwbNGhrtoCQjuaIEgP0NFJlKdnOw2bnoHSzwTOvI5KeNrAtV5K51tBFGonH6kj Sg1B3Cv+zM1H/1AfWwUod02pfOWt4CRYSsFiJK5rJ/3ZUaEG4fFmL+RQPeKPH4yJftio dM2+Qj/mulPXmp0XnC6s5YFzMj6g9INZoYjUK51aFNxDQTVYRh60FT6ahoC/JoB3+yR2 RVTQ== X-Gm-Message-State: ALoCoQk5k2aIj2Lu64UpiGbdaDcYU+nANjajIFuIbrg1DjQg9i3P9vK/Tw9c+IR9K6VjHFMwMGr8 X-Received: by 10.112.148.101 with SMTP id tr5mr26589852lbb.13.1434950484190; Sun, 21 Jun 2015 22:21:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.228 with SMTP id z4ls866086lal.90.gmail; Sun, 21 Jun 2015 22:21:24 -0700 (PDT) X-Received: by 10.152.28.42 with SMTP id y10mr11741284lag.9.1434950484043; Sun, 21 Jun 2015 22:21:24 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id mr8si15609775lbb.104.2015.06.21.22.21.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jun 2015 22:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagx9 with SMTP id x9so14826331lag.1 for ; Sun, 21 Jun 2015 22:21:23 -0700 (PDT) X-Received: by 10.112.160.165 with SMTP id xl5mr879279lbb.36.1434950483295; Sun, 21 Jun 2015 22:21:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2141806lbb; Sun, 21 Jun 2015 22:21:22 -0700 (PDT) X-Received: by 10.66.196.130 with SMTP id im2mr52468104pac.43.1434950481330; Sun, 21 Jun 2015 22:21:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ke5si27817487pab.238.2015.06.21.22.21.20; Sun, 21 Jun 2015 22:21:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753953AbbFVFVT (ORCPT + 11 others); Mon, 22 Jun 2015 01:21:19 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:34757 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753914AbbFVFVT (ORCPT ); Mon, 22 Jun 2015 01:21:19 -0400 Received: by pabvl15 with SMTP id vl15so80066372pab.1 for ; Sun, 21 Jun 2015 22:21:18 -0700 (PDT) X-Received: by 10.66.218.6 with SMTP id pc6mr55097742pac.20.1434950478643; Sun, 21 Jun 2015 22:21:18 -0700 (PDT) Received: from localhost ([223.227.180.185]) by mx.google.com with ESMTPSA id fk5sm13710730pab.40.2015.06.21.22.21.15 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 21 Jun 2015 22:21:17 -0700 (PDT) Date: Mon, 22 Jun 2015 10:51:06 +0530 From: Viresh Kumar To: Preeti U Murthy Cc: Rafael Wysocki , ke.wang@spreadtrum.com, linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, ego@linux.vnet.ibm.com, paulus@samba.org, shilpa.bhat@linux.vnet.ibm.com, prarit@redhat.com, robert.schoene@tu-dresden.de, skannan@codeaurora.org Subject: Re: [PATCH V2 10/10] cpufreq: propagate errors returned from __cpufreq_governor() Message-ID: <20150622052106.GA3878@linux> References: <46b51eea20399c927fb1f16839773f618133ae09.1434713657.git.viresh.kumar@linaro.org> <55845930.7020503@linux.vnet.ibm.com> <20150620031207.GE1955@linux> <55879214.2070809@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <55879214.2070809@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 22-06-15, 10:11, Preeti U Murthy wrote: > There are some checkpatch errors on this patch. --------------8<------------------ From: Viresh Kumar Date: Thu, 11 Sep 2014 10:50:48 +0530 Subject: [PATCH] cpufreq: propagate errors returned from __cpufreq_governor() Return codes aren't honored properly in cpufreq_set_policy(). This can lead to two problems: - wrong errors propagated to sysfs - we try to do next state-change even if the previous one failed cpufreq_governor_dbs() now returns proper errors on all invalid state-transition requests and this code should honor that. Reviewed-and-tested-by: Preeti U Murthy Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b612411655f9..0b3c60861bdf 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2284,16 +2284,31 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, old_gov = policy->governor; /* end old governor */ if (old_gov) { - __cpufreq_governor(policy, CPUFREQ_GOV_STOP); + ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); + if (ret) { + /* This can happen due to race with other operations */ + pr_debug("%s: Failed to Stop Governor: %s (%d)\n", + __func__, old_gov->name, ret); + return ret; + } + up_write(&policy->rwsem); - __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); + ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); down_write(&policy->rwsem); + + if (ret) { + pr_err("%s: Failed to Exit Governor: %s (%d)\n", + __func__, old_gov->name, ret); + return ret; + } } /* start new governor */ policy->governor = new_policy->governor; - if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) { - if (!__cpufreq_governor(policy, CPUFREQ_GOV_START)) + ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT); + if (!ret) { + ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); + if (!ret) goto out; up_write(&policy->rwsem); @@ -2305,11 +2320,13 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, pr_debug("starting governor %s failed\n", policy->governor->name); if (old_gov) { policy->governor = old_gov; - __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT); - __cpufreq_governor(policy, CPUFREQ_GOV_START); + if (__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) + policy->governor = NULL; + else + __cpufreq_governor(policy, CPUFREQ_GOV_START); } - return -EINVAL; + return ret; out: pr_debug("governor: change or update limits\n");