From patchwork Fri Dec 13 05:17:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yasuaki Ishimatsu X-Patchwork-Id: 3338061 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 437D49F489 for ; Fri, 13 Dec 2013 05:18:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CF5F207E4 for ; Fri, 13 Dec 2013 05:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9A5D207FD for ; Fri, 13 Dec 2013 05:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750891Ab3LMFSW (ORCPT ); Fri, 13 Dec 2013 00:18:22 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:48857 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750825Ab3LMFSV (ORCPT ); Fri, 13 Dec 2013 00:18:21 -0500 Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 20A803EE0C0; Fri, 13 Dec 2013 14:18:20 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 0AEF445DEC0; Fri, 13 Dec 2013 14:18:17 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.nic.fujitsu.com [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id E210445DD76; Fri, 13 Dec 2013 14:18:16 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id D0954E08003; Fri, 13 Dec 2013 14:18:16 +0900 (JST) Received: from g01jpfmpwyt01.exch.g01.fujitsu.local (g01jpfmpwyt01.exch.g01.fujitsu.local [10.128.193.38]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 76629E08008; Fri, 13 Dec 2013 14:18:16 +0900 (JST) Received: from localhost.localdomain (localhost [127.0.0.1]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id 4B5F36D633F; Fri, 13 Dec 2013 14:18:16 +0900 (JST) Received: from g01jpexchyt33.g01.fujitsu.local (unknown [10.128.193.4]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id CB5D06D6616; Fri, 13 Dec 2013 14:18:14 +0900 (JST) Received: from [127.0.0.1] (10.124.101.123) by g01jpexchyt33.g01.fujitsu.local (10.128.193.36) with Microsoft SMTP Server id 14.3.146.2; Fri, 13 Dec 2013 14:18:13 +0900 X-SecurityPolicyCheck: OK by SHieldMailChecker v2.0.1 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20120718-3 Message-ID: <52AA986C.7050305@jp.fujitsu.com> Date: Fri, 13 Dec 2013 14:17:32 +0900 From: Yasuaki Ishimatsu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "Rafael J. Wysocki" CC: ACPI Devel Maling List , Greg Kroah-Hartman , LKML , Linux PCI , "Moore, Robert" , Toshi Kani , Yinghai Lu , Zhang Rui , Bjorn Helgaas , Mika Westerberg , Aaron Lu , Lv Zheng Subject: Re: [PATCH 7/10] ACPI / hotplug: Move container-specific code out of the core References: <1421028.Rsfpmhnym3@vostro.rjw.lan> <81535269.SKoBMiGyoU@vostro.rjw.lan> <52AA7760.20603@jp.fujitsu.com> <4217831.DpCd0ng0jT@vostro.rjw.lan> In-Reply-To: <4217831.DpCd0ng0jT@vostro.rjw.lan> X-SecurityPolicyCheck-GC: OK by FENCE-Mail Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP (2013/12/13 13:56), Rafael J. Wysocki wrote: > On Friday, December 13, 2013 11:56:32 AM Yasuaki Ishimatsu wrote: >> Hi Rafael, > > Hi, > >> Please share your more detailed idea. I started to implement the following >> idea. But the idea has one problem. >> >>>>> The eject work flow can be: >>>>> (1) an eject event occurs, >>>>> (2) the container "physical" device fails offline in acpi_scan_hot_remove() >>>>> emmitting, say, KOBJ_CHANGE for the "physical" device, >>>>> (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, >>>>> (4) user space changes the "physical" container device flag controlling >>>>> offline to 0, >>>>> (5) user space uses the sysfs "eject" attribute of the ACPI container object >>>>> to finally eject the container, >>>>> (6) the offline in acpi_scan_hot_remove() is now successful, because the >>>>> flag controlling it has been set to 0 in step (4), >>>>> (7) the "physical" container device goes away before executing _EJ0, >>>>> (8) the container is ejected. >> >> I want to emit KOBJ_CHANGE before offlining devices on container device at (2). >> But acpi_scan_hot_remove() offlines devices on container device at first. >> So when offline container device, devices on container has been offlined. >> >> Thus the idea cannot fulfill my necessary feature. > > Well, in that case we need to treat containers in a special way at the ACPI > level. Which is a bit unfortunate so to speak. > > To that end I'd try to add a new flag to struct acpi_hotplug_profile, say > .verify_offline, such that if set, it would cause acpi_scan_hot_remove() to > check if all of the "physical" companions of the top-level device are offline > to start with, and if not, it would just emit KOBJ_CHANGE for the companions > that are not offline and bail out. > > So the above algorithm would become: > > (1) an eject event occurs, > (2) acpi_scan_hot_remove() checks the verify_offline flag in the target device's > scan_handler structure, > (3) if set (it would always be set for containers), acpi_scan_hot_remove() > checks the status of the target device's "physical" companions; if at least > one of them is offline, KOBJ_CHANGE is emitted for that "physical" device, > and acpi_scan_hot_remove() returns, [I guess we can just emit KOBJ_CHANGE > for the first companion that is not offline at this point.] > (4) user space notices the KOBJ_CHANGE and does the cleanup as needed; in the > process it carries out the offline operation for the container's "physical" > companion (there's only one such companion for each container), [That > operation for the container itself is trivial, but to succeed it requires > all devices below the container to be taken offline in advance.] > (5) user space uses the sysfs "eject" attribute of the ACPI container object > to finally eject the container, > (6) acpi_scan_hot_remove() is now successful, because the container's "physical" > companion is now offline, > (7) the "physical" container device goes away before executing _EJ0, > (8) the container is ejected. > > I think that should work for you. This idea seems to same as your previous work. http://lkml.org/lkml/2013/2/23/97 How about add autoremove flag into acpi_hotplug_profile and check it as follow: --- drivers/acpi/scan.c | 5 +++++ 1 file changed, 5 insertions(+) Adding the check into "acpi_hotplug_notify_cb()", user need not change the flag for removing container device by "sysfs eject". Thanks, Yasuaki Ishimatsu > > Thanks, > Rafael > -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5383c81..c43d110 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -409,6 +409,11 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; goto err_out; } + if (!handler->hotplug.autoremove) { + kobject_uevent(&device->dev.kobj, KOBJ_CHANGE); + ost_code = ACPI_OST_SC_EJECT_NON_SPECIFIC_FAILURE; + goto err_out; + } acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); break;