From: Keshavamurthy Anil S <anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: LHNS list
<lhns-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
ACPI Developer
<acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Cc: anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 2/6]ACPI based Physical CPU hotplug
Date: Wed, 8 Sep 2004 18:24:15 -0700 [thread overview]
Message-ID: <20040908182415.C7287@unix-os.sc.intel.com> (raw)
In-Reply-To: <44BDAFB888F59F408FAE3CC35AB47041B17999@orsmsx409>; from anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org on Wed, Sep 08, 2004 at 06:10:50PM -0700
This is the core eject support interface required to support user mode
agent initiated hot-removal.
---
Name:acpi_core_eject.patch
Status: Tested on 2.6.9-rc2-mm2
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Depends:acpi_core
Version: applies on 2.6.9-rc1-mm2
This patch support /sys/firmware/acpi/eject interface where in
the ACPI device say "LSB0" can be ejected by echoing "\_SB.LSB0" >
/sys/firmware/acpi/eject
The kernel when it receives an hardware sci eject request it simply passes this
to user mode agent and the agent in turn will offline all the child devices and
then echo's the ACPI device name onto /sys/firware/acpi/eject file and then the
kernel will then actually remove the device.
---
linux-2.6.9-rc1-mm2-askeshav/drivers/acpi/scan.c | 141 +++++++++++++++++++++++
1 files changed, 141 insertions(+)
diff -puN drivers/acpi/scan.c~acpi_core_eject drivers/acpi/scan.c
--- linux-2.6.9-rc1-mm2/drivers/acpi/scan.c~acpi_core_eject 2004-09-08 16:42:16.763594503 -0700
+++ linux-2.6.9-rc1-mm2-askeshav/drivers/acpi/scan.c 2004-09-08 16:42:16.848555439 -0700
@@ -2,6 +2,7 @@
* scan.c - support for transforming the ACPI namespace into individual objects
*/
+#include <linux/module.h>
#include <linux/init.h>
#include <linux/acpi.h>
@@ -293,6 +294,141 @@ end:
}
/* --------------------------------------------------------------------------
+ ACPI hotplug Eject support
+ -------------------------------------------------------------------------- */
+static ssize_t acpi_eject_store(struct subsystem *subsys, const char *buf, size_t count);
+static struct subsys_attribute acpi_eject_attr =
+ __ATTR(eject,0200,NULL,acpi_eject_store);
+
+/*
+ * evaluate _EJ0, detach driver, and remove from ACPI bus
+ */
+static int
+eject_operation(acpi_handle handle, int lockable)
+{
+ struct acpi_object_list arg_list;
+ union acpi_object arg;
+ acpi_status status = AE_OK;
+
+ /*
+ * TBD: evaluate _PS3?
+ */
+
+ if (lockable) {
+ arg_list.count = 1;
+ arg_list.pointer = &arg;
+ arg.type = ACPI_TYPE_INTEGER;
+ arg.integer.value = 0;
+ acpi_evaluate_object(handle, "_LCK", &arg_list, NULL);
+ }
+
+ arg_list.count = 1;
+ arg_list.pointer = &arg;
+ arg.type = ACPI_TYPE_INTEGER;
+ arg.integer.value = 1;
+
+ /*
+ * TBD: _EJD support.
+ */
+
+ status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL);
+ if (ACPI_FAILURE(status)) {
+ return(-ENODEV);
+ }
+
+ return(0);
+}
+
+static ssize_t
+acpi_eject_store(struct subsystem *subsys, const char *buf, size_t count)
+{
+ acpi_status status;
+ acpi_handle hlsb;
+ struct acpi_device *device = NULL;
+ int result;
+ int ret = count;
+
+ char *acpi_name;
+ char *p;
+ int islockable;
+ acpi_object_type type = 0;
+
+ if (!count) {
+ return -EINVAL;
+ }
+
+ acpi_name = kmalloc(count+1, GFP_KERNEL);
+ if (!acpi_name) {
+ return -ENOMEM;
+ }
+
+ acpi_name[count] = '\0';
+ strncpy(acpi_name, buf, count);
+
+ for (p = acpi_name+(count-1); p >= acpi_name; --p) {
+ if (isspace(*p))
+ *p = '\0';
+ else
+ break;
+ }
+
+ status = acpi_get_handle(NULL, acpi_name, &hlsb);
+ if(ACPI_FAILURE(status)) {
+ ret = -ENODEV;
+ goto err;
+ }
+
+ status = acpi_get_type(hlsb, &type);
+ if (ACPI_FAILURE(status)) {
+ ret = -ENODEV;
+ goto err;
+ }
+
+ result = acpi_bus_get_device(hlsb, &device);
+ if (result) {
+ ret = -ENODEV;
+ goto err;
+ }
+#ifndef FORCE_EJECT
+ if (device->driver == NULL) {
+ ret = -ENODEV;
+ goto err;
+ }
+#endif
+ if (!device->flags.ejectable) {
+ ret = -ENODEV;
+ goto err;
+ }
+
+ islockable = device->flags.lockable;
+
+ /*
+ * remove from ACPI bus.
+ */
+ if (type == ACPI_BUS_TYPE_PROCESSOR)
+ acpi_bus_trim(device, 0);
+ else
+ acpi_bus_trim(device, 1);
+
+
+ result = eject_operation(hlsb, islockable);
+ if (result) {
+ ret = -EBUSY;
+ }
+err:
+ kfree(acpi_name);
+ return ret;
+}
+
+
+static int __init register_acpi_eject(void)
+{
+ subsys_create_file(&acpi_subsys, &acpi_eject_attr);
+ return 0;
+}
+
+
+/* --------------------------------------------------------------------------
Performance Management
-------------------------------------------------------------------------- */
@@ -1155,6 +1291,11 @@ static int __init acpi_scan_init(void)
if (result)
acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
+ /*
+ * Register hotplug eject interface
+ */
+ register_acpi_eject();
+
Done:
return_VALUE(result);
}
_
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
next prev parent reply other threads:[~2004-09-09 1:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <44BDAFB888F59F408FAE3CC35AB47041B17999@orsmsx409>
2004-09-09 1:21 ` [PATCH 1/6]ACPI based Physical CPU hotplug Keshavamurthy Anil S
2004-09-09 1:24 ` Keshavamurthy Anil S [this message]
2004-09-09 1:35 ` [PATCH 3/6]ACPI " Keshavamurthy Anil S
2004-09-09 1:37 ` [PATCH 4/6]ACPI " Keshavamurthy Anil S
2004-09-09 1:40 ` [PATCH 5/6]ACPI " Keshavamurthy Anil S
[not found] ` <20040908184011.C7384-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2004-09-09 20:40 ` Mika Penttilä
[not found] ` <4140BFA3.1070508-9Aww8k/80nUxHbG02/KK1g@public.gmane.org>
2004-09-09 21:18 ` Keshavamurthy Anil S
2004-09-09 1:41 ` [PATCH 6/6]ACPI " Keshavamurthy Anil S
[not found] ` <20040908184152.D7384-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2004-09-13 1:18 ` [Lhns-devel] " Keiichiro Tokunaga
[not found] ` <20040913101834.65490902.tokunaga.keiich-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2004-09-14 7:57 ` Keiichiro Tokunaga
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=20040908182415.C7287@unix-os.sc.intel.com \
--to=anil.s.keshavamurthy-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=lhns-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/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