From patchwork Fri Sep 20 17:44:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2919981 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 70E869F1BF for ; Fri, 20 Sep 2013 17:44:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C46D20373 for ; Fri, 20 Sep 2013 17:44:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC7B2201CB for ; Fri, 20 Sep 2013 17:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753390Ab3ITRoS (ORCPT ); Fri, 20 Sep 2013 13:44:18 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:30136 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297Ab3ITRoP (ORCPT ); Fri, 20 Sep 2013 13:44:15 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r8KHi7iw027241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Sep 2013 17:44:08 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8KHi7jO020476 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Sep 2013 17:44:07 GMT Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r8KHi6Zs020463; Fri, 20 Sep 2013 17:44:06 GMT Received: from linux-siqj.site (/10.132.126.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 20 Sep 2013 10:44:06 -0700 From: Yinghai Lu To: "Rafael J. Wysocki" , Viresh Kumar Cc: cpufreq@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu Subject: [PATCH -v2] cpufreq: fix racing between acpi_cpufreq_loading Date: Fri, 20 Sep 2013 10:44:03 -0700 Message-Id: <1379699043-7414-1-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.1.4 X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 There is racing in __acpi_processor_start ==> acpi_processor_load_module ==> request_module_nowait/requested = 1 before first pr path to have requested set, second cpu would request again. that will cause acpi_cpufreq_early_init to be called in parallel, that will cause data curruption in acpi_cpufreq_early_init... and intermittent crash. So add mutex to protect it. Signed-off-by: Yinghai Lu --- drivers/acpi/processor_perflib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/acpi/processor_perflib.c =================================================================== --- linux-2.6.orig/drivers/acpi/processor_perflib.c +++ linux-2.6/drivers/acpi/processor_perflib.c @@ -235,6 +235,7 @@ void acpi_processor_ppc_exit(void) acpi_processor_ppc_status &= ~PPC_REGISTERED; } +static DEFINE_MUTEX(acpi_cpufreq_load_lock); /* * Do a quick check if the systems looks like it should use ACPI * cpufreq. We look at a _PCT method being available, but don't @@ -246,8 +247,12 @@ void acpi_processor_load_module(struct a acpi_status status = 0; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; - if (!arch_has_acpi_pdc() || requested) + mutex_lock(&acpi_cpufreq_load_lock); + if (!arch_has_acpi_pdc() || requested) { + mutex_unlock(&acpi_cpufreq_load_lock); return; + } + status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); if (!ACPI_FAILURE(status)) { printk(KERN_INFO PREFIX "Requesting acpi_cpufreq\n"); @@ -255,6 +260,7 @@ void acpi_processor_load_module(struct a requested = 1; } kfree(buffer.pointer); + mutex_unlock(&acpi_cpufreq_load_lock); } static int acpi_processor_get_performance_control(struct acpi_processor *pr)