Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2199709ybl; Thu, 30 Jan 2020 13:08:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwwnc3kroOkNoQe/y7RmCdt+Ck79JznyvO6q8ww2hRSBVF7HKEGdimsMAN3Fk5V6Udmg5Z7 X-Received: by 2002:a05:6830:18c4:: with SMTP id v4mr4870870ote.265.1580418507808; Thu, 30 Jan 2020 13:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580418507; cv=none; d=google.com; s=arc-20160816; b=k9qr0d0TuHIzz687HDcHw7C1/JLeG0vVQOU/1teBME+vOPr95rO6ZXvdk7L+Buzo97 xhtgsDIgF32hVOJE220kTcdxc9VzdPdkyDRHem7yOko8YaJuwmqDeySSiukBD8ZfJ/dp xj9b493NUUYBoQZa0ZNa2zEJVSZ4K5iv5Ctwvn503ikvHK/uHcfzRXFxRZheSMX5rk1G zkXky+aldhkrLShRNMGSxKE6u4Z4Uz2c6BL0FQk3YrzlKtYIs/F2CjtxJwf8lPtE9Rb+ C3qaytyyYO3VE/qr5ZtvAWwIXqSCgPHeotX56wqZMBBJjbhEZtmL0KFvLrolcW5NlNPm 5Ndw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=+KhBsaQhYAtg/9op0ggWgTDIHD8rbgQILFtHm4y6ZFo=; b=rgMun6tISu0wmUxfK4FiD5WsB8mFw0vYp2UeXuyXC6aLlhvagRby6XgjCgcvJ4WG/Z lG4iOQ1Vf5keO/ZMFufWSg4Qq0hYGbdHU8enY0xBRfMH/tMOn6TC2+O5U4bkaNkIgn6c VnPF+hyguBrHBVH1gKQwsj7O1Mj5aCUsIMcoDxhySV+xNi4447CDrJDNPxNjVa9wBAkF zW+QHNhwvnvqra1lbfNDuZPlUP73l0g3MmCqpR2qwz5ls7prurhCKs8lM3sdx078+ivb qvvui9wSDCOlW1eVIzJju1h0E2bvyrSUEc/vjLAHGOpceVnqeKPdX231rgkBhMXlXZmM WuVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e73si3276660oib.145.2020.01.30.13.08.15; Thu, 30 Jan 2020 13:08:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727547AbgA3VHV (ORCPT + 99 others); Thu, 30 Jan 2020 16:07:21 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:33306 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbgA3VHV (ORCPT ); Thu, 30 Jan 2020 16:07:21 -0500 Received: by mail-oi1-f193.google.com with SMTP id q81so5135034oig.0; Thu, 30 Jan 2020 13:07:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+KhBsaQhYAtg/9op0ggWgTDIHD8rbgQILFtHm4y6ZFo=; b=Hg92ugbkSXmLWCBJuOJK+7+OY/1o6//yBw15l6cqYBJXEexpN6B620zzvVqZDHrHe4 4cAo40MtEgPbkePpidXVDf2hyydSUT6q6SEjazmuJoRZGXy30agu0ADmo5A2Pih567bw 0WcoL8N24yE7JHAmtnzV7WuK9keTurqVGBogNj2FybFNVtqWOFM/gO4+SYscYlldYC2k +5CC/GAPUoqVPfJYYtONxNXQPJp7I7+vlw8MIymy0YrNX/RF9afre8W0759NoNKaQkj4 jv8UvHibgAPuFy3Ei9cj1TlQQNuFKTR6zIt7gAww5p10E6FQuC1K9S3DFn2eISS0G4WP s+9Q== X-Gm-Message-State: APjAAAVWpNLwewGboBwN4Hd2NZJycnNXhBgA8LzE/EK2ajDQPZ/3d3WG 6cLYO2dQMjiDSR24WPq4tCs7PtBXLwiBFWK0zgE= X-Received: by 2002:aca:d6c8:: with SMTP id n191mr4359734oig.103.1580418440279; Thu, 30 Jan 2020 13:07:20 -0800 (PST) MIME-Version: 1.0 References: <20200111022145.GA166025@localhost> In-Reply-To: <20200111022145.GA166025@localhost> From: "Rafael J. Wysocki" Date: Thu, 30 Jan 2020 22:07:09 +0100 Message-ID: Subject: Re: [PATCH] acpi: button: Provide option for power button to directly signal init To: Josh Triplett Cc: "Rafael J. Wysocki" , Len Brown , Jonathan Corbet , Arjan van de Ven , "open list:DOCUMENTATION" , Linux Kernel Mailing List , ACPI Devel Maling List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 11, 2020 at 3:21 AM Josh Triplett wrote: > > Virtual machines and containers often use an ACPI power button event to > tell the machine to shut down gracefully. > > Provide an optional, extremely lightweight way to handle this event by > signaling init directly, rather than running a separate daemon (such as > acpid or systemd-logind) that adds to startup time and VM image > complexity. Well, I'm not convinced. Even though the patch looks straightforward, the approach really is quite not so conceptually and honestly it looks like a band-aid. Also I'm not quite sure why the ACPI button driver is the target of this and not the input layer, for instance. > By default, the power button will continue to notify userspace through > the input layer. With the button.power_signal parameter set, the > power button will instead send the configured signal to init. (For > instance, sending SIGINT will make the power button simulate > ctrl-alt-del.) > > Signed-off-by: Josh Triplett > --- > Documentation/admin-guide/kernel-parameters.txt | 6 ++++++ > drivers/acpi/button.c | 11 +++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index ade4e6ec23e0..bbb598e148f4 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -450,6 +450,12 @@ > firmware feature for flushing multiple hpte entries > at a time. > > + button.power_signal= > + [ACPI] When the power button is pressed, send this > + signal number to the init process. If set to 0 > + (default), do not send a signal. > + Format: integer > + > c101= [NET] Moxa C101 synchronous serial card > > cachesize= [BUGS=X86-32] Override level 2 CPU cache size detection. > diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c > index b758b45737f5..923259f132d6 100644 > --- a/drivers/acpi/button.c > +++ b/drivers/acpi/button.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -167,6 +168,10 @@ static unsigned long lid_report_interval __read_mostly = 500; > module_param(lid_report_interval, ulong, 0644); > MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events"); > > +static int power_signal __read_mostly = 0; > +module_param(power_signal, int, 0644); > +MODULE_PARM_DESC(power_signal, "Power button sends this signal to init"); > + > /* -------------------------------------------------------------------------- > FS Interface (/proc) > -------------------------------------------------------------------------- */ > @@ -426,6 +431,12 @@ static void acpi_button_notify(struct acpi_device *device, u32 event) > if (button->suspended) > break; > > + if (power_signal > + && button->type == ACPI_BUTTON_TYPE_POWER) { > + kill_cad_pid(power_signal, 1); > + break; > + } > + > keycode = test_bit(KEY_SLEEP, input->keybit) ? > KEY_SLEEP : KEY_POWER; > input_report_key(input, keycode, 1); > -- > 2.25.0.rc2 >