From patchwork Wed Nov 19 13:21:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 5337281 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C1430C11AC for ; Wed, 19 Nov 2014 13:22:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D5888201EF for ; Wed, 19 Nov 2014 13:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 60B5B2010B for ; Wed, 19 Nov 2014 13:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753300AbaKSNWb (ORCPT ); Wed, 19 Nov 2014 08:22:31 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:64866 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752765AbaKSNWa (ORCPT ); Wed, 19 Nov 2014 08:22:30 -0500 Received: by mail-wg0-f51.google.com with SMTP id k14so834827wgh.10 for ; Wed, 19 Nov 2014 05:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=T1MrY6hchfkp+4r8U4x+b7XjQj4ieUMoke5Ca/0Fsf8=; b=xlAxZNTiGvHj4Xuw+haDhNMyThxKRGDwAKmwuKp8yyjN5KmQ5xl/y4NXw3SZJtYGDO EHVi6lEu+6949IJ/XFsfCfOeYIOjLrcXejjnZuzS8AVWtsHZCNERIFpTZBqn9SOuzyH6 dlUylT3o5a3Xw+8iEvwDzhoTjvn1MD+zRPU309lHo0Xd4KmNMbQKiZkmoXJR19mNSoCN eltv1OaPUSvGoOblpgJYGusTONsPLr3kKquVIZ6qYjjYSl7RNLLJlcaBQrhBeO0YdVNB 3pbaOxMSeqiyn2fNiPP0Eg69SbpPbTywA0dVzFagBn1Bwx2qptEDRj0kIdgHtURKGXq1 4KuQ== X-Received: by 10.194.172.4 with SMTP id ay4mr34334405wjc.13.1416403348494; Wed, 19 Nov 2014 05:22:28 -0800 (PST) Received: from cizrna.lan (37-48-37-12.tmcz.cz. [37.48.37.12]) by mx.google.com with ESMTPSA id ny6sm2188594wic.22.2014.11.19.05.22.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2014 05:22:27 -0800 (PST) From: Tomeu Vizoso To: linux-tegra@vger.kernel.org Cc: Javier Martinez Canillas , Tomeu Vizoso , "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: Ref the policy object sooner Date: Wed, 19 Nov 2014 14:21:31 +0100 Message-Id: <1416403291-7722-1-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do it before it's assigned to cpufreq_cpu_data, otherwise we can get this warning when a driver tries to get the cpu frequency during initialization: ------------[ cut here ]------------ WARNING: CPU: 1 PID: 64 at include/linux/kref.h:47 kobject_get+0x64/0x70() Modules linked in: CPU: 1 PID: 64 Comm: irq/77-tegra-ac Not tainted 3.18.0-rc4-next-20141114ccu-00050-g3eff942 #326 [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x98/0xd8) [] (dump_stack) from [] (warn_slowpath_common+0x84/0xb4) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null) from [] (kobject_get+0x64/0x70) [] (kobject_get) from [] (cpufreq_cpu_get+0x88/0xc8) [] (cpufreq_cpu_get) from [] (cpufreq_get+0xc/0x64) [] (cpufreq_get) from [] (actmon_thread_isr+0x134/0x198) [] (actmon_thread_isr) from [] (irq_thread_fn+0x1c/0x40) [] (irq_thread_fn) from [] (irq_thread+0x134/0x174) [] (irq_thread) from [] (kthread+0xdc/0xf4) [] (kthread) from [] (ret_from_fork+0x14/0x3c) ---[ end trace b7bd64a81b340c59 ]--- Signed-off-by: Tomeu Vizoso --- drivers/cpufreq/cpufreq.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4473eba..954cb2f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -898,12 +898,6 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy, struct freq_attr **drv_attr; int ret = 0; - /* prepare interface data */ - ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, - &dev->kobj, "cpufreq"); - if (ret) - return ret; - /* set up files for this cpu device */ drv_attr = cpufreq_driver->attr; while ((drv_attr) && (*drv_attr)) { @@ -1211,6 +1205,15 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) } down_write(&policy->rwsem); + + /* prepare interface data */ + ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, + &dev->kobj, "cpufreq"); + if (ret) { + pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret); + goto err_init_policy_kobj; + } + write_lock_irqsave(&cpufreq_driver_lock, flags); for_each_cpu(j, policy->cpus) per_cpu(cpufreq_cpu_data, j) = policy; @@ -1301,6 +1304,7 @@ err_get_freq: per_cpu(cpufreq_cpu_data, j) = NULL; write_unlock_irqrestore(&cpufreq_driver_lock, flags); +err_init_policy_kobj: up_write(&policy->rwsem); if (cpufreq_driver->exit)