From patchwork Fri Mar 2 06:35:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 10253531 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 41D1F603ED for ; Fri, 2 Mar 2018 06:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 349E02882E for ; Fri, 2 Mar 2018 06:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28DBC28846; Fri, 2 Mar 2018 06:35:17 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 512D22882E for ; Fri, 2 Mar 2018 06:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936024AbeCBGfP (ORCPT ); Fri, 2 Mar 2018 01:35:15 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34384 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933010AbeCBGfO (ORCPT ); Fri, 2 Mar 2018 01:35:14 -0500 Received: by mail-pf0-f194.google.com with SMTP id j20so3586654pfi.1; Thu, 01 Mar 2018 22:35:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DyFe2sukaoddhFImNvyOG9CSsf/X31riqQI0WUmsgXA=; b=Z+qTDSZn6hG1jDQizxGzKJLvUiXLYuI6+Vs8uvK5varkyQ2voTI1z6vHtbUvQg+dcD QzhqSK+lIrotKM+nTOw+IA4Eqw69jALSTOrK2Wmanu7I4LR6i0T3KbEFeawPdgAwkzQC J0BoZ3wMFm1daqz3shB/UOLZEuXc1KsCSHjEAmQWT73vLKUHPoCmQv3QVRAhoUayt9j6 sSPb9NQ+0YVD+ko/Aq7Zo/haMsWCH0iz1gBEF5cHgyCkFcebnDojGNIsYe6fX7C0qQwf 6gms8x74Li9WyqkXnLFA4MuxDTmDEU8OhJj2ZbkOiCkO96N2CupXAZRXwcL8ZSujqxst zX/w== 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=DyFe2sukaoddhFImNvyOG9CSsf/X31riqQI0WUmsgXA=; b=UDrnYrJPft67bdp2jFfPlGuXWs+w5Cgpl5dkcCo6EqcQ43JBDyw4wfpa7jStOP9SGK HuUApOgYNXiC8IYrFUljRkwqG1RPuhYHb6C3sY1YGZculMDBQFWJIJFEkTdRI0iSQcu6 F3u2Q2/LXtxDSgQM6BReFDowxf917DTvZYV4shK5JfNKmiQf84k3iAytsXmHU7e1Y2Fx R2moyFHmcPFNBaoO9/lfjprV3meT5raxX4Yzk5GjV3Isj8L0+ovczK3VtcBj+olPn5BU tXpM37WzuXSC3vlYCcg31u5SD9SVjfvoKG4cQLB/dkXHKhzgqlo8MA20/ey2qwJxEo9L vK7w== X-Gm-Message-State: APf1xPDkeUADvlZAEKgkUUS3usjiJssxNFQLVuY74MjX04a6rIPUdH3C koLB/HaxhF6NFsYeIsFrCnk= X-Google-Smtp-Source: AG47ELseOOhupj4673xUzyCHjMRW/ixUmge6iWh3h+FDzRHDaDfuzeK04qW1rlCuooklKZAKctGp/g== X-Received: by 10.101.80.68 with SMTP id k4mr3675224pgo.81.1519972513702; Thu, 01 Mar 2018 22:35:13 -0800 (PST) Received: from linux-uc2j.site ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id 73sm7682544pfz.165.2018.03.01.22.35.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 22:35:12 -0800 (PST) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: "Rafael J . Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Michal Hocko , Len Brown Subject: [PATCH] ACPI / scan: Send the change uevent with offine environmental data Date: Fri, 2 Mar 2018 14:35:08 +0800 Message-Id: <20180302063508.15818-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 In current design of ACPI container offline, Kernel emits KOBJ_CHANGE uevent to user space to indidate that the ejection of the container was triggered by platform. (caa73ea15 patch) A pure KOBJ_CHANGE uevent is not enough for user space to identify the purpose. For example, a "udevadm trigger" command can also be used to emit change event to all udev rules. A udev rule can not identify that the event is from kernel for offline or from udevadm for other purpose. Then the offline action in udev rule may also be triggered by udevadm tool. So, similar to the change uevent of dock, kernel sends the KOBJ_CHANGE uevent with a offline environmental data to indicate purpose. It's useful by udev rule for using ENV{EVENT} filter. Cc: Michal Hocko Cc: "Rafael J. Wysocki" Cc: Len Brown Signed-off-by: "Lee, Chun-Yi" Acked-by: Michal Hocko Tested-by: Michal Hocko --- drivers/acpi/scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 8e63d93..f6dca9b 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -116,6 +116,7 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) { struct acpi_device_physical_node *pn; bool offline = true; + static const char *envp[] = { "EVENT=offline", NULL }; /* * acpi_container_offline() calls this for all of the container's @@ -126,7 +127,7 @@ bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) list_for_each_entry(pn, &adev->physical_node_list, node) if (device_supports_offline(pn->dev) && !pn->dev->offline) { if (uevent) - kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE); + kobject_uevent_env(&pn->dev->kobj, KOBJ_CHANGE, envp); offline = false; break;