From patchwork Thu Jun 11 10:51:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 49748 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 CCF4320C81 for ; Thu, 11 Jun 2015 10:53:08 +0000 (UTC) Received: by wibdt2 with SMTP id dt2sf1840873wib.3 for ; Thu, 11 Jun 2015 03:53:08 -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=hxUDDkTjI8dr57/tDcRbYzDfo37MqumoqCMSjggO8vo=; b=ZiiY1lT4cXOiY6oTzSsYpT+5oKmD1TFjfGu4+XLLv1/UOgxZeDxETJjhRth3Wdt5nt wE1GawUQJXOq9uXQ40VjUpueECnopniLbh9+Lp1RDmC6OzUGQkj/yauyWgx6XrLXZT9/ lUgSMoyDxhj8XhNyGoIMd2XvbolL+v4DgufjsnPIx1FqSOdHPSq6t0dw1/nOQqlybtb6 ZoJ4gaDMk3V6hcPl2pawNsYmB/xBiRWENZ5It4WyNu/JcxyIgdZmC6r98Kjkzmj5wwYP BCXhv1LErZcXkVNVaC6B431H45G/+d6RMSFCchxjU6pZ/PX9+oV9b6ww5c48FRnP2eRM VxMQ== X-Gm-Message-State: ALoCoQkKF9zNMZnOD1N8jG4GoKbY1IKvGj+k3zx7hfq3tnT7yZDUyubcpQgfiMcmg1ZJ8rptJAR5 X-Received: by 10.112.189.131 with SMTP id gi3mr7936483lbc.6.1434019988055; Thu, 11 Jun 2015 03:53:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.105 with SMTP id lb9ls389068lab.10.gmail; Thu, 11 Jun 2015 03:53:07 -0700 (PDT) X-Received: by 10.152.203.233 with SMTP id kt9mr9179979lac.21.1434019987910; Thu, 11 Jun 2015 03:53:07 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ug12si267479lac.47.2015.06.11.03.53.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 03:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by laew7 with SMTP id w7so2420380lae.1 for ; Thu, 11 Jun 2015 03:53:07 -0700 (PDT) X-Received: by 10.112.182.4 with SMTP id ea4mr9351068lbc.35.1434019987658; Thu, 11 Jun 2015 03:53:07 -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 hn6csp3952702lbb; Thu, 11 Jun 2015 03:53:06 -0700 (PDT) X-Received: by 10.70.131.132 with SMTP id om4mr13883474pdb.30.1434019978801; Thu, 11 Jun 2015 03:52:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xz3si375664pab.181.2015.06.11.03.52.58; Thu, 11 Jun 2015 03:52:58 -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 S1752439AbbFKKw5 (ORCPT + 11 others); Thu, 11 Jun 2015 06:52:57 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34615 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752358AbbFKKw4 (ORCPT ); Thu, 11 Jun 2015 06:52:56 -0400 Received: by payr10 with SMTP id r10so2311066pay.1 for ; Thu, 11 Jun 2015 03:52:56 -0700 (PDT) X-Received: by 10.68.136.42 with SMTP id px10mr14032730pbb.19.1434019975899; Thu, 11 Jun 2015 03:52:55 -0700 (PDT) Received: from localhost ([122.167.219.251]) by mx.google.com with ESMTPSA id pr4sm399240pbb.30.2015.06.11.03.52.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 11 Jun 2015 03:52:55 -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 11/12] cpufreq: propagate errors returned from __cpufreq_governor() Date: Thu, 11 Jun 2015 16:21:54 +0530 Message-Id: <1e4cea25fc1bf43924a39944ca9d1ec0782621e8.1434019473.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.215.50 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: , At few places in cpufreq_set_policy() either we aren't checking return errors of __cpufreq_governor() or aren't returning them as is to the callers. This sometimes propagates wrong errors to sysfs OR we try to do more operations even if we have failed. Now that we return -EBUSY from __cpufreq_governor() on invalid requests, there are more chances of hitting these errors. Lets fix them by checking and returning errors properly. 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");