From: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
To: Keshavamurthy Anil S <anil.s.keshavamurthy@intel.com>
Cc: "Brown, Len" <len.brown@intel.com>,
ACPI Developer <acpi-devel@lists.sourceforge.net>,
LHNS list <lhns-devel@lists.sourceforge.net>,
Linux IA64 <linux-ia64@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: PATCH-ACPI based CPU hotplug[2/6]-ACPI Eject interface support
Date: Mon, 20 Sep 2004 09:35:33 -0700 [thread overview]
Message-ID: <20040920093532.D14208@unix-os.sc.intel.com> (raw)
In-Reply-To: <20040920092520.A14208@unix-os.sc.intel.com>; from anil.s.keshavamurthy@intel.com on Mon, Sep 20, 2004 at 09:25:20AM -0700
---
Name:acpi_core_eject.patch
Status: Tested on 2.6.9-rc2
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Depends:acpi_core
Version: applies on 2.6.9-rc2
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-rc2-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-rc2/drivers/acpi/scan.c~acpi_core_eject 2004-09-17 17:56:46.027451654 -0700
+++ linux-2.6.9-rc2-askeshav/drivers/acpi/scan.c 2004-09-17 17:56:46.114365716 -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>
@@ -291,6 +292,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
-------------------------------------------------------------------------- */
@@ -1153,6 +1289,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);
}
_
next prev parent reply other threads:[~2004-09-20 16:38 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-20 16:25 PATCH-ACPI based CPU hotplug[0/6] Keshavamurthy Anil S
2004-09-20 16:29 ` PATCH-ACPI based CPU hotplug[0/6]-Core ACPI enhancement support Keshavamurthy Anil S
2004-09-20 16:34 ` PATCH-ACPI based CPU hotplug[1/6]-ACPI core " Keshavamurthy Anil S
[not found] ` <200409201326.44946.dtor_core@ameritech.net>
2004-09-20 19:01 ` [ACPI] " Keshavamurthy Anil S
2004-09-20 20:26 ` Bjorn Helgaas
2004-09-20 20:44 ` Keshavamurthy Anil S
2004-09-24 23:22 ` Keshavamurthy Anil S
2004-09-20 16:35 ` Keshavamurthy Anil S [this message]
2004-09-20 18:33 ` [ACPI] PATCH-ACPI based CPU hotplug[2/6]-ACPI Eject interface support Dmitry Torokhov
2004-09-20 19:24 ` Keshavamurthy Anil S
2004-09-20 23:12 ` Dmitry Torokhov
2004-09-21 0:52 ` Alex Williamson
2004-09-21 1:20 ` Dmitry Torokhov
2004-09-21 1:25 ` Keshavamurthy Anil S
2004-09-21 1:41 ` Alex Williamson
2004-09-21 5:34 ` Dmitry Torokhov
2004-09-21 1:38 ` Keshavamurthy Anil S
2004-09-21 5:51 ` Dmitry Torokhov
2004-09-21 21:51 ` Keshavamurthy Anil S
2004-09-21 22:23 ` [Lhns-devel] " Russ Anderson
2004-09-22 3:10 ` Dmitry Torokhov
2004-09-24 23:28 ` Keshavamurthy Anil S
2004-09-27 6:12 ` Dmitry Torokhov
2004-09-27 16:53 ` Keshavamurthy Anil S
2004-09-27 18:09 ` Dmitry Torokhov
2004-09-22 4:17 ` Keiichiro Tokunaga
2004-09-22 16:59 ` Keshavamurthy Anil S
2004-09-20 16:38 ` PATCH-ACPI based CPU hotplug[3/6]-Mapping lsapic to cpu Keshavamurthy Anil S
2004-09-22 2:10 ` [ACPI] " Keiichiro Tokunaga
2004-09-23 6:55 ` Keshavamurthy Anil S
2004-09-22 13:15 ` Keiichiro Tokunaga
2004-09-22 13:23 ` Keiichiro Tokunaga
2004-09-22 14:52 ` Alex Williamson
2004-09-22 17:10 ` Keiichiro Tokunaga
2004-09-22 17:54 ` Keshavamurthy Anil S
2004-09-24 23:36 ` Keshavamurthy Anil S
2004-09-27 11:47 ` Keiichiro Tokunaga
2004-09-27 12:50 ` Keiichiro Tokunaga
2004-09-27 20:44 ` Keshavamurthy Anil S
2004-09-20 16:41 ` PATCH-ACPI based CPU hotplug[4/6]-Dynamic cpu register/unregister support Keshavamurthy Anil S
2004-09-22 8:34 ` [ACPI] " Keiichiro Tokunaga
2004-09-22 17:10 ` Keshavamurthy Anil S
2004-09-24 23:40 ` Keshavamurthy Anil S
2004-09-20 16:43 ` PATCH-ACPI based CPU hotplug[5/6]-ACPI processor driver extension Keshavamurthy Anil S
2004-09-22 9:57 ` [ACPI] " Keiichiro Tokunaga
2004-09-24 23:48 ` Keshavamurthy Anil S
2004-09-20 16:47 ` PATCH-ACPI based CPU hotplug[6/6]-ACPI Container driver Keshavamurthy Anil S
2004-09-23 16:23 ` [PATCH][0/4] NUMA node handling support for ACPI container driver Keiichiro Tokunaga
2004-09-23 16:31 ` [PATCH][1/4] Add unregister_node() to drivers/base/node.c Keiichiro Tokunaga
2004-09-23 16:43 ` [Lhns-devel] " Dave Hansen
2004-09-24 3:12 ` Keiichiro Tokunaga
2004-09-27 18:52 ` Keshavamurthy Anil S
2004-09-28 10:19 ` Keiichiro Tokunaga
2004-09-23 16:32 ` [PATCH][2/4] Add arch_register_node() for ia64 Keiichiro Tokunaga
2004-09-23 16:32 ` [PATCH][3/4] Add hotplug support to drivers/acpi/numa.c Keiichiro Tokunaga
2004-09-27 12:58 ` Keiichiro Tokunaga
2004-09-27 20:06 ` Keshavamurthy Anil S
2004-09-29 6:26 ` Keiichiro Tokunaga
2004-09-23 16:36 ` [PATCH][4/4] Add NUMA node handling to the container driver Keiichiro Tokunaga
2004-09-23 22:09 ` Mika Penttilä
2004-09-24 4:44 ` Keiichiro Tokunaga
2004-09-23 16:38 ` [PATCH][0/4] NUMA node handling support for ACPI " Keshavamurthy Anil S
2004-09-24 23:51 ` PATCH-ACPI based CPU hotplug[6/6]-ACPI Container driver Keshavamurthy Anil S
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=20040920093532.D14208@unix-os.sc.intel.com \
--to=anil.s.keshavamurthy@intel.com \
--cc=acpi-devel@lists.sourceforge.net \
--cc=len.brown@intel.com \
--cc=lhns-devel@lists.sourceforge.net \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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