From patchwork Mon Apr 3 15:55:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 9659895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 285326032D for ; Mon, 3 Apr 2017 15:55:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1018928111 for ; Mon, 3 Apr 2017 15:55:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0263F281AA; Mon, 3 Apr 2017 15:55:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17A1A28111 for ; Mon, 3 Apr 2017 15:55:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752144AbdDCPzm (ORCPT ); Mon, 3 Apr 2017 11:55:42 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36129 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbdDCPzl (ORCPT ); Mon, 3 Apr 2017 11:55:41 -0400 Received: by mail-wr0-f196.google.com with SMTP id k6so33405400wre.3; Mon, 03 Apr 2017 08:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=brNfuP3/gjvXL48x7pFz1P0qSmQpCzv7FXH1btTq2pg=; b=TdGRY20lm3t9WS0g2HVtp7tVB1v5lYYbRNkp5QmmXUQDbCSLLblQdUvcsA6o8HCTR8 pjsSdSTjR8n/42VqiyKiuuzRm7ufyjzCmZ6iaHqs/GMTe0oweV7ycdf6Hy+2k45eKCwt gfXpb5qGUSlKm1dbV7fxCuBPDfTPGOb+YQ0Unzbu7+fYct1V3UYNCXdmYSuiJfXG5/6h 0dbKFHZfp4oFbFcuBzppNPony7RIa+/158Fi1znRWSWaRZI9Hn9AlqwuIQS/0khwwwiV yT6m04QQ9rlXv0YyfM3brXFZiukjSfj21vC/b2QY1a+1pDlRzeQOECaXT6HTTrKXsOiD NKIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=brNfuP3/gjvXL48x7pFz1P0qSmQpCzv7FXH1btTq2pg=; b=I8xU3dMxYjU2T7eM4w2q9+jfJ5qKZJ4Ucxd/USD8s+TygwJUbsTxYxIlDNZMhL2fM3 lodLLf9RFx9Rl5Ij/I6FuyPsX97zdrn8loDhCyVIVUPLPxjA2jO3onPGNSZMcTakZf0B eofE743wavPKQCxHR2J6Ip/k7t8kVODj0dPF2oQWVaAI/yf7nnCJCfQ7rmV1ZmtZhf2E 3IWq8ScyC4a41INOAmMc41HVtjdyAZiOv6ch42nNzTtR3aAUhCpyy1UpNkigawpTKhxR d9rX9EtjqRW5pELmTtLUriPmhPeqPeKirKjnMnYgVtku87n30QCYL5VuhXwrcG/Zg2EW m6Rw== X-Gm-Message-State: AFeK/H1IjqmIiSHE9BsXg8FB4j78BeVYHiWKS6TFKZIuMqb+b5zpl7VN fO60jh2r1pmALmZH X-Received: by 10.28.10.70 with SMTP id 67mr10321976wmk.131.1491234939860; Mon, 03 Apr 2017 08:55:39 -0700 (PDT) Received: from linux-uc2j.suse.cz ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id 46sm18832656wru.37.2017.04.03.08.55.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 08:55:38 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: "Rafael J . Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Michal Hocko , Jiri Kosina Subject: [PATCH] ACPI: emits change uevents to all physical companion devices of container's children Date: Mon, 3 Apr 2017 23:55:33 +0800 Message-Id: <20170403155533.30283-1-jlee@suse.com> X-Mailer: git-send-email 2.10.2 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The caa73ea1 patch, "ACPI / hotplug / driver core: Handle containers in a special way", introduced the offline callback of acpi container. In the patch description, it mentions: For ACPI containers that callback simply walks the list of ACPI device objects right below the container object (its children) and checks if all of their physical companion devices are offline. If that's not the case, it returns -EBUSY and the container system devivce cannot be put offline. Consequently, to put the container system device offline, it is necessary to put all of the physical devices depending on its ACPI companion object offline beforehand. Looks that it means acpi_container_offline() should walks all physical companion devices of container's children and checks their offline state. And, the comment in source code is "Check all of the dependent devices' physical companions", which means it should checks _all_ physical companions. But, the checking code just stops at the first not-offlined physical companion device of the first not-offlined child, then kernel only emits KOBJ_CHANGE uevent to the one device. It doesn't really walk all children's all physical companion devices and doesn't send change uevent to them. This causes that usespace can only receive one uevent for one physical companion device in acpi container when acpi container offline is triggered. Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Michal Hocko Cc: Jiri Kosina Signed-off-by: "Lee, Chun-Yi" --- drivers/acpi/container.c | 5 +++-- drivers/acpi/scan.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 12c2409..1f1537d 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c @@ -43,13 +43,14 @@ static int acpi_container_offline(struct container_dev *cdev) { struct acpi_device *adev = ACPI_COMPANION(&cdev->dev); struct acpi_device *child; + int ret = 0; /* Check all of the dependent devices' physical companions. */ list_for_each_entry(child, &adev->children, node) if (!acpi_scan_is_offline(child, false)) - return -EBUSY; + ret = -EBUSY; - return 0; + return ret; } static void acpi_container_release(struct device *dev) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 1926918..1a9055c 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -134,7 +134,6 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE); offline = false; - break; } mutex_unlock(&adev->physical_node_lock);