From patchwork Fri Sep 11 18:21:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 7162991 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C82F39F380 for ; Fri, 11 Sep 2015 18:24:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9CFE207F6 for ; Fri, 11 Sep 2015 18:24:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 02734207CA for ; Fri, 11 Sep 2015 18:24:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZaSxh-0007ht-UP; Fri, 11 Sep 2015 18:22:13 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZaSxe-0007eL-Ix for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2015 18:22:11 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t8BILRas027119; Fri, 11 Sep 2015 13:21:27 -0500 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8BILRPq028223; Fri, 11 Sep 2015 13:21:27 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Fri, 11 Sep 2015 13:24:21 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t8BILQcL001257; Fri, 11 Sep 2015 13:21:26 -0500 From: Grygorii Strashko To: Russell King , , Subject: [RFC][4.1.5-rt5 PATCH] ARM: smp: __cpu_disable: fix sleeping function called from invalid context Date: Fri, 11 Sep 2015 21:21:23 +0300 Message-ID: <1441995683-30817-1-git-send-email-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.5.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150911_112210_716294_B6F23AD5 X-CRM114-Status: GOOD ( 10.09 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philipp@peloton-tech.com, Sekhar Nori , linux-kernel@vger.kernel.org, Steven Rostedt , Grygorii Strashko , Austin Schuh , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 When running with the RT-kernel (4.1.5-rt5) on TI OMAP dra7-evm and trying to do Suspend to RAM, the following backtrace occurs: Disabling non-boot CPUs ... PM: noirq suspend of devices complete after 7.295 msecs Disabling non-boot CPUs ... BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917 in_atomic(): 1, irqs_disabled(): 128, pid: 18, name: migration/1 INFO: lockdep is turned off. irq event stamp: 122 hardirqs last enabled at (121): [] _raw_spin_unlock_irqrestore+0x88/0x90 hardirqs last disabled at (122): [] _raw_spin_lock_irq+0x28/0x5c softirqs last enabled at (0): [] copy_process.part.52+0x410/0x19d8 softirqs last disabled at (0): [< (null)>] (null) Preemption disabled at:[< (null)>] (null) CPU: 1 PID: 18 Comm: migration/1 Tainted: G W 4.1.4-rt3-01046-g96ac8da #204 Hardware name: Generic DRA74X (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x88/0xdc) [] (dump_stack) from [] (___might_sleep+0x198/0x2a8) [] (___might_sleep) from [] (rt_spin_lock+0x30/0x70) [] (rt_spin_lock) from [] (find_lock_task_mm+0x9c/0x174) [] (find_lock_task_mm) from [] (clear_tasks_mm_cpumask+0xb4/0x1ac) [] (clear_tasks_mm_cpumask) from [] (__cpu_disable+0x98/0xbc) [] (__cpu_disable) from [] (take_cpu_down+0x1c/0x50) [] (take_cpu_down) from [] (multi_cpu_stop+0x11c/0x158) [] (multi_cpu_stop) from [] (cpu_stopper_thread+0xc4/0x184) [] (cpu_stopper_thread) from [] (smpboot_thread_fn+0x18c/0x324) [] (smpboot_thread_fn) from [] (kthread+0xe8/0x104) [] (kthread) from [] (ret_from_fork+0x14/0x3c) CPU1: shutdown PM: Calling sched_clock_suspend+0x0/0x40 PM: Calling timekeeping_suspend+0x0/0x2e0 PM: Calling irq_gc_suspend+0x0/0x68 PM: Calling fw_suspend+0x0/0x2c PM: Calling cpu_pm_suspend+0x0/0x28 Also, sometimes system stucks right after displaying "Disabling non-boot CPUs ...". The root cause of above backtrace is task_lock() which takes a sleeping lock on -RT. To fix the issue, move clear_tasks_mm_cpumask() call from __cpu_disable() to __cpu_die() which is called on the thread which is asking for a target CPU to be shutdown. In addition, this change restores CPUhotplug functionality on TI OMAP dra7-evm and CPU1 can be unplugged/plugged many times. Signed-off-by: Grygorii Strashko --- RFC: I'm not sure how safe this change is and will be appreciated for any comments. Most of arches call clear_tasks_mm_cpumask() from __cpu_disable(), but *powerpc* calls it from CPU_DEAD notifier. This patch follows powerpc's approach in general. This issue was first reported in: http://www.spinics.net/lists/linux-rt-users/msg13752.html arch/arm/kernel/smp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 48185a7..7ee0912 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -230,8 +230,6 @@ int __cpu_disable(void) flush_cache_louis(); local_flush_tlb_all(); - clear_tasks_mm_cpumask(cpu); - return 0; } @@ -247,6 +245,9 @@ void __cpu_die(unsigned int cpu) pr_err("CPU%u: cpu didn't die\n", cpu); return; } + + clear_tasks_mm_cpumask(cpu); + pr_notice("CPU%u: shutdown\n", cpu); /*