From patchwork Fri Jan 18 19:52:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 2004121 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DD75D4020D for ; Fri, 18 Jan 2013 19:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751118Ab3ARTxM (ORCPT ); Fri, 18 Jan 2013 14:53:12 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:51846 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755720Ab3ARTxH (ORCPT ); Fri, 18 Jan 2013 14:53:07 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0IJqsbF019540; Fri, 18 Jan 2013 13:52:54 -0600 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0IJqsOY008646; Fri, 18 Jan 2013 13:52:54 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Fri, 18 Jan 2013 13:52:54 -0600 Received: from localhost (kahuna.am.dhcp.ti.com [128.247.75.12]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0IJqsWr021563; Fri, 18 Jan 2013 13:52:54 -0600 From: Nishanth Menon To: linux-pm CC: Rafael , Kevin , MyungJoo Ham , lkml , lo , Jack , Alexander , Nishanth Menon Subject: [PATCH 1/4] cpufreq: OMAP: use RCU locks around usage of OPP Date: Fri, 18 Jan 2013 13:52:32 -0600 Message-ID: <1358538755-29109-2-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358538755-29109-1-git-send-email-nm@ti.com> References: <1358538755-29109-1-git-send-email-nm@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org OPP pointer is RCU protected, hence after finding it, de-reference also should be protected with the same RCU context else the OPP pointer may become invalid. Reported-by: Alexander Holler Tested-by: Alexander Holler Acked-by: Alexander Holler Signed-off-by: Nishanth Menon --- drivers/cpufreq/omap-cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) Fixes warning as follows: http://dpaste.de/5j4qX/ [ 5.175323] =============================== [ 5.179901] [ INFO: suspicious RCU usage. ] [ 5.184295] 3.7.1-beagleboard-00018-g65ab3da-dirty #180 Not tainted [ 5.190979] ------------------------------- [ 5.195465] drivers/base/power/opp.c:155 suspicious rcu_dereference_check() usage! [ 5.203460] [ 5.203460] other info that might help us debug this: [ 5.203460] [ 5.211914] [ 5.211914] rcu_scheduler_active = 1, debug_locks = 0 [ 5.219055] 3 locks held by swapper/1: [ 5.222991] #0: (subsys mutex#5){+.+.+.}, at: [] subsys_interface_register+0x34/0xbc [ 5.232360] #1: (&per_cpu(cpu_policy_rwsem, cpu)){+.+.+.}, at: [] lock_policy_rwsem_write+0x24/0x48 [ 5.243072] #2: (&this_dbs_info->timer_mutex){+.+...}, at: [] cpufreq_governor_dbs+0x2e8/0x380 [ 5.253295] [ 5.253295] stack backtrace: [ 5.257965] [] (unwind_backtrace+0x0/0xe0) from [] (opp_get_voltage+0x5c/0xc0) [ 5.267395] [] (opp_get_voltage+0x5c/0xc0) from [] (omap_target+0x180/0x364) [ 5.276672] [] (omap_target+0x180/0x364) from [] (__cpufreq_driver_target+0x38/0x54) [ 5.303039] [] (__cpufreq_driver_target+0x38/0x54) from [] (cpufreq_governor_dbs+0x314/0x380) [ 5.313903] [] (cpufreq_governor_dbs+0x314/0x380) from [] (__cpufreq_governor+0x70/0xb4) [ 5.324310] [] (__cpufreq_governor+0x70/0xb4) from [] (__cpufreq_set_policy+0x150/0x168) [ 5.334686] [] (__cpufreq_set_policy+0x150/0x168) from [] (cpufreq_add_dev_interface+0x17c/0x1f0) [ 5.345886] [] (cpufreq_add_dev_interface+0x17c/0x1f0) from [] (cpufreq_add_dev+0x12c/0x1d8) [ 5.356628] [] (cpufreq_add_dev+0x12c/0x1d8) from [] (subsys_interface_register+0x7c/0xbc) [ 5.367187] [] (subsys_interface_register+0x7c/0xbc) from [] (cpufreq_register_driver+0x9c/0x128) [ 5.378387] [] (cpufreq_register_driver+0x9c/0x128) from [] (do_one_initcall+0x90/0x164) [ 5.395812] [] (do_one_initcall+0x90/0x164) from [] (kernel_init+0xe4/0x298) [ 5.408569] [] (kernel_init+0xe4/0x298) from [] (ret_from_fork+0x14/0x24) diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 1f3417a..97102b0 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -110,13 +110,16 @@ static int omap_target(struct cpufreq_policy *policy, freq = ret; if (mpu_reg) { + rcu_read_lock(); opp = opp_find_freq_ceil(mpu_dev, &freq); if (IS_ERR(opp)) { + rcu_read_unlock(); dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n", __func__, freqs.new); return -EINVAL; } volt = opp_get_voltage(opp); + rcu_read_unlock(); tol = volt * OPP_TOLERANCE / 100; volt_old = regulator_get_voltage(mpu_reg); }