From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4F82C2D0DB for ; Thu, 30 Jan 2020 21:07:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703FB20708 for ; Thu, 30 Jan 2020 21:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580418442; bh=4P4sREC3cYV+vUNSvGXYnC5xTKG+r+SiT9QXQomCSNA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=FmAgJ5/q1I2lMNRZwM132Djf9DrA6NUndD97ktOskNbkYfUReS17xzI94PZSODUrF 5oqckC0uOeDkBsA+AOS/jX+mZ7wUHC59f8a9IUL5gQkP9Kv6wa4cXpx53peFjkfpzn FRUVyX3GxUAaJCrk9eOuZij1ejeqX79Zu/CJqClM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727089AbgA3VHV (ORCPT ); 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-Google-Smtp-Source: APXvYqyl510fC9XqZsVw4DYiTbSHXnTxOvhV5KaMTO1VWv/L/jyTAjwQPata1SThgOjatlzBGwd4Q2asPWdLs4/wV/o= 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-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@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 >