From patchwork Sat Oct 6 15:27:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1558491 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2B851DF238 for ; Sat, 6 Oct 2012 15:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755014Ab2JFPgD (ORCPT ); Sat, 6 Oct 2012 11:36:03 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:42425 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754899Ab2JFPf7 (ORCPT ); Sat, 6 Oct 2012 11:35:59 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so2755784pad.19 for ; Sat, 06 Oct 2012 08:35:58 -0700 (PDT) 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=MeGUDjowXAC0uRYjqfU6jnW6zMJ7+t9dsmWiiyv6Ag4=; b=JGs5U+ZdX4DQGCm/2SXJsiLtat4Nk88ba76OFCsPh2whGn0es5n3izIZ671RxHVjj9 Zg9cmw2+dww6EHNJ+s3xGXdEcfk6PgGRyreY9zz1X01oxoq+xEuiOwmNYsDSZHxWX/ru 6xdeFCXLBiuGlwSbt03tmrUA1Cu4YkNEHtliXv4LtXwdNu1zcdks+sPTrjHhBC5jk6oz 6m/rxvEzr9YBjJJYAPqjI2+HLyynJGYtfhrojF8/eKVYBgsP9evl0DfLPSSFDhQ1qW+E 39yumVGkx1VQ5ozYp6FUTlXUFSB+OffZccj/lPy7aY9r+uOs7UD//ng1ZBZoLlNE0usY CRUg== Received: by 10.66.78.104 with SMTP id a8mr29731322pax.38.1349537758733; Sat, 06 Oct 2012 08:35:58 -0700 (PDT) Received: from localhost.localdomain ([221.221.24.247]) by mx.google.com with ESMTPS id vz8sm7785292pbc.63.2012.10.06.08.35.46 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 06 Oct 2012 08:35:58 -0700 (PDT) From: Jiang Liu To: Yinghai Lu , Yasuaki Ishimatsu , Kenji Kaneshige , Wen Congyang , Tang Chen , Taku Izumi Cc: Hanjun Guo , Yijing Wang , Gong Chen , Jiang Liu , Tony Luck , Huang Ying , Bob Moore , Len Brown , "Srivatsa S . Bhat" , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Subject: [RFC PATCH v3 25/28] ACPIHP/processor: reject online/offline requests when doing processor hotplug Date: Sat, 6 Oct 2012 23:27:33 +0800 Message-Id: <1349537256-21670-26-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349537256-21670-1-git-send-email-jiang.liu@huawei.com> References: <1349537256-21670-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, 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 447bd6d..51e3993 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c @@ -702,7 +702,7 @@ static int acpi_processor_pre_configure(struct acpi_device *device, if (result) goto out_unlock; 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) goto out_unmap; @@ -755,10 +755,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) { @@ -783,9 +799,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) @@ -803,6 +821,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,