From patchwork Thu Sep 12 05:25:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19988 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4119D20F59 for ; Thu, 12 Sep 2013 05:27:38 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf11380105vcb.3 for ; Wed, 11 Sep 2013 22:27:38 -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 :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=AwMw4bzt6fFEdTXi0pKK+EI0UmwzkpafG1JS9ScRl7M=; b=OlzyeNXUS8+6ts7oa4SryEl5MUKzjqvZqpL/e9EVzcOVHDUmh3wLRH3Hq3ivDDmbf8 upFHoC0ug4g6670HOBnWGLw7G3BPJk7g5Win9X/56p3SxPirXJ/H22P1cNHTtGsAOWLv +kNwh9M3BSrzhs0sslVYo34C3nrcxJZnpSlnUWzigMKPGGjJ5kGlqtfWTOZHS3EKnx66 7ylK5yHruGhEgOMqFe+fX1V5Dlpd8UHcMIS1/7Pbu87F6HKT2Uh6OP+dL1OW8JZb3ftF lGbSTxYzfYLsZjBtJGe2BnhU/lCSjh6uD8Vu2GPN8Exkmo/CrRgjZcrT9nVywT16rC3X ujrA== X-Gm-Message-State: ALoCoQns528hlc+xgrMDqZuj5m0mQab3jeSschEgQ/xMujXxjRFPhWVBDGjfXmDwNNt2+BIoMfz2 X-Received: by 10.236.80.42 with SMTP id j30mr2064090yhe.29.1378963658022; Wed, 11 Sep 2013 22:27:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.83 with SMTP id s19ls584321qeu.7.gmail; Wed, 11 Sep 2013 22:27:37 -0700 (PDT) X-Received: by 10.220.43.19 with SMTP id u19mr4854892vce.3.1378963657780; Wed, 11 Sep 2013 22:27:37 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id ee8si662541vdc.28.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Sep 2013 22:27:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jx11so6451888veb.21 for ; Wed, 11 Sep 2013 22:27:37 -0700 (PDT) X-Received: by 10.52.227.6 with SMTP id rw6mr4102300vdc.19.1378963657684; Wed, 11 Sep 2013 22:27:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp881vcz; Wed, 11 Sep 2013 22:27:37 -0700 (PDT) X-Received: by 10.68.183.131 with SMTP id em3mr5772949pbc.56.1378963656604; Wed, 11 Sep 2013 22:27:36 -0700 (PDT) Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by mx.google.com with ESMTPS id ar2si1398018pbc.262.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Sep 2013 22:27:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.178 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.178; Received: by mail-pd0-f178.google.com with SMTP id w10so10238676pde.37 for ; Wed, 11 Sep 2013 22:27:36 -0700 (PDT) X-Received: by 10.68.65.47 with SMTP id u15mr5650078pbs.11.1378963656104; Wed, 11 Sep 2013 22:27:36 -0700 (PDT) Received: from localhost ([106.197.36.204]) by mx.google.com with ESMTPSA id gg10sm2119601pbc.46.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 11 Sep 2013 22:27:35 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl, swarren@wwwdotorg.org, srivatsa.bhat@linux.vnet.ibm.com Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 5/5] cpufreq: use correct values of cpus in __cpufreq_remove_dev_finish() Date: Thu, 12 Sep 2013 10:55:48 +0530 Message-Id: <8f777cc6b41b2fed4bf71ce2adc36800353d5738.1378963070.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This broke after a recent change "cedb70a cpufreq: Split __cpufreq_remove_dev() into two parts" from Srivatsa.. Consider a scenario where we have two CPUs in a policy (0 & 1) and we are removing cpu 1. On the call to __cpufreq_remove_dev_prepare() we have cleared 1 from policy->cpus and now on a call to __cpufreq_remove_dev_finish() we read cpumask_weight of policy->cpus, which will come as 1 and this code will behave as if we are removing the last cpu from policy :) Fix it by clearing cpu mask in __cpufreq_remove_dev_finish() instead of __cpufreq_remove_dev_prepare(). Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 0e11fcb..b556d46 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1175,12 +1175,9 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, policy->governor->name, CPUFREQ_NAME_LEN); #endif - WARN_ON(lock_policy_rwsem_write(cpu)); + lock_policy_rwsem_read(cpu); cpus = cpumask_weight(policy->cpus); - - if (cpus > 1) - cpumask_clear_cpu(cpu, policy->cpus); - unlock_policy_rwsem_write(cpu); + unlock_policy_rwsem_read(cpu); if (cpu != policy->cpu) { if (!frozen) @@ -1222,9 +1219,12 @@ static int __cpufreq_remove_dev_finish(struct device *dev, return -EINVAL; } - lock_policy_rwsem_read(cpu); + WARN_ON(lock_policy_rwsem_write(cpu)); cpus = cpumask_weight(policy->cpus); - unlock_policy_rwsem_read(cpu); + + if (cpus > 1) + cpumask_clear_cpu(cpu, policy->cpus); + unlock_policy_rwsem_write(cpu); /* If cpu is last user of policy, free policy */ if (cpus == 1) {