public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "canquan.shen" <shencanquan@huawei.com>
To: "lenb@kernel.org" <lenb@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"xiaowei.yang@huawei.com" <xiaowei.yang@huawei.com>,
	hanweidong <hanweidong@huawei.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	james.chenjiabo@huawei.com, wuchangyi@huawei.com
Subject: [PATCH v5] acpi: Fix CPU hot removal problem
Date: Mon, 07 Nov 2011 17:01:26 +0800	[thread overview]
Message-ID: <4EB79E66.9090508@huawei.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2906 bytes --]

We run linux as a guest in Xen environment. When we used the xen tools 
(xm vcpu-set <n>) to hot add and remove vcpu to and from the guest, we 
encountered the failure on vcpu removal. We found the reason is that it 
did't go to really remove cpu in the cpu removal code path.

This patch adds acpi_bus_hot_remove_device in 
acpi_process_hotplug_notify to fix this issue. With this patch, it works 
fine for us.

Signed-off-by: Canquan Shen <shencanquan@huawei.com>
---
  drivers/acpi/processor_driver.c |   13 +------------
  drivers/acpi/scan.c             |    4 ++--
  include/acpi/acpi_bus.h         |    1 +
  3 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/processor_driver.c 
b/drivers/acpi/processor_driver.c
index a4e0f1b..8429688 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -665,18 +665,7 @@ static void 
acpi_processor_hotplug_notify(acpi_handle handle,
      case ACPI_NOTIFY_EJECT_REQUEST:
          ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                    "received ACPI_NOTIFY_EJECT_REQUEST\n"));
-
-        if (acpi_bus_get_device(handle, &device)) {
-            printk(KERN_ERR PREFIX
-                    "Device don't exist, dropping EJECT\n");
-            break;
-        }
-        pr = acpi_driver_data(device);
-        if (!pr) {
-            printk(KERN_ERR PREFIX
-                    "Driver data is NULL, dropping EJECT\n");
-            return;
-        }
+        acpi_bus_hot_remove_device(handle);
          break;
      default:
          ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 449c556..6dfb4a7 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -83,7 +83,7 @@ acpi_device_modalias_show(struct device *dev, struct 
device_attribute *attr, cha
  }
  static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);

-static void acpi_bus_hot_remove_device(void *context)
+void acpi_bus_hot_remove_device(void *context)
  {
      struct acpi_device *device;
      acpi_handle handle = context;
@@ -129,7 +129,7 @@ static void acpi_bus_hot_remove_device(void *context)
       * TBD: _EJD support.
       */
      status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
-    if (ACPI_FAILURE(status))
+    if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND))
          printk(KERN_WARNING PREFIX
                  "Eject device failed\n");

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 6cd5b64..756e8d1 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -342,6 +342,7 @@ int acpi_match_device_ids(struct acpi_device *device,
                const struct acpi_device_id *ids);
  int acpi_create_dir(struct acpi_device *);
  void acpi_remove_dir(struct acpi_device *);
+void acpi_bus_hot_remove_device(void *context);

  /*
   * Bind physical devices with ACPI devices
-- 
1.7.6.msysgit.0

[-- Attachment #2: 0001-acpi-Fix-CPU-hot-removal-problem.patch --]
[-- Type: text/plain, Size: 2903 bytes --]

>From e7795527be2e9b334dc5f3ac9fdba9eaac62a33b Mon Sep 17 00:00:00 2001
From: Shen canquan <shencanquan@huawei.com>
Date: Sat, 24 Sep 2011 14:00:52 +0800
Subject: [PATCH] acpi: Fix CPU hot removal problem

We run linux as a guest in Xen environment. When we used the xen tools (xm
vcpu-set <n>) to hot add and remove vcpu to and from the guest, we
encountered the failure on vcpu removal. We found the reason is that it
did't go to really remove cpu in the cpu removal code path.

This patch adds acpi_bus_hot_remove_device in acpi_process_hotplug_notify to
fix this issue. With this patch, it works fine for us.

Signed-off-by: Canquan Shen <shencanquan@huawei.com>
---
 drivers/acpi/processor_driver.c |   13 +------------
 drivers/acpi/scan.c             |    4 ++--
 include/acpi/acpi_bus.h         |    1 +
 3 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index a4e0f1b..8429688 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -665,18 +665,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
 	case ACPI_NOTIFY_EJECT_REQUEST:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 				  "received ACPI_NOTIFY_EJECT_REQUEST\n"));
-
-		if (acpi_bus_get_device(handle, &device)) {
-			printk(KERN_ERR PREFIX
-				    "Device don't exist, dropping EJECT\n");
-			break;
-		}
-		pr = acpi_driver_data(device);
-		if (!pr) {
-			printk(KERN_ERR PREFIX
-				    "Driver data is NULL, dropping EJECT\n");
-			return;
-		}
+		acpi_bus_hot_remove_device(handle);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 449c556..6dfb4a7 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -83,7 +83,7 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha
 }
 static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
 
-static void acpi_bus_hot_remove_device(void *context)
+void acpi_bus_hot_remove_device(void *context)
 {
 	struct acpi_device *device;
 	acpi_handle handle = context;
@@ -129,7 +129,7 @@ static void acpi_bus_hot_remove_device(void *context)
 	 * TBD: _EJD support.
 	 */
 	status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
-	if (ACPI_FAILURE(status))
+	if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND))
 		printk(KERN_WARNING PREFIX
 				"Eject device failed\n");
 
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 6cd5b64..756e8d1 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -342,6 +342,7 @@ int acpi_match_device_ids(struct acpi_device *device,
 			  const struct acpi_device_id *ids);
 int acpi_create_dir(struct acpi_device *);
 void acpi_remove_dir(struct acpi_device *);
+void acpi_bus_hot_remove_device(void *context);
 
 /*
  * Bind physical devices with ACPI devices
-- 
1.7.6.msysgit.0


             reply	other threads:[~2011-11-07  9:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-07  9:01 canquan.shen [this message]
2011-11-07 17:37 ` [PATCH v5] acpi: Fix CPU hot removal problem Len Brown
2011-11-08  0:22   ` canquan.shen
  -- strict thread matches above, loose matches on Subject: below --
2011-09-24  6:10 canquan.shen
2011-09-29  3:14 ` Chen Gong
2011-09-29  3:41   ` canquan.shen
2011-09-30  5:20     ` Bjorn Helgaas
2011-10-18 12:34       ` canquan.shen
2011-10-19  3:01         ` Chen Gong
2011-10-19  3:12           ` canquan.shen
2011-10-19  3:33             ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EB79E66.9090508@huawei.com \
    --to=shencanquan@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=hanweidong@huawei.com \
    --cc=james.chenjiabo@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wuchangyi@huawei.com \
    --cc=xiaowei.yang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox