From patchwork Sun Oct 11 17:21:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 54743 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id AA97723069 for ; Sun, 11 Oct 2015 17:21:53 +0000 (UTC) Received: by lbbpc3 with SMTP id pc3sf5715469lbb.2 for ; Sun, 11 Oct 2015 10:21:52 -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=Xi163H+aSKaVZ71x7VOTp/n755xXXJ2BuvoVivuTEgg=; b=bbSPT1zM2jtoA8e1iYdYqSUq0W4VEHM8128b24LFbc1DQr20yAYKA6iz3rRvSfS4xx AJ7fCVJ3P55MCYSxotGFoNc/G+AWkKGFePuwLVUKSxrkD7nQ8eujgmqnFOnfk1Nkt8R4 jX4aXY7Bbu2mDDTANPPBSBmF2TemStDeQMBeouTQ7jhRfMQ3EEw2Vkz39354p4GKr0z2 Yq9dCCiKktiPDf4/GXNM6xCJKyyS72ZlAypNKWgdW8OPI6eMgE0rTdiBz+8xG8gA9Erb KSCfdB+siGr7boCVaVxRYNWQSq11YosrUnVaDuJwulDZlQI6tKw/Jxm6CltowkCgb8Pn aoCQ== X-Gm-Message-State: ALoCoQm4VrRpKx75yiCUlAmBrcT21WraUO7j+HGTtpPNHz6x663XER4FA5+TR8dRbajpfLzGDrPF X-Received: by 10.112.150.229 with SMTP id ul5mr21543lbb.2.1444584112594; Sun, 11 Oct 2015 10:21:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.218.207 with SMTP id r198ls464686lfg.40.gmail; Sun, 11 Oct 2015 10:21:52 -0700 (PDT) X-Received: by 10.25.31.212 with SMTP id f203mr7019937lff.6.1444584112448; Sun, 11 Oct 2015 10:21:52 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id s70si8405060lfs.93.2015.10.11.10.21.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Oct 2015 10:21:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbwr8 with SMTP id r8so121952412lbw.2 for ; Sun, 11 Oct 2015 10:21:52 -0700 (PDT) X-Received: by 10.25.40.130 with SMTP id o124mr6819498lfo.41.1444584112325; Sun, 11 Oct 2015 10:21:52 -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.59.35 with SMTP id w3csp1144029lbq; Sun, 11 Oct 2015 10:21:51 -0700 (PDT) X-Received: by 10.68.69.79 with SMTP id c15mr29046785pbu.90.1444584110474; Sun, 11 Oct 2015 10:21:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si19610513pbq.151.2015.10.11.10.21.50; Sun, 11 Oct 2015 10:21:50 -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 S1752275AbbJKRVp (ORCPT + 12 others); Sun, 11 Oct 2015 13:21:45 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:35153 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752257AbbJKRVn (ORCPT ); Sun, 11 Oct 2015 13:21:43 -0400 Received: by pabve7 with SMTP id ve7so74364210pab.2 for ; Sun, 11 Oct 2015 10:21:42 -0700 (PDT) X-Received: by 10.68.194.133 with SMTP id hw5mr19654654pbc.25.1444584102648; Sun, 11 Oct 2015 10:21:42 -0700 (PDT) Received: from localhost ([120.59.64.42]) by smtp.gmail.com with ESMTPSA id ze3sm13788578pac.5.2015.10.11.10.21.41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 11 Oct 2015 10:21:41 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 4/5] cpufreq: create cpu/cpufreq/policyX directories Date: Sun, 11 Oct 2015 22:51:13 +0530 Message-Id: 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.179 as permitted sender) smtp.mailfrom=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: , The cpufreq sysfs interface had been a bit inconsistent as one of the CPUs for a policy had a real directory within its sysfs 'cpuX' directory and all other CPUs had links to it. That also made the code a bit complex as we need to take care of moving the sysfs directory if the CPU containing the real directory is getting physically hot-unplugged. Solve this by creating 'policyX' directories (per-policy) in /sys/devices/system/cpu/cpufreq/ directory, where X is the CPU for which the policy was first created. This also removes the need of keeping kobj_cpu and we can remove it now. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 34 ++++------------------------------ include/linux/cpufreq.h | 1 - 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2cb0e3b8170e..58aabe0f2d2c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -917,9 +917,6 @@ static int cpufreq_add_dev_symlink(struct cpufreq_policy *policy) /* Some related CPUs might not be present (physically hotplugged) */ for_each_cpu(j, policy->real_cpus) { - if (j == policy->kobj_cpu) - continue; - ret = add_cpu_dev_symlink(policy, j); if (ret) break; @@ -933,12 +930,8 @@ static void cpufreq_remove_dev_symlink(struct cpufreq_policy *policy) unsigned int j; /* Some related CPUs might not be present (physically hotplugged) */ - for_each_cpu(j, policy->real_cpus) { - if (j == policy->kobj_cpu) - continue; - + for_each_cpu(j, policy->real_cpus) remove_cpu_dev_symlink(policy, j); - } } static int cpufreq_add_dev_interface(struct cpufreq_policy *policy) @@ -1054,8 +1047,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL)) goto err_free_rcpumask; - ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, &dev->kobj, - "cpufreq"); + ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, + cpufreq_global_kobject, "policy%u", cpu); if (ret) { pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret); goto err_free_real_cpus; @@ -1069,10 +1062,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) INIT_WORK(&policy->update, handle_update); policy->cpu = cpu; - - /* Set this once on allocation */ - policy->kobj_cpu = cpu; - return policy; err_free_real_cpus: @@ -1424,22 +1413,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) return; } - if (cpu != policy->kobj_cpu) { - remove_cpu_dev_symlink(policy, cpu); - } else { - /* - * The CPU owning the policy object is going away. Move it to - * another suitable CPU. - */ - unsigned int new_cpu = cpumask_first(policy->real_cpus); - struct device *new_dev = get_cpu_device(new_cpu); - - dev_dbg(dev, "%s: Moving policy object to CPU%u\n", __func__, new_cpu); - - sysfs_remove_link(&new_dev->kobj, "cpufreq"); - policy->kobj_cpu = new_cpu; - WARN_ON(kobject_move(&policy->kobj, &new_dev->kobj)); - } + remove_cpu_dev_symlink(policy, cpu); } static void handle_update(struct work_struct *work) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9623218d996a..ef4c5b1a860f 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -65,7 +65,6 @@ struct cpufreq_policy { unsigned int shared_type; /* ACPI: ANY or ALL affected CPUs should set cpufreq */ unsigned int cpu; /* cpu managing this policy, must be online */ - unsigned int kobj_cpu; /* cpu managing sysfs files, can be offline */ struct clk *clk; struct cpufreq_cpuinfo cpuinfo;/* see above */