From patchwork Sun Nov 4 15:23:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1694461 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 882D23FD8C for ; Sun, 4 Nov 2012 15:25:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755156Ab2KDPY4 (ORCPT ); Sun, 4 Nov 2012 10:24:56 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:52244 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754947Ab2KDPYw (ORCPT ); Sun, 4 Nov 2012 10:24:52 -0500 Received: by mail-pa0-f46.google.com with SMTP id hz1so3385889pad.19 for ; Sun, 04 Nov 2012 07:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=z4eeBD/SPXYwLw9HdJberKCUQumgQW6is4kOWyg4G94=; b=Rjna8AdIc64rX17SQFpWCSbfQcIDP2/jl0p6NVUbOFh8UbP46aPFNj/DSl3SCfByD5 w+a87NLsTxZYn4TvrGRa69kj7Mc64eBqkMiDomDYjeFbBrck8nQhKsbq4INyqOYzcI+K deEWyRRCuJDpF7eGJT7KXbGcNKFIuDR1OBv9aTMsif8Ll2tpFGSdVY3brTdO2gksFGnI yuJhgf3DrvlOO0unomu+XDeEXViUGT0rllOVCrNYoBdLbIKkmo2jBCARv5k7OtknjHj/ UkYbIPEW6C5YcdECy7Go0FVIrin+Czj9AvlVMavozErbSd8ZY3/WFSjNfZOLxs9sxew+ cFHA== Received: by 10.66.78.169 with SMTP id c9mr21429171pax.30.1352042691756; Sun, 04 Nov 2012 07:24:51 -0800 (PST) Received: from localhost.localdomain ([120.196.98.117]) by mx.google.com with ESMTPS id nd6sm9020763pbc.68.2012.11.04.07.24.46 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Nov 2012 07:24:51 -0800 (PST) From: Jiang Liu To: "Rafael J . Wysocki" , Yinghai Lu , Tony Luck , Yasuaki Ishimatsu , Wen Congyang , Tang Chen , Taku Izumi , Bjorn Helgaas Cc: Jiang Liu , Kenji Kaneshige , Huang Ying , Bob Moore , Len Brown , "Srivatsa S . Bhat" , Yijing Wang , Hanjun Guo , Jiang Liu , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org Subject: [ACPIHP PATCH part4 6/9] ACPIHP/processor: reject online/offline requests when doing processor hotplug Date: Sun, 4 Nov 2012 23:23:59 +0800 Message-Id: <1352042642-7306-7-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> References: <1352042642-7306-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When doing physical processor hotplug, all affected CPUs should be handled in atomic. In other words, it shouldn't be disturbed by online/offline requests from CPU device's online sysfs interface. For example, it's fatal if a CPU is onlined through CPU device's online sysfs interface between the hotplug driver offlines all affected CPUs and powers the physical processor off. So temporarily reject online/offline requests from CPU device's online sysfs interface by setting the busy flag when doing physical processor hotplug. Signed-off-by: Jiang Liu --- drivers/acpi/processor_driver.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 53e364d..22214fc 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -703,7 +703,7 @@ static int acpi_processor_pre_configure(struct acpi_device *device, return result; BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); - result = arch_register_cpu(pr->id, 0); + result = arch_register_cpu(pr->id, 1); if (result) { acpi_unmap_lsapic(pr->id); pr->id = -1; @@ -751,10 +751,26 @@ static void acpi_processor_post_configure(struct acpi_device *device, if (!cpu_online(pr->id) && cpu_up(pr->id)) dev_warn(&device->dev, "fails to online CPU%d.\n", pr->id); + cpu_set_busy(pr->id, 0); } else if (cmd == ACPIHP_DEV_POST_CMD_ROLLBACK) acpi_processor_reset(device, pr); } +static int acpi_processor_pre_release(struct acpi_device *device, + struct acpihp_cancel_context *ctx) +{ + int result; + struct acpi_processor *pr; + + if (!device || !acpi_driver_data(device)) + return -EINVAL; + pr = acpi_driver_data(device); + + result = cpu_set_busy(pr->id, 1); + + return result ? -EBUSY : 0; +} + static int acpi_processor_release(struct acpi_device *device, struct acpihp_cancel_context *ctx) { @@ -779,9 +795,11 @@ static void acpi_processor_post_release(struct acpi_device *device, BUG_ON(!device || !acpi_driver_data(device)); pr = acpi_driver_data(device); - if (cmd == ACPIHP_DEV_POST_CMD_ROLLBACK) + if (cmd == ACPIHP_DEV_POST_CMD_ROLLBACK) { if (!cpu_online(pr->id)) cpu_up(pr->id); + cpu_set_busy(pr->id, 0); + } } static void acpi_processor_unconfigure(struct acpi_device *device) @@ -799,6 +817,7 @@ static struct acpihp_dev_ops acpi_processor_hp_ops = { .pre_configure = &acpi_processor_pre_configure, .configure = &acpi_processor_configure, .post_configure = &acpi_processor_post_configure, + .pre_release = &acpi_processor_pre_release, .release = &acpi_processor_release, .post_release = &acpi_processor_post_release, .unconfigure = &acpi_processor_unconfigure,