From patchwork Mon May 20 04:39:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 17043 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2C86320F5A for ; Mon, 20 May 2013 04:40:22 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id fp13sf4424044lab.10 for ; Sun, 19 May 2013 21:39:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=WljGf+9oly7i11zFif2XjqbEEMXZH/7SSrbqjwi1dhU=; b=isesxmndnlkWXJVR9G+UD+U85j4U00b2sX0deZi4n1A0kCNBgzQXVc0F5dsJ4zh2v0 ELG5n8BsoqlPhy5tz9M/yrPE0JK+Uj7Pgprk0MKTiDWqfY2Pm3nVj2RPI25Y34wfnFFx 8Xcm+KXrK1V1c6joKbSMiNENNMVHft7x0/E4EfBxUOE+bvEDVb3EqWt6fFgvt98ibw4t hVSqGo6MAvcOe0qImkjE9ZOsM+mlLGloDy1nscR3SDZ19lJHo2FxYXwjitBd0OQUrBOq xfZw+W6XszIrDXgZameyHtjlCPCgyObx0BsQZZUQ133lHGYREdnBSGyNyj252o4/NMNZ qDHg== X-Received: by 10.180.188.98 with SMTP id fz2mr1294621wic.4.1369024772918; Sun, 19 May 2013 21:39:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.76.6 with SMTP id g6ls6941wiw.0.gmail; Sun, 19 May 2013 21:39:32 -0700 (PDT) X-Received: by 10.180.205.200 with SMTP id li8mr9947527wic.15.1369024772817; Sun, 19 May 2013 21:39:32 -0700 (PDT) Received: from mail-ve0-x22a.google.com (mail-ve0-x22a.google.com [2607:f8b0:400c:c01::22a]) by mx.google.com with ESMTPS id ek7si2984838wid.23.2013.05.19.21.39.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 19 May 2013 21:39:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22a; Received: by mail-ve0-f170.google.com with SMTP id 15so3567155vea.29 for ; Sun, 19 May 2013 21:39:31 -0700 (PDT) X-Received: by 10.58.225.228 with SMTP id rn4mr1872505vec.35.1369024771598; Sun, 19 May 2013 21:39:31 -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.126.138 with SMTP id c10csp66573vcs; Sun, 19 May 2013 21:39:30 -0700 (PDT) X-Received: by 10.60.134.106 with SMTP id pj10mr27910574oeb.3.1369024770411; Sun, 19 May 2013 21:39:30 -0700 (PDT) Received: from mail-ob0-x233.google.com (mail-ob0-x233.google.com [2607:f8b0:4003:c01::233]) by mx.google.com with ESMTPS id so3si11865032oeb.25.2013.05.19.21.39.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 19 May 2013 21:39:30 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:4003:c01::233 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:4003:c01::233; Received: by mail-ob0-f179.google.com with SMTP id wd20so4919032obb.38 for ; Sun, 19 May 2013 21:39:30 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.118.42 with SMTP id kj10mr22118157obb.99.1369024770030; Sun, 19 May 2013 21:39:30 -0700 (PDT) Received: by 10.182.180.16 with HTTP; Sun, 19 May 2013 21:39:29 -0700 (PDT) In-Reply-To: <51991D53.7020806@gmail.com> References: <8bf03cb4a42864802800188fde78adf9b498455f.1368789952.git.viresh.kumar@linaro.org> <1b08f7e4657818e4a00ea7ebb137998223834dd5.1368789952.git.viresh.kumar@linaro.org> <51991D53.7020806@gmail.com> Date: Mon, 20 May 2013 10:09:29 +0530 Message-ID: Subject: Re: [PATCH 2/2] cpufreq: Don't create empty /sys/devices/system/cpu/cpufreq directory From: Viresh Kumar To: Francesco Lavra Cc: rjw@sisk.pl, robin.randhawa@arm.com, linux-pm@vger.kernel.org, patches@linaro.org, Liviu.Dudau@arm.com, linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org, linaro-kernel@lists.linaro.org, Steve.Bannister@arm.com, arvind.chauhan@arm.com, charles.garcia-tobin@arm.com X-Gm-Message-State: ALoCoQmfQQ38O944K39RAPIgx6dCplFvwzhqN64lGcxrRFVT23TtG23JOvjwF4DiCYrR+JKhv/gN X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22a 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: , On 20 May 2013 00:13, Francesco Lavra wrote: > On 05/17/2013 01:26 PM, Viresh Kumar wrote: >> +EXPORT_SYMBOL(get_cpufreq_global_kobject); >> +EXPORT_SYMBOL(put_cpufreq_global_kobject); > > Global symbol names should begin with a sensible prefix; in this case, > it looks like cpufreq_get_global_kobject and cpufreq_put_global_kobject > would be more appropriate names. Please see if V2 looks fine. Attached too for applying. ------------x--------------------x------------------ From: Viresh Kumar Date: Fri, 17 May 2013 16:09:09 +0530 Subject: [PATCH V2] cpufreq: Don't create empty /sys/devices/system/cpu/cpufreq directory When we don't have any file in cpu/cpufreq directory we shouldn't create it. Specially with the introduction of per-policy governor instance patchset, even governors are moved to cpu/cpu*/cpufreq/governor-name directory and so this directory is just not required. Lets have it only when required. Signed-off-by: Viresh Kumar --- V1->V2: Replace: {get|put}_cpufreq_global_kobject with cpufreq_{get|put}_global_kobject. drivers/cpufreq/acpi-cpufreq.c | 4 ++-- drivers/cpufreq/cpufreq.c | 48 ++++++++++++++++++++++++++++++++++---- drivers/cpufreq/cpufreq_governor.c | 6 +++++ include/linux/cpufreq.h | 4 ++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index ce28c34..ae0918d 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -947,7 +947,7 @@ static void __init acpi_cpufreq_boost_init(void) /* We create the boost file in any case, though for systems without * hardware support it will be read-only and hardwired to return 0. */ - if (sysfs_create_file(cpufreq_global_kobject, &(global_boost.attr))) + if (cpufreq_sysfs_create_file(&(global_boost.attr))) pr_warn(PFX "could not register global boost sysfs file\n"); else pr_debug("registered global boost sysfs file\n"); @@ -955,7 +955,7 @@ static void __init acpi_cpufreq_boost_init(void) static void __exit acpi_cpufreq_boost_exit(void) { - sysfs_remove_file(cpufreq_global_kobject, &(global_boost.attr)); + cpufreq_sysfs_remove_file(&(global_boost.attr)); if (msrs) { unregister_cpu_notifier(&boost_nb); diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e3d7112..74a1a60 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -678,9 +678,6 @@ static struct attribute *default_attrs[] = { NULL }; -struct kobject *cpufreq_global_kobject; -EXPORT_SYMBOL(cpufreq_global_kobject); - #define to_policy(k) container_of(k, struct cpufreq_policy, kobj) #define to_attr(a) container_of(a, struct freq_attr, attr) @@ -751,6 +748,49 @@ static struct kobj_type ktype_cpufreq = { .release = cpufreq_sysfs_release, }; +struct kobject *cpufreq_global_kobject; +EXPORT_SYMBOL(cpufreq_global_kobject); + +static int cpufreq_global_kobject_usage; + +int cpufreq_get_global_kobject(void) +{ + if (!cpufreq_global_kobject_usage++) + return kobject_add(cpufreq_global_kobject, + &cpu_subsys.dev_root->kobj, "%s", "cpufreq"); + + return 0; +} +EXPORT_SYMBOL(cpufreq_get_global_kobject); + +void cpufreq_put_global_kobject(void) +{ + if (!--cpufreq_global_kobject_usage) + kobject_del(cpufreq_global_kobject); +} +EXPORT_SYMBOL(cpufreq_put_global_kobject); + +int cpufreq_sysfs_create_file(const struct attribute *attr) +{ + int ret = cpufreq_get_global_kobject(); + + if (!ret) { + ret = sysfs_create_file(cpufreq_global_kobject, attr); + if (ret) + cpufreq_put_global_kobject(); + } + + return ret; +} +EXPORT_SYMBOL(cpufreq_sysfs_create_file); + +void cpufreq_sysfs_remove_file(const struct attribute *attr) +{ + sysfs_remove_file(cpufreq_global_kobject, attr); + cpufreq_put_global_kobject(); +} +EXPORT_SYMBOL(cpufreq_sysfs_remove_file); + /* symlink affected CPUs */ static int cpufreq_add_dev_symlink(unsigned int cpu, struct cpufreq_policy *policy) @@ -2022,7 +2062,7 @@ static int __init cpufreq_core_init(void) init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); } - cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); + cpufreq_global_kobject = kobject_create(); BUG_ON(!cpufreq_global_kobject); register_syscore_ops(&cpufreq_syscore_ops); diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index b6cfd55..7532570 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -231,6 +231,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, return rc; } + if (!have_governor_per_policy()) + WARN_ON(cpufreq_get_global_kobject()); + rc = sysfs_create_group(get_governor_parent_kobj(policy), get_sysfs_attr(dbs_data)); if (rc) { @@ -269,6 +272,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, sysfs_remove_group(get_governor_parent_kobj(policy), get_sysfs_attr(dbs_data)); + if (!have_governor_per_policy()) + cpufreq_put_global_kobject(); + if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && (policy->governor->initialized == 1)) { struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index cbdf5a4..b97d99b 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -71,6 +71,10 @@ struct cpufreq_governor; /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ extern struct kobject *cpufreq_global_kobject; +int cpufreq_get_global_kobject(void); +void cpufreq_put_global_kobject(void); +int cpufreq_sysfs_create_file(const struct attribute *attr); +void cpufreq_sysfs_remove_file(const struct attribute *attr); #define CPUFREQ_ETERNAL (-1) struct cpufreq_cpuinfo {