From patchwork Thu Jan 10 23:40:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toshi Kani X-Patchwork-Id: 211168 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 43E452C05E9 for ; Fri, 11 Jan 2013 11:01:51 +1100 (EST) X-Greylist: delayed 599 seconds by postgrey-1.34 at bilbo; Fri, 11 Jan 2013 11:00:38 EST Received: from g6t0187.atlanta.hp.com (g6t0187.atlanta.hp.com [15.193.32.64]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "smtp.hp.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 613E62C0093 for ; Fri, 11 Jan 2013 11:00:38 +1100 (EST) Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g6t0187.atlanta.hp.com (Postfix) with ESMTP id 89FC3280E4; Thu, 10 Jan 2013 23:51:06 +0000 (UTC) Received: from misato.fc.hp.com (misato.fc.hp.com [16.71.12.41]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 9A95A1411C; Thu, 10 Jan 2013 23:51:05 +0000 (UTC) From: Toshi Kani To: rjw@sisk.pl, lenb@kernel.org, gregkh@linuxfoundation.org, akpm@linux-foundation.org Subject: [RFC PATCH v2 10/12] ACPI: Update container driver for hotplug framework Date: Thu, 10 Jan 2013 16:40:28 -0700 Message-Id: <1357861230-29549-11-git-send-email-toshi.kani@hp.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1357861230-29549-1-git-send-email-toshi.kani@hp.com> References: <1357861230-29549-1-git-send-email-toshi.kani@hp.com> Cc: linux-s390@vger.kernel.org, Toshi Kani , jiang.liu@huawei.com, wency@cn.fujitsu.com, linux-mm@kvack.org, yinghai@kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, isimatu.yasuaki@jp.fujitsu.com, srivatsa.bhat@linux.vnet.ibm.com, guohanjun@huawei.com, bhelgaas@google.com, linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Changed container_notify_cb() to request a hotplug operation by calling shp_submit_req(). It no longer initiates hot-add by calling acpi_bus_add(). Also, it no longer sets device->flags.eject_pending and generates KOBJ_OFFLINE event for hot-delete. Signed-off-by: Toshi Kani --- drivers/acpi/container.c | 95 ++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 58 deletions(-) diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 811910b..89af4fc 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c @@ -35,6 +35,7 @@ #include #include #include +#include #define PREFIX "ACPI: " @@ -135,77 +136,37 @@ static int acpi_container_remove(struct acpi_device *device, int type) return status; } -static int container_device_add(struct acpi_device **device, acpi_handle handle) -{ - acpi_handle phandle; - struct acpi_device *pdev; - int result; - - - if (acpi_get_parent(handle, &phandle)) { - return -ENODEV; - } - - if (acpi_bus_get_device(phandle, &pdev)) { - return -ENODEV; - } - - if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) { - return -ENODEV; - } - - result = acpi_bus_start(*device); - - return result; -} - -static void container_notify_cb(acpi_handle handle, u32 type, void *context) +static void container_notify_cb(acpi_handle handle, u32 event, void *context) { struct acpi_device *device = NULL; - int result; - int present; - acpi_status status; + struct shp_request *shp_req; + enum shp_operation shp_op; u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ - switch (type) { + switch (event) { case ACPI_NOTIFY_BUS_CHECK: /* Fall through */ case ACPI_NOTIFY_DEVICE_CHECK: - pr_debug("Container driver received %s event\n", - (type == ACPI_NOTIFY_BUS_CHECK) ? - "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); - - present = is_device_present(handle); - status = acpi_bus_get_device(handle, &device); - if (!present) { - if (ACPI_SUCCESS(status)) { - /* device exist and this is a remove request */ - device->flags.eject_pending = 1; - kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); - return; - } - break; + if (!is_device_present(handle)) { + acpi_handle_err(handle, "Device not enabled\n"); + goto err; } - if (!ACPI_FAILURE(status) || device) - break; - - result = container_device_add(&device, handle); - if (result) { - acpi_handle_warn(handle, "Failed to add container\n"); - break; + if (!acpi_bus_get_device(handle, &device)) { + acpi_handle_err(handle, "Device added already\n"); + goto err; } - kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); - ost_code = ACPI_OST_SC_SUCCESS; + shp_op = SHP_HOTPLUG_ADD; break; case ACPI_NOTIFY_EJECT_REQUEST: - if (!acpi_bus_get_device(handle, &device) && device) { - device->flags.eject_pending = 1; - kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); - return; + if (acpi_bus_get_device(handle, &device)) { + acpi_handle_err(handle, "Device not added yet\n"); + goto err; } + + shp_op = SHP_HOTPLUG_DEL; break; default: @@ -213,8 +174,26 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) return; } - /* Inform firmware that the hotplug operation has completed */ - (void) acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); + shp_req = shp_alloc_request(shp_op); + if (!shp_req) { + acpi_handle_err(handle, "No memory to request hotplug\n"); + goto err; + } + + shp_req->handle = (void *)handle; + shp_req->event = event; + + if (shp_submit_req(shp_req)) { + acpi_handle_err(handle, "Failed to request hotplug\n"); + kfree(shp_req); + goto err; + } + + return; + +err: + /* Inform firmware that the hotplug operation completed w/ error */ + (void) acpi_evaluate_hotplug_ost(handle, event, ost_code, NULL); return; }