From: Jiang Liu <jiang.liu@huawei.com> To: Yinghai Lu <yinghai@kernel.org>, Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>, Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>, Wen Congyang <wency@cn.fujitsu.com>, Tang Chen <tangchen@cn.fujitsu.com>, Taku Izumi <izumi.taku@jp.fujitsu.com> Cc: Jiang Liu <jiang.liu@huawei.com>, Tony Luck <tony.luck@intel.com>, Huang Ying <ying.huang@intel.com>, Bob Moore <robert.moore@intel.com>, Len Brown <lenb@kernel.org>, "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>, Bjorn Helgaas <bhelgaas@google.com>, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, Gaohuai Han <hangaohuai@huawei.com>, Jiang Liu <liuj97@gmail.com> Subject: [RFC PATCH v2 03/16] ACPIHP: detect ACPI hotplug slots by checking ACPI _EJ0 method Date: Sat, 4 Aug 2012 20:13:50 +0800 [thread overview] Message-ID: <1344082443-4608-4-git-send-email-jiang.liu@huawei.com> (raw) In-Reply-To: <1344082443-4608-1-git-send-email-jiang.liu@huawei.com> From: Jiang Liu <jiang.liu@huawei.com> This patch implements a default mechanism to detect and manage ACPI system device hotplug slots based on standard ACPI interfaces. 1) Detech hotplug slot by checking existence of _EJ0 and _STA methods. 2) Power off a slot by excuting _EJ0 method. It's the default hotplug slot enumerating mechanism, platform specifc drivers may provide advanced implementation to override the default implementation. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Gaohuai Han <hangaohuai@huawei.com> Signed-off-by: Jiang Liu <liuj97@gmail.com> --- drivers/acpi/Kconfig | 10 +++ drivers/acpi/hotplug/Makefile | 1 + drivers/acpi/hotplug/slot_enum.c | 3 + drivers/acpi/hotplug/slot_enum_ej0.c | 113 ++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 drivers/acpi/hotplug/slot_enum_ej0.c diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 711e18e..c9f7918 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -344,6 +344,16 @@ config ACPI_HOTPLUG_ENUM To compile this driver as a module, choose M here: the module will be called acpihp_enum. +config ACPI_HOTPLUG_ENUM_EJ0 + bool "Detecting ACPI Hotplug Slot by Checking _EJ0 Method" + depends on ACPI_HOTPLUG_ENUM + default y + help + Enable detecting ACPI hotplug slots by checking ACPI _EJ0 method + under ACPI device objects. + + It's the default method to detect ACPI hotplug slots. + config ACPI_CONTAINER tristate "Container and Module Devices (EXPERIMENTAL)" depends on EXPERIMENTAL diff --git a/drivers/acpi/hotplug/Makefile b/drivers/acpi/hotplug/Makefile index 41c0da9..23dfa93 100644 --- a/drivers/acpi/hotplug/Makefile +++ b/drivers/acpi/hotplug/Makefile @@ -7,3 +7,4 @@ acpihp-y = core.o obj-$(CONFIG_ACPI_HOTPLUG_ENUM) += acpihp_enum.o acpihp_enum-y = slot_enum.o +acpihp_enum-y += slot_enum_ej0.o diff --git a/drivers/acpi/hotplug/slot_enum.c b/drivers/acpi/hotplug/slot_enum.c index 80396a3..a251ecf 100644 --- a/drivers/acpi/hotplug/slot_enum.c +++ b/drivers/acpi/hotplug/slot_enum.c @@ -40,11 +40,14 @@ struct acpihp_slot_id { static struct acpihp_slot_ops *slot_ops_curr; +extern struct acpihp_slot_ops acpihp_enum_ej0; + /* * Array of platform specific enumeration methods. * Entries in the array should be sorted by descending priority order. */ static struct acpihp_slot_ops *slot_ops_array[] = { + &acpihp_enum_ej0, NULL }; diff --git a/drivers/acpi/hotplug/slot_enum_ej0.c b/drivers/acpi/hotplug/slot_enum_ej0.c new file mode 100644 index 0000000..2788860 --- /dev/null +++ b/drivers/acpi/hotplug/slot_enum_ej0.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011 Huawei Tech. Co., Ltd. + * Copyright (C) 2011 Gaohuai Han <hangaohuai@huawei.com> + * Copyright (C) 2011 Jiang Liu <jiang.liu@huawei.com> + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include <linux/acpi.h> +#include <acpi/acpi.h> +#include <acpi/acpi_hotplug.h> + +static acpi_status acpihp_enum_ej0_init(void) +{ + return AE_OK; +} + +static void acpihp_enum_ej0_fini(void) +{ +} + +static acpi_status acpihp_enum_ej0_check(acpi_handle handle) +{ + acpi_handle tmp; + + /* Assume a device object with _EJ0 and _STA has a hotplug slot. */ + if (ACPI_FAILURE(acpi_get_handle(handle, "_EJ0", &tmp))) + return AE_ERROR; + if (ACPI_FAILURE(acpi_get_handle(handle, METHOD_NAME__STA, &tmp))) + return AE_ERROR; + + return AE_OK; +} + +static acpi_status +acpihp_enum_ej0_get_capabilities(acpi_handle handle, u32 *capability) +{ + /* + * Assume device objects with _EJ0 are capable of: + * ONLINE, OFFLINE, POWEROFF, HOTPLUG + */ + *capability = ACPIHP_SLOT_CAP_ONLINE | ACPIHP_SLOT_CAP_OFFLINE | + ACPIHP_SLOT_CAP_POWEROFF | ACPIHP_SLOT_CAP_HOTPLUG; + + return AE_OK; +} + +static acpi_status acpihp_enum_ej0_poweron(acpi_handle handle) +{ + return AE_SUPPORT; +} + +static acpi_status acpihp_enum_ej0_poweroff(acpi_handle handle) +{ + acpi_status status; + unsigned long long sta; + union acpi_object arg; + struct acpi_object_list arg_list; + + if (!handle) + return AE_BAD_PARAMETER; + + arg_list.count = 1; + arg_list.pointer = &arg; + arg.type = ACPI_TYPE_INTEGER; + arg.integer.value = 1; + status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to power off object %p.\n", handle); + return status; + } + + status = acpi_evaluate_integer(handle, METHOD_NAME__STA, NULL, &sta); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to evaluate _STA method of object %p\n", + handle); + return status; + } + + if (sta & (ACPI_STA_DEVICE_FUNCTIONING | ACPI_STA_DEVICE_ENABLED)) { + ACPIHP_WARN("object %p is still active after executing _EJ0.\n", + handle); + return AE_ERROR; + } + + return AE_OK; +} + +struct acpihp_slot_ops acpihp_enum_ej0 = { + .init = acpihp_enum_ej0_init, + .fini = acpihp_enum_ej0_fini, + .check = acpihp_enum_ej0_check, + .get_capabilities = acpihp_enum_ej0_get_capabilities, + .poweron = acpihp_enum_ej0_poweron, + .poweroff = acpihp_enum_ej0_poweroff, + .owner = THIS_MODULE, + .desc = "ACPI _EJ0 Based Hotplug Slot Enumerator" +}; -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Jiang Liu <jiang.liu@huawei.com> To: Yinghai Lu <yinghai@kernel.org>, Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>, Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>, Wen Congyang <wency@cn.fujitsu.com>, Tang Chen <tangchen@cn.fujitsu.com>, Taku Izumi <izumi.taku@jp.fujitsu.com> Cc: Jiang Liu <jiang.liu@huawei.com>, Tony Luck <tony.luck@intel.com>, Huang Ying <ying.huang@intel.com>, Bob Moore <robert.moore@intel.com>, Len Brown <lenb@kernel.org>, "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>, Bjorn Helgaas <bhelgaas@google.com>, <linux-kernel@vger.kernel.org>, <linux-acpi@vger.kernel.org>, <linux-pci@vger.kernel.org>, Gaohuai Han <hangaohuai@huawei.com>, Jiang Liu <liuj97@gmail.com> Subject: [RFC PATCH v2 03/16] ACPIHP: detect ACPI hotplug slots by checking ACPI _EJ0 method Date: Sat, 4 Aug 2012 20:13:50 +0800 [thread overview] Message-ID: <1344082443-4608-4-git-send-email-jiang.liu@huawei.com> (raw) In-Reply-To: <1344082443-4608-1-git-send-email-jiang.liu@huawei.com> From: Jiang Liu <jiang.liu@huawei.com> This patch implements a default mechanism to detect and manage ACPI system device hotplug slots based on standard ACPI interfaces. 1) Detech hotplug slot by checking existence of _EJ0 and _STA methods. 2) Power off a slot by excuting _EJ0 method. It's the default hotplug slot enumerating mechanism, platform specifc drivers may provide advanced implementation to override the default implementation. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Gaohuai Han <hangaohuai@huawei.com> Signed-off-by: Jiang Liu <liuj97@gmail.com> --- drivers/acpi/Kconfig | 10 +++ drivers/acpi/hotplug/Makefile | 1 + drivers/acpi/hotplug/slot_enum.c | 3 + drivers/acpi/hotplug/slot_enum_ej0.c | 113 ++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 drivers/acpi/hotplug/slot_enum_ej0.c diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 711e18e..c9f7918 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -344,6 +344,16 @@ config ACPI_HOTPLUG_ENUM To compile this driver as a module, choose M here: the module will be called acpihp_enum. +config ACPI_HOTPLUG_ENUM_EJ0 + bool "Detecting ACPI Hotplug Slot by Checking _EJ0 Method" + depends on ACPI_HOTPLUG_ENUM + default y + help + Enable detecting ACPI hotplug slots by checking ACPI _EJ0 method + under ACPI device objects. + + It's the default method to detect ACPI hotplug slots. + config ACPI_CONTAINER tristate "Container and Module Devices (EXPERIMENTAL)" depends on EXPERIMENTAL diff --git a/drivers/acpi/hotplug/Makefile b/drivers/acpi/hotplug/Makefile index 41c0da9..23dfa93 100644 --- a/drivers/acpi/hotplug/Makefile +++ b/drivers/acpi/hotplug/Makefile @@ -7,3 +7,4 @@ acpihp-y = core.o obj-$(CONFIG_ACPI_HOTPLUG_ENUM) += acpihp_enum.o acpihp_enum-y = slot_enum.o +acpihp_enum-y += slot_enum_ej0.o diff --git a/drivers/acpi/hotplug/slot_enum.c b/drivers/acpi/hotplug/slot_enum.c index 80396a3..a251ecf 100644 --- a/drivers/acpi/hotplug/slot_enum.c +++ b/drivers/acpi/hotplug/slot_enum.c @@ -40,11 +40,14 @@ struct acpihp_slot_id { static struct acpihp_slot_ops *slot_ops_curr; +extern struct acpihp_slot_ops acpihp_enum_ej0; + /* * Array of platform specific enumeration methods. * Entries in the array should be sorted by descending priority order. */ static struct acpihp_slot_ops *slot_ops_array[] = { + &acpihp_enum_ej0, NULL }; diff --git a/drivers/acpi/hotplug/slot_enum_ej0.c b/drivers/acpi/hotplug/slot_enum_ej0.c new file mode 100644 index 0000000..2788860 --- /dev/null +++ b/drivers/acpi/hotplug/slot_enum_ej0.c @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2011 Huawei Tech. Co., Ltd. + * Copyright (C) 2011 Gaohuai Han <hangaohuai@huawei.com> + * Copyright (C) 2011 Jiang Liu <jiang.liu@huawei.com> + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include <linux/acpi.h> +#include <acpi/acpi.h> +#include <acpi/acpi_hotplug.h> + +static acpi_status acpihp_enum_ej0_init(void) +{ + return AE_OK; +} + +static void acpihp_enum_ej0_fini(void) +{ +} + +static acpi_status acpihp_enum_ej0_check(acpi_handle handle) +{ + acpi_handle tmp; + + /* Assume a device object with _EJ0 and _STA has a hotplug slot. */ + if (ACPI_FAILURE(acpi_get_handle(handle, "_EJ0", &tmp))) + return AE_ERROR; + if (ACPI_FAILURE(acpi_get_handle(handle, METHOD_NAME__STA, &tmp))) + return AE_ERROR; + + return AE_OK; +} + +static acpi_status +acpihp_enum_ej0_get_capabilities(acpi_handle handle, u32 *capability) +{ + /* + * Assume device objects with _EJ0 are capable of: + * ONLINE, OFFLINE, POWEROFF, HOTPLUG + */ + *capability = ACPIHP_SLOT_CAP_ONLINE | ACPIHP_SLOT_CAP_OFFLINE | + ACPIHP_SLOT_CAP_POWEROFF | ACPIHP_SLOT_CAP_HOTPLUG; + + return AE_OK; +} + +static acpi_status acpihp_enum_ej0_poweron(acpi_handle handle) +{ + return AE_SUPPORT; +} + +static acpi_status acpihp_enum_ej0_poweroff(acpi_handle handle) +{ + acpi_status status; + unsigned long long sta; + union acpi_object arg; + struct acpi_object_list arg_list; + + if (!handle) + return AE_BAD_PARAMETER; + + arg_list.count = 1; + arg_list.pointer = &arg; + arg.type = ACPI_TYPE_INTEGER; + arg.integer.value = 1; + status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to power off object %p.\n", handle); + return status; + } + + status = acpi_evaluate_integer(handle, METHOD_NAME__STA, NULL, &sta); + if (ACPI_FAILURE(status)) { + ACPIHP_WARN("fails to evaluate _STA method of object %p\n", + handle); + return status; + } + + if (sta & (ACPI_STA_DEVICE_FUNCTIONING | ACPI_STA_DEVICE_ENABLED)) { + ACPIHP_WARN("object %p is still active after executing _EJ0.\n", + handle); + return AE_ERROR; + } + + return AE_OK; +} + +struct acpihp_slot_ops acpihp_enum_ej0 = { + .init = acpihp_enum_ej0_init, + .fini = acpihp_enum_ej0_fini, + .check = acpihp_enum_ej0_check, + .get_capabilities = acpihp_enum_ej0_get_capabilities, + .poweron = acpihp_enum_ej0_poweron, + .poweroff = acpihp_enum_ej0_poweroff, + .owner = THIS_MODULE, + .desc = "ACPI _EJ0 Based Hotplug Slot Enumerator" +}; -- 1.7.9.5
next prev parent reply other threads:[~2012-08-04 12:13 UTC|newest] Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-04 12:13 [RFC PATCH v2 00/16] ACPI based system device hotplug framework Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 01/16] ACPIHP: introduce a framework for ACPI based system device hotplug Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 02/16] ACPIHP: ACPI system device hotplug slot enumerator Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` Jiang Liu [this message] 2012-08-04 12:13 ` [RFC PATCH v2 03/16] ACPIHP: detect ACPI hotplug slots by checking ACPI _EJ0 method Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 04/16] ACPI: introduce interfaces to manage ACPI device reference count Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 05/16] ACPIHP: scan and walk ACPI devices connecting to an ACPI hotplug slot Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 06/16] ACPIHP: group devices connecting to a hotplug slot according to device types Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 07/16] ACPIHP: add callbacks into acpi_device_ops to support new hotplug framework Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 08/16] ACPIHP: provide interfaces to associate driver specific data to hotplug slots Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 09/16] ACPIHP: implement utility functions to support system device hotplug Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 10/16] ACPIHP: system device hotplug driver skeleton Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-09 7:12 ` Tang Chen 2012-08-09 7:40 ` Jiang Liu 2012-08-09 7:40 ` Jiang Liu 2012-08-09 8:41 ` Tang Chen 2012-08-09 9:36 ` Jiang Liu 2012-08-09 9:36 ` Jiang Liu 2012-08-10 4:39 ` Tang Chen 2012-08-04 12:13 ` [RFC PATCH v2 11/16] ACPIHP: analyse dependences among ACPI system device hotplug slots Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:13 ` [RFC PATCH v2 12/16] ACPIHP: cancel inprogress ACPI system device hotplug operations Jiang Liu 2012-08-04 12:13 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 13/16] ACPIHP: configure/unconfigure system devices connecting to a hotplug slot Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 14/16] ACPIHP: implement the state machine for ACPI hotplug slots Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 15/16] ACPIHP: implement ACPI hotplug sysfs interfaces Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-04 12:14 ` [RFC PATCH v2 16/16] ACPIHP: enhance ACPI container driver to support new hotplug framework Jiang Liu 2012-08-04 12:14 ` Jiang Liu 2012-08-07 23:38 ` [RFC PATCH v2 00/16] ACPI based system device " Toshi Kani 2012-08-08 15:44 ` Jiang Liu 2012-08-08 16:27 ` Bjorn Helgaas 2012-08-09 15:24 ` Jiang Liu 2012-08-08 21:05 ` Toshi Kani
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=1344082443-4608-4-git-send-email-jiang.liu@huawei.com \ --to=jiang.liu@huawei.com \ --cc=bhelgaas@google.com \ --cc=hangaohuai@huawei.com \ --cc=isimatu.yasuaki@jp.fujitsu.com \ --cc=izumi.taku@jp.fujitsu.com \ --cc=kaneshige.kenji@jp.fujitsu.com \ --cc=lenb@kernel.org \ --cc=linux-acpi@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pci@vger.kernel.org \ --cc=liuj97@gmail.com \ --cc=robert.moore@intel.com \ --cc=srivatsa.bhat@linux.vnet.ibm.com \ --cc=tangchen@cn.fujitsu.com \ --cc=tony.luck@intel.com \ --cc=wency@cn.fujitsu.com \ --cc=ying.huang@intel.com \ --cc=yinghai@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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.