From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbcB2Gj1 (ORCPT ); Mon, 29 Feb 2016 01:39:27 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:35231 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918AbcB2GjU (ORCPT ); Mon, 29 Feb 2016 01:39:20 -0500 Date: Mon, 29 Feb 2016 12:09:17 +0530 From: Viresh Kumar To: rjw@rjwysocki.net, Shilpasri G Bhat Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, ego@linux.vnet.ibm.com, shreyas@linux.vnet.ibm.com, linux-api@vger.kernel.org Subject: Re: [PATCH v10 2/2] cpufreq: powernv: Add sysfs attributes to show throttle stats Message-ID: <20160229063917.GK2791@vireshk-i7> References: <1456483012-29466-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> <1456483012-29466-3-git-send-email-shilpa.bhat@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456483012-29466-3-git-send-email-shilpa.bhat@linux.vnet.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26-02-16, 16:06, Shilpasri G Bhat wrote: > +static int powernv_cpufreq_policy_notifier(struct notifier_block *nb, > + unsigned long action, void *data) > +{ > + struct cpufreq_policy *policy = data; > + int ret; > + > + if (action == CPUFREQ_CREATE_POLICY) { > + ret = sysfs_create_group(&policy->kobj, &throttle_attr_grp); > + if (ret) > + pr_info("Failed to create throttle stats directory for cpu %d\n", > + policy->cpu); > + } else if (action == CPUFREQ_REMOVE_POLICY) { > + sysfs_remove_group(&policy->kobj, &throttle_attr_grp); > + } > + > + return NOTIFY_DONE; > +} > + > +static struct notifier_block powernv_cpufreq_policy_nb = { > + .notifier_call = powernv_cpufreq_policy_notifier, > + .next = NULL, > +}; > + > static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy) > { > struct powernv_smp_call_data freq_data; > @@ -603,6 +708,8 @@ static inline void clean_chip_info(void) > > static inline void unregister_all_notifiers(void) > { > + cpufreq_unregister_notifier(&powernv_cpufreq_policy_nb, > + CPUFREQ_POLICY_NOTIFIER); > opal_message_notifier_unregister(OPAL_MSG_OCC, > &powernv_cpufreq_opal_nb); > unregister_reboot_notifier(&powernv_cpufreq_reboot_nb); > @@ -628,6 +735,8 @@ static int __init powernv_cpufreq_init(void) > > register_reboot_notifier(&powernv_cpufreq_reboot_nb); > opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb); > + cpufreq_register_notifier(&powernv_cpufreq_policy_nb, > + CPUFREQ_POLICY_NOTIFIER); > > rc = cpufreq_register_driver(&powernv_cpufreq_driver); > if (!rc) @Rafael: This driver needs to do this *ugly* notifier hack, just because we aren't doing kobject_add() for policy->kobj before ->init(). And we did that because, we wanted to create the policyX structure with the first CPU in policy->related_cpus mask and related_cpus mask isn't available until we call ->init().. Should we do something in core to make this easier for this driver? -- viresh