From patchwork Fri Jun 19 11:48:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 50085 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6436C218C9 for ; Fri, 19 Jun 2015 11:49:21 +0000 (UTC) Received: by laar3 with SMTP id r3sf16211853laa.1 for ; Fri, 19 Jun 2015 04:49:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=r7xlVR+uxCDRrtPCkbSDNApVS+HktyXDw2q5g3z+j2Y=; b=mdKL5b+xzE+OLoVe67Dz1YdoVRmMp2hNau6ZJFQLZrT8ECA3fHqEPqk2MOJNR1uNKx fUQxdd+Nda5nPOYeZpv7iZVX+pYgWUHo3ci/Tzybzhrr2Iz+X4qafowKapYDRzg4Nery fJSYyg4Mbq/LSG9mdTtWlox4Sd6ypn0FB21PQlAxKYwODQ4dPN0TT1J8xKkY8PbOLAAV K1/wddFRMomTlPIKUluHREHqDLhQ8e4NWNYU4Uf5rU2tsdwrZKUAFWna2fad/RK6cuUV qa2kxv1G3UKbCjFf6oNMp0pDIdLnar8uePNgCnzgd4JAMtXaUCqBQsYyAiFbBO9CZZ5k Yk1w== X-Gm-Message-State: ALoCoQnIyQCk1jQrvQmYYlTDSWV+nyQ66ZZCuzPptSXBZwlpmwpvqRqz5OWj4KECdmPRhj63ypv0 X-Received: by 10.180.106.10 with SMTP id gq10mr2968139wib.0.1434714560328; Fri, 19 Jun 2015 04:49:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.1 with SMTP id o1ls614488lao.12.gmail; Fri, 19 Jun 2015 04:49:20 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr17079636lbc.41.1434714560156; Fri, 19 Jun 2015 04:49:20 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id pz9si8972271lbb.92.2015.06.19.04.49.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jun 2015 04:49:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbbvz5 with SMTP id vz5so22456838lbb.0 for ; Fri, 19 Jun 2015 04:49:20 -0700 (PDT) X-Received: by 10.152.225.166 with SMTP id rl6mr17500191lac.36.1434714560045; Fri, 19 Jun 2015 04:49:20 -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 hn6csp529353lbb; Fri, 19 Jun 2015 04:49:19 -0700 (PDT) X-Received: by 10.68.205.33 with SMTP id ld1mr31690885pbc.22.1434714551580; Fri, 19 Jun 2015 04:49:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si16100144pde.8.2015.06.19.04.49.10; Fri, 19 Jun 2015 04:49:11 -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 S1751604AbbFSLtG (ORCPT + 11 others); Fri, 19 Jun 2015 07:49:06 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:33727 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbbFSLtF (ORCPT ); Fri, 19 Jun 2015 07:49:05 -0400 Received: by padev16 with SMTP id ev16so83995807pad.0 for ; Fri, 19 Jun 2015 04:49:05 -0700 (PDT) X-Received: by 10.66.119.204 with SMTP id kw12mr11263970pab.19.1434714545058; Fri, 19 Jun 2015 04:49:05 -0700 (PDT) Received: from localhost ([122.167.70.98]) by mx.google.com with ESMTPSA id md8sm11046469pdb.35.2015.06.19.04.49.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 19 Jun 2015 04:49:04 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Preeti U Murthy , ke.wang@spreadtrum.com Cc: 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, Viresh Kumar Subject: [PATCH V2 10/10] cpufreq: propagate errors returned from __cpufreq_governor() Date: Fri, 19 Jun 2015 17:18:10 +0530 Message-Id: <46b51eea20399c927fb1f16839773f618133ae09.1434713657.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: 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.217.178 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: , 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. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b612411655f9..da672b910760 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2284,16 +2284,20 @@ 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); - up_write(&policy->rwsem); - __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); - down_write(&policy->rwsem); + if(!(ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP))) { + up_write(&policy->rwsem); + ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT); + down_write(&policy->rwsem); + } + + if (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)) + if (!(ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT))) { + if (!(ret = __cpufreq_governor(policy, CPUFREQ_GOV_START))) goto out; up_write(&policy->rwsem); @@ -2305,11 +2309,11 @@ 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)) + __cpufreq_governor(policy, CPUFREQ_GOV_START); } - return -EINVAL; + return ret; out: pr_debug("governor: change or update limits\n");