From patchwork Wed Dec 24 06:09:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5536441 Return-Path: X-Original-To: patchwork-linux-arm@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 9467CBEEA8 for ; Wed, 24 Dec 2014 06:12:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDB4220115 for ; Wed, 24 Dec 2014 06:12:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DBBBC20108 for ; Wed, 24 Dec 2014 06:12:29 +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 1Y3f9r-0006nA-8z; Wed, 24 Dec 2014 06:10:55 +0000 Received: from mail-ig0-x230.google.com ([2607:f8b0:4001:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y3f9k-0006hz-CU for linux-arm-kernel@lists.infradead.org; Wed, 24 Dec 2014 06:10:50 +0000 Received: by mail-ig0-f176.google.com with SMTP id l13so6968164iga.15 for ; Tue, 23 Dec 2014 22:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=pJC/drOrAjyZBZZXR57RaFvtfQlPu2BeOj0F1uhHUqc=; b=lFwRBWzdienfc6NUvvEeXrLRAITLGT4sFkSuRwUtKDPntgfygr9EwB19HzHqwmrsmb YWf+FsXFEZOOsnFqfIvYutvt/ZT0sniYwHAlNpF1Gv4BrvDZQt2n1wDmn3HcLIc06jgA H7BsNuFyoFZZUr9zl+VQ4iY6llt620T86UTqc= 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=pJC/drOrAjyZBZZXR57RaFvtfQlPu2BeOj0F1uhHUqc=; b=lmQskijpbrTXF7a2Vtzsmzl+tgg3MyuSqZ+V5e5JHWSiwPdBURRsscaU0FqJmlcO1c Y3r9SHCH8JgegGD2sJhqpCV0vUBbhVM/65lV5l1YMRea8UdVt/6qjyIBagLW4tiVZWUe S/vB1S47+pod2bRLLnOy0ucy6VNSKU+jfro0LDz5q4U/s+vyaB8DdMlVu++ifeMa0ijH PLGK+pPdmfDp1DyKgsXI0NmY1nxt+NClexZHTxwnrKTxuhzBVz0stczVK6a2Sfclfsyy N2Nxq8+dpOSBxoHebRmZxwG81bNTEaVKq5jMG0Tcnjo+llHA8x7bAZNoZiok/i55DoVe iYjQ== X-Gm-Message-State: ALoCoQm2VnhHzw7Kj1juNur1lQ5iRRJwIXE2/jR67BqbotjZTe89GZUcM8fyjANg9XFeLwaW8A5N X-Received: by 10.50.50.140 with SMTP id c12mr18677011igo.5.1419401426497; Tue, 23 Dec 2014 22:10:26 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id f9sm10945635iod.24.2014.12.23.22.10.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Dec 2014 22:10:25 -0800 (PST) From: Doug Anderson To: rjw@rjwysocki.net, viresh.kumar@linaro.org Subject: [PATCH v2] cpufreq: suspend cpufreq governors on shutdown Date: Tue, 23 Dec 2014 22:09:48 -0800 Message-Id: <1419401388-20171-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141223_221048_512071_7A7BD961 X-CRM114-Status: GOOD ( 14.11 ) X-Spam-Score: -0.8 (/) Cc: Heiko Stuebner , linux-pm@vger.kernel.org, Dmitry Torokhov , Doug Anderson , linux-kernel@vger.kernel.org, Chris Zhong , Dylan Reid , Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 We should stop cpufreq governors when we shut down the system. If we don't do this, we can end up with this deadlock: 1. cpufreq governor may be running on a CPU other than CPU0. 2. In machine_restart() we call smp_send_stop() which stops CPUs. If one of these CPUs was actively running a cpufreq governor then it may have the mutex / spinlock needed to access the main PMIC in the system (perhaps over I2C) 3. If a machine needs access to the main PMIC in order to shutdown then it will never get it since the mutex was lost when the other CPU stopped. 4. We'll hang (possibly eventually hitting the hard lockup detector). Let's avoid the problem by stopping the cpufreq governor at shutdown, which is a sensible thing to do anyway. Signed-off-by: Doug Anderson Acked-by: Viresh Kumar --- Changes in v2: - Add a comment about why we register - Don't create cpufreq_shutdown() wrapper function drivers/cpufreq/cpufreq.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a09a29c..33f3d65 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -2550,6 +2551,14 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) } EXPORT_SYMBOL_GPL(cpufreq_unregister_driver); +/* + * Stop cpufreq at shutdown to make sure it isn't holding any locks + * or mutexes when secondary CPUs are halted. + */ +static struct syscore_ops cpufreq_syscore_ops = { + .shutdown = cpufreq_suspend, +}; + static int __init cpufreq_core_init(void) { if (cpufreq_disabled()) @@ -2558,6 +2567,8 @@ static int __init cpufreq_core_init(void) cpufreq_global_kobject = kobject_create(); BUG_ON(!cpufreq_global_kobject); + register_syscore_ops(&cpufreq_syscore_ops); + return 0; } core_initcall(cpufreq_core_init);