From patchwork Tue Mar 20 05:51:26 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: 10296417 X-Patchwork-Delegate: rjw@sisk.pl 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 944EF60386 for ; Tue, 20 Mar 2018 05:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75EFC2883B for ; Tue, 20 Mar 2018 05:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A8E62929E; Tue, 20 Mar 2018 05:51:45 +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 584D72883B for ; Tue, 20 Mar 2018 05:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750986AbeCTFvm (ORCPT ); Tue, 20 Mar 2018 01:51:42 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:34578 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750888AbeCTFvm (ORCPT ); Tue, 20 Mar 2018 01:51:42 -0400 Received: by mail-io0-f193.google.com with SMTP id r18so848845ioa.1; Mon, 19 Mar 2018 22:51:41 -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=kGLUTaa9cNyPmec7M/qp4WBOMgI4pCcQamWPP5kxEAM=; b=V7DcYq3Af62B1lAZyoD5V6Xy8rF8192VX3CrztTDT1mAIWG8NSxUWfkc8qFEOq1JPy W3mvPbEwoqZdmAArexOOpazRbesEA4eoIB1++DyQQ+Edu8hQmppJgv9z3k/mIdyhnSJG 1kkOKKfvImNVwhLet9591JJ0yZY5C9EPLbhYyeqHB9mZ1WywwQsAcvLJfEMIbwWeh1Ad WrjsHqp4qEzsgr5ot0d817cAEzCNugGKaENsgahk0gMe98axYAu10HEd3CQ9stCNLZvV pmxlWcDTgzY9hgFCCqrFiwdMZpDRRQUeqqtoYrfgDascMaRkWKPp0oK36yPMPdldjjVZ sUjw== 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=kGLUTaa9cNyPmec7M/qp4WBOMgI4pCcQamWPP5kxEAM=; b=nPzC/Xuew3AchXw1mgfO+q3N6z9svvSqBndrJk1biPjPK4MB08AqEh4s/hrcRftPhD x6/sqKlBT01CmnOZQPQWKdqXe7mTIu7B5tq6vqzpp8hSWMphIeLaVIi8DjoVQvBmO/GM hHYQTrpceub0zMHvcGSZ7YzYxWVox7TYCIYPxlZMW/d35zhzEvd6FTsSVvjruMlMPShQ OSczznlS22Din3iRNdgg9Ma+FU+FR/+z3INnV+ajxOHzxhtfvE/IoEYNAlsoWlwEeqrp I7p1mdzxAvuuFCpfuKCts9Gq3Ki1JDMrG9X0wolrlvQfzl8GVEQDics8iDXKbQcxsP0o vP4w== X-Gm-Message-State: AElRT7HR2J05Cl7rVvxTx7LzOlQ2mUFi4aG6eWppJ0VaoQ2DMX/+WDUU ZCnrpkbRW+AVAzU3N+xyd8c= X-Google-Smtp-Source: AG47ELsrcZOHfOCTq2rMENafufk/2nSI4MbCaPfHtZLRW/U9A9k5bwauA1TN716o8qb2tTaZB5OdhQ== X-Received: by 10.107.138.193 with SMTP id c62mr14254314ioj.280.1521525101298; Mon, 19 Mar 2018 22:51:41 -0700 (PDT) Received: from linux-l9pv.suse ([134.159.103.118]) by smtp.gmail.com with ESMTPSA id s4-v6sm492839ita.36.2018.03.19.22.51.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Mar 2018 22:51:40 -0700 (PDT) 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" , Len Brown Subject: [PATCH v2] ACPI / scan: Send the change uevent with offine environmental data Date: Tue, 20 Mar 2018 13:51:26 +0800 Message-Id: <20180320055126.8671-1-jlee@suse.com> X-Mailer: git-send-email 2.12.3 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. v2: Fix build warning for the environmental string Cc: "Rafael J. Wysocki" Cc: Len Brown Acked-by: Michal Hocko Tested-by: Michal Hocko Signed-off-by: "Lee, Chun-Yi" --- 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..490498e 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; + 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;