From patchwork Thu Nov 3 11:20:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kirjanov X-Patchwork-Id: 690779 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t8jKC3Kdlz9vDS for ; Thu, 3 Nov 2016 22:23:59 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linux-powerpc-org.20150623.gappssmtp.com header.i=@linux-powerpc-org.20150623.gappssmtp.com header.b=agdtXnmn; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3t8jKC2GWBzDvW4 for ; Thu, 3 Nov 2016 22:23:59 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linux-powerpc-org.20150623.gappssmtp.com header.i=@linux-powerpc-org.20150623.gappssmtp.com header.b=agdtXnmn; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3t8jHg5WyYzDvR9 for ; Thu, 3 Nov 2016 22:22:38 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linux-powerpc-org.20150623.gappssmtp.com header.i=@linux-powerpc-org.20150623.gappssmtp.com header.b=agdtXnmn; dkim-atps=neutral Received: by mail-lf0-x244.google.com with SMTP id o141so1342110lff.1 for ; Thu, 03 Nov 2016 04:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-powerpc-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=b+iQKq+wcMTmyoLnb0Jpq9i8lp0iCHb9IlJNKv5PcN4=; b=agdtXnmnWziOagRSBx3Xuk3pmb/wtfIkTRQof0EUYrTcoxM3zqAV/pBAvyfW56dxkZ qgCh0I3BkFohJlLhRcnI2AXR1J8ue+hklOVhMspnXP63Ehy+KTSlGJVJl1Pbs/EpQuXc 7wmZAgJatSQoHxEJMCQ8Jlyp/OwH8xjAqF9t1nL0Kh/WJID3hFgfwr41A4tyqq5CN+HT biiLpN2/1Uw7aM+iAelgcimQUBjLBywBgOa8C+871N8JRplKLKTeHJIYsbOg3AIzBL0p xsv78G1fjufhsNljxUk4/KhUdkOZPxwNG9H6ZCLjxHuZha4OcEZBOmi1QA8CVg2PKaHH okWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=b+iQKq+wcMTmyoLnb0Jpq9i8lp0iCHb9IlJNKv5PcN4=; b=XLFcITyZvmFOaiHSzEbiciajbS+8URlYPCUVtCpi7Bn7jt3TwMNa1/bcfvzku/+n2k giOodmUNfV3ySijBXEbCql6/7kQoMgq7Z7APwQU87djVD7Yfrl8JWRZwMDm8ijQRO+7e 2r9q9qNccozNbYJdaM3jt+OdJ5gMLnjZwtp8BYwTDIN/qOuvV/zlwmHHESPgwwuFYIwH WwDQbUYpFpq8iiWOIzfTaIJDn114SBIlLwT0XKplp5+BZbHe7eStWBoYak3/NiCRhXYJ 6P6xmXRhiej8Ia91mAciqoG7qNFxJYAaLtKbeICB937M0+srYSiogZeSSvepA3xTbsYc tH5g== X-Gm-Message-State: ABUngvdCQqS+n4MBr5OMduM3xoP71AR3bXpj4yX7Yku4SkwXT17q53jIIX74HH/sG2EHdQ== X-Received: by 10.25.22.201 with SMTP id 70mr5115870lfw.170.1478172152635; Thu, 03 Nov 2016 04:22:32 -0700 (PDT) Received: from power.oil.ru ([195.54.192.103]) by smtp.gmail.com with ESMTPSA id e38sm1315032lji.38.2016.11.03.04.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Nov 2016 04:22:32 -0700 (PDT) From: Denis Kirjanov To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH] ppc: cpufreq: Use get_cpu()/put_cpu() instead of smp_processor_id() to avoid the oops Date: Thu, 3 Nov 2016 07:20:41 -0400 Message-Id: <1478172041-9067-1-git-send-email-kda@linux-powerpc.org> X-Mailer: git-send-email 1.8.3.1 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Denis Kirjanov Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" [ 67.700897] BUG: using smp_processor_id() in preemptible [00000000] code: cat/7343 [ 67.700988] caller is .powernv_cpufreq_throttle_check+0x2c/0x710 [ 67.700998] CPU: 13 PID: 7343 Comm: cat Not tainted 4.8.0-rc5-dirty #1 [ 67.701038] Call Trace: [ 67.701066] [c0000007d25b75b0] [c000000000971378] .dump_stack+0xe4/0x150 (unreliable) [ 67.701153] [c0000007d25b7640] [c0000000005162e4] .check_preemption_disabled+0x134/0x150 [ 67.701238] [c0000007d25b76e0] [c0000000007b63ac] .powernv_cpufreq_throttle_check+0x2c/0x710 [ 67.701322] [c0000007d25b7790] [c0000000007b6d18] .powernv_cpufreq_target_index+0x288/0x360 [ 67.701407] [c0000007d25b7870] [c0000000007acee4] .__cpufreq_driver_target+0x394/0x8c0 [ 67.701491] [c0000007d25b7920] [c0000000007b22ac] .cpufreq_set+0x7c/0xd0 [ 67.701565] [c0000007d25b79b0] [c0000000007adf50] .store_scaling_setspeed+0x80/0xc0 [ 67.701650] [c0000007d25b7a40] [c0000000007ae270] .store+0xa0/0x100 [ 67.701723] [c0000007d25b7ae0] [c0000000003566e8] .sysfs_kf_write+0x88/0xb0 [ 67.701796] [c0000007d25b7b70] [c0000000003553b8] .kernfs_fop_write+0x178/0x260 [ 67.701881] [c0000007d25b7c10] [c0000000002ac3cc] .__vfs_write+0x3c/0x1c0 [ 67.701954] [c0000007d25b7cf0] [c0000000002ad584] .vfs_write+0xc4/0x230 [ 67.702027] [c0000007d25b7d90] [c0000000002aeef8] .SyS_write+0x58/0x100 [ 67.702101] [c0000007d25b7e30] [c00000000000bfec] system_call+0x38/0xfc Signed-off-by: Denis Kirjanov --- drivers/cpufreq/powernv-cpufreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index d3ffde8..4cd91a3 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -475,7 +475,7 @@ static inline unsigned int get_nominal_index(void) static void powernv_cpufreq_throttle_check(void *data) { struct chip *chip; - unsigned int cpu = smp_processor_id(); + int cpu; unsigned long pmsr; int pmsr_pmax; unsigned int pmsr_pmax_idx; @@ -491,9 +491,11 @@ static void powernv_cpufreq_throttle_check(void *data) goto next; chip->throttled = true; if (pmsr_pmax_idx > powernv_pstate_info.nominal) { + cpu = get_cpu(); pr_warn_once("CPU %d on Chip %u has Pmax(%d) reduced below nominal frequency(%d)\n", cpu, chip->id, pmsr_pmax, idx_to_pstate(powernv_pstate_info.nominal)); + put_cpu(); chip->throttle_sub_turbo++; } else { chip->throttle_turbo++;