From patchwork Fri Aug 1 10:25:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 34693 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E583420670 for ; Fri, 1 Aug 2014 10:26:24 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id 9sf7932047ykp.7 for ; Fri, 01 Aug 2014 03:26: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:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=CeaqxoOzIOw9sAaPYwsILLjdik7YQk7SVAnBBUJ0V6A=; b=LPjO4VQtsxBh3I+lKXtIrfwwgnt45zUSxOFS/f6k8tBT4JA6b0WVZ18jNWkI91Eyr3 gRb9QiwwLoz0sh+h0msZKVrjEdUPkq5bRh2rmBaMlMJYKeiHAgjXrhGDA/lu/a+dUhDI IkBme4jd6Ez5a6J4fNyFVaOpdnqsyRLNwb9jqWwOoXkhlnCoXBOMaPW3nHd39rlGJa19 Pq1rRjJzBErgXerEMh3clbfSoAm8JEJxXfuYpEbBeMjH7afPs8LdIgl/R3L8nba84AIz gR3TllhQLo9Q+D+1KoPsaqmzrGLlwcK11IC7tpXXkFZTevXwXCS/WoiRh8BhzbI/YKr4 gkvg== X-Gm-Message-State: ALoCoQk9kZAbjG7umog4piKSHeC51+ZkNyc0bOoS9MKQ49CzYt5/SJPGCwXdvL4GHr39LLVT7pAK X-Received: by 10.224.2.193 with SMTP id 1mr1834119qak.9.1406888784696; Fri, 01 Aug 2014 03:26:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.80 with SMTP id o74ls1204139qgd.48.gmail; Fri, 01 Aug 2014 03:26:24 -0700 (PDT) X-Received: by 10.53.6.132 with SMTP id cu4mr3822209vdd.62.1406888784608; Fri, 01 Aug 2014 03:26:24 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id ua6si6851073vcb.14.2014.08.01.03.26.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Aug 2014 03:26:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so6206503vcb.5 for ; Fri, 01 Aug 2014 03:26:24 -0700 (PDT) X-Received: by 10.52.144.14 with SMTP id si14mr197410vdb.95.1406888784501; Fri, 01 Aug 2014 03:26:24 -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.221.37.5 with SMTP id tc5csp99041vcb; Fri, 1 Aug 2014 03:26:23 -0700 (PDT) X-Received: by 10.70.134.140 with SMTP id pk12mr1447066pdb.165.1406888782177; Fri, 01 Aug 2014 03:26:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id do1si4623799pdb.240.2014.08.01.03.26.21 for ; Fri, 01 Aug 2014 03:26:22 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbaHAK0S (ORCPT + 14 others); Fri, 1 Aug 2014 06:26:18 -0400 Received: from mail-qa0-f47.google.com ([209.85.216.47]:41715 "EHLO mail-qa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753497AbaHAK0Q (ORCPT ); Fri, 1 Aug 2014 06:26:16 -0400 Received: by mail-qa0-f47.google.com with SMTP id i13so3649120qae.20 for ; Fri, 01 Aug 2014 03:26:15 -0700 (PDT) X-Received: by 10.224.12.4 with SMTP id v4mr7475163qav.3.1406888775292; Fri, 01 Aug 2014 03:26:15 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id a67sm8953707qgf.37.2014.08.01.03.26.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 01 Aug 2014 03:26:14 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org Cc: linux-pm@vger.kernel.org, Viresh Kumar , "Rafael J. Wysocki" Subject: [PATCH] cpufreq: move policy kobj to policy->cpu at resume Date: Fri, 1 Aug 2014 15:55:58 +0530 Message-Id: <2b0ca5cc52f1840c70cbf8208d7f620f0898364e.1406888629.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.0.0.rc2 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.220.174 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: , commit 92c14bd9477a20a83144f08c0ca25b0308bf0730 upstream. This is only relevant to implementations with multiple clusters, where clusters have separate clock lines but all CPUs within a cluster share it. Consider a dual cluster platform with 2 cores per cluster. During suspend we start hot unplugging CPUs in order 1 to 3. When CPU2 is removed, policy->kobj would be moved to CPU3 and when CPU3 goes down we wouldn't free policy or its kobj as we want to retain permissions/values/etc. Now on resume, we will get CPU2 before CPU3 and will call __cpufreq_add_dev(). We will recover the old policy and update policy->cpu from 3 to 2 from update_policy_cpu(). But the kobj is still tied to CPU3 and isn't moved to CPU2. We wouldn't create a link for CPU2, but would try that for CPU3 while bringing it online. Which will report errors as CPU3 already has kobj assigned to it. This bug got introduced with commit 42f921a, which overlooked this scenario. To fix this, lets move kobj to the new policy->cpu while bringing first CPU of a cluster back. Also do a WARN_ON() if kobject_move failed, as we would reach here only for the first CPU of a non-boot cluster. And we can't recover from this situation, if kobject_move() fails. Fixes: ("42f921a cpufreq: remove sysfs files for CPUs which failed to come back after resume") Cc: # 3.13 Cc: # 3.14 Reported-and-tested-by: Bu Yitian Reported-by: Saravana Kannan Reviewed-by: Srivatsa S. Bhat Signed-off-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 199b52b..153f4b9 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1089,10 +1089,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, * the creation of a brand new one. So we need to perform this update * by invoking update_policy_cpu(). */ - if (frozen && cpu != policy->cpu) + if (frozen && cpu != policy->cpu) { update_policy_cpu(policy, cpu); - else + WARN_ON(kobject_move(&policy->kobj, &dev->kobj)); + } else { policy->cpu = cpu; + } policy->governor = CPUFREQ_DEFAULT_GOVERNOR; cpumask_copy(policy->cpus, cpumask_of(cpu));