From: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
To: linux-acpi@vger.kernel.org, isimatu.yasuaki@jp.fujitsu.com,
wency@cn.fujitsu.com
Cc: rjw@sisk.pl, lenb@kernel.org, toshi.kani@hp.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
Subject: [RFC PATCH v2 3/3] acpi_memhotplug: Add prepare_remove operation
Date: Thu, 15 Nov 2012 11:22:50 +0100 [thread overview]
Message-ID: <1352974970-6643-4-git-send-email-vasilis.liaskovitis@profitbricks.com> (raw)
In-Reply-To: <1352974970-6643-1-git-send-email-vasilis.liaskovitis@profitbricks.com>
Offlining and removal of memory is now done in the prepare_remove callback,
not in the remove callback.
The prepare_remove callback will be called when trying to remove a memory device
with the following ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
3. echo "PNP0C80:00" > /sys/bus/acpi/drivers/acpi_memhotplug/unbind
Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
---
drivers/acpi/acpi_memhotplug.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 92c973a..8615ff3 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -54,6 +54,7 @@ MODULE_LICENSE("GPL");
static int acpi_memory_device_add(struct acpi_device *device);
static int acpi_memory_device_remove(struct acpi_device *device, int type);
+static int acpi_memory_device_prepare_remove(struct acpi_device *device);
static const struct acpi_device_id memory_device_ids[] = {
{ACPI_MEMORY_DEVICE_HID, 0},
@@ -68,6 +69,7 @@ static struct acpi_driver acpi_memory_device_driver = {
.ops = {
.add = acpi_memory_device_add,
.remove = acpi_memory_device_remove,
+ .prepare_remove = acpi_memory_device_prepare_remove,
},
};
@@ -499,6 +501,20 @@ static int acpi_memory_device_add(struct acpi_device *device)
static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
struct acpi_memory_device *mem_device = NULL;
+
+ if (!device || !acpi_driver_data(device))
+ return -EINVAL;
+
+ mem_device = acpi_driver_data(device);
+
+ kfree(mem_device);
+
+ return 0;
+}
+
+static int acpi_memory_device_prepare_remove(struct acpi_device *device)
+{
+ struct acpi_memory_device *mem_device = NULL;
int result;
if (!device || !acpi_driver_data(device))
@@ -506,12 +522,14 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
mem_device = acpi_driver_data(device);
+ /*
+ * offline and remove memory only when the memory device is
+ * ejected.
+ */
result = acpi_memory_remove_memory(mem_device);
if (result)
return result;
- kfree(mem_device);
-
return 0;
}
--
1.7.9
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-11-15 10:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 10:22 [RFC PATCH v2 0/3] acpi: Introduce prepare_remove device operation Vasilis Liaskovitis
2012-11-15 10:22 ` [RFC PATCH v2 1/3] driver core: Introduce prepare_remove in bus_type Vasilis Liaskovitis
2012-11-15 10:22 ` [RFC PATCH v2 2/3] acpi: Introduce prepare_remove operation in acpi_device_ops Vasilis Liaskovitis
2012-11-15 10:22 ` Vasilis Liaskovitis [this message]
2012-11-16 21:17 ` [RFC PATCH v2 0/3] acpi: Introduce prepare_remove device operation Rafael J. Wysocki
2012-11-16 21:33 ` Greg Kroah-Hartman
2012-11-16 21:41 ` Rafael J. Wysocki
2012-11-16 21:43 ` Rafael J. Wysocki
2012-11-16 22:45 ` Toshi Kani
2012-11-16 23:01 ` Greg Kroah-Hartman
2012-11-16 23:14 ` Toshi Kani
2012-11-16 23:33 ` Greg Kroah-Hartman
2012-11-16 23:35 ` Toshi Kani
2012-11-17 0:02 ` Greg Kroah-Hartman
2012-11-17 0:08 ` Toshi Kani
2012-11-17 0:22 ` Greg Kroah-Hartman
2012-11-17 0:25 ` Toshi Kani
2012-11-18 16:16 ` Jiang Liu
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=1352974970-6643-4-git-send-email-vasilis.liaskovitis@profitbricks.com \
--to=vasilis.liaskovitis@profitbricks.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rjw@sisk.pl \
--cc=toshi.kani@hp.com \
--cc=wency@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).