From patchwork Tue May 9 07:02:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 9717111 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 4DCC160237 for ; Tue, 9 May 2017 07:02:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 407E4269DA for ; Tue, 9 May 2017 07:02:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3489D282E8; Tue, 9 May 2017 07:02:36 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 BB61A269DA for ; Tue, 9 May 2017 07:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751166AbdEIHCe (ORCPT ); Tue, 9 May 2017 03:02:34 -0400 Received: from mga09.intel.com ([134.134.136.24]:11430 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdEIHCe (ORCPT ); Tue, 9 May 2017 03:02:34 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2017 00:02:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,313,1491289200"; d="scan'208";a="1166567070" Received: from surface-pro-3.sh.intel.com ([10.239.159.52]) by fmsmga002.fm.intel.com with ESMTP; 09 May 2017 00:02:31 -0700 From: Lv Zheng To: "Rafael J . Wysocki" , "Rafael J . Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , linux-acpi@vger.kernel.org Subject: [PATCH v2 2/5] ACPI: button: Add button.lid_init_state=close Date: Tue, 9 May 2017 15:02:30 +0800 Message-Id: <7c7f3a265974fb1f885dbfafcc0b97adc7b72f3b.1494311429.git.lv.zheng@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <2a779ae8c280c968b3237ac4a3d9580df7262a46.1493951798.git.lv.zheng@intel.com> References: <2a779ae8c280c968b3237ac4a3d9580df7262a46.1493951798.git.lv.zheng@intel.com> 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 We have tested that: 1. If ACPI button driver sends "open" to the user space but _LID return value to the kernel space, external monitor issues still cannot be fixed (link #1, comment #33, test result #2), while 2. if ACPI button driver sends "close" to the user space but _LID return value to the kernel space, external monitor issues can be fixed (link #1, comment #33, test result #3). We knew that some platforms require "open" to be sent to the user space to avoid entering a suspend/resume loop. So we have 2 contradictory user space requirements and are not possible to fix them both in 1 kernel driver mode without using platform specific quirks. This actually can also be treated as a proof that the root causes of the bugs are not in the kernel button driver but in the user space usage models. This patch adds button.lid_init_state=close so that it can explicitly explain the contradictory requirements and help the kernel community to raise such bugs to the correct responsibles. Link: https://bugzilla.kernel.org/show_bug.cgi?id=195455 [#1] Link: https://bugzilla.redhat.com/show_bug.cgi?id=1430259 Tested-by: Steffen Weber Tested-by: Julian Wiedmann Reported-by: Joachim Frieben Signed-off-by: Lv Zheng --- Documentation/acpi/acpi-lid.txt | 12 +++++++----- drivers/acpi/button.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Documentation/acpi/acpi-lid.txt b/Documentation/acpi/acpi-lid.txt index effe7af..e846a59 100644 --- a/Documentation/acpi/acpi-lid.txt +++ b/Documentation/acpi/acpi-lid.txt @@ -69,13 +69,15 @@ A. button.lid_init_state=method: notification is missing. This option is the default behavior during the period the userspace isn't ready to handle the buggy AML tables. -B. button.lid_init_state=open: - When this option is specified, the ACPI button driver always reports the - initial lid state as "opened" and whether the "opened"/"closed" events - are paired fully relies on the firmware implementation. +B. button.lid_init_state=open/close: + When one of these options are specified, the ACPI button driver always + reports the initial lid state as fixed "opened"/"closed" and whether the + "opened"/"closed" events are paired fully relies on the firmware + implementation. This may fix some platforms where the returning value of the _LID control method is not reliable and the initial lid state notification is - missing. + missing. Especially useful for platforms where different usage models + require contractory initial lid state. If the userspace has been prepared to ignore the unreliable "opened" events and the unreliable initial state notification, Linux users should always diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 6d5a8c1..8b4666f 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -57,7 +57,8 @@ #define ACPI_BUTTON_LID_INIT_IGNORE 0x00 #define ACPI_BUTTON_LID_INIT_OPEN 0x01 -#define ACPI_BUTTON_LID_INIT_METHOD 0x02 +#define ACPI_BUTTON_LID_INIT_CLOSE 0x02 +#define ACPI_BUTTON_LID_INIT_METHOD 0x03 #define _COMPONENT ACPI_BUTTON_COMPONENT ACPI_MODULE_NAME("button"); @@ -377,6 +378,9 @@ static void acpi_lid_initialize_state(struct acpi_device *device) case ACPI_BUTTON_LID_INIT_OPEN: (void)acpi_lid_notify_state(device, 1); break; + case ACPI_BUTTON_LID_INIT_CLOSE: + (void)acpi_lid_notify_state(device, 0); + break; case ACPI_BUTTON_LID_INIT_METHOD: (void)acpi_lid_update_state(device); break; @@ -563,6 +567,9 @@ static int param_set_lid_init_state(const char *val, struct kernel_param *kp) if (!strncmp(val, "open", sizeof("open") - 1)) { lid_init_state = ACPI_BUTTON_LID_INIT_OPEN; pr_info("Notify initial lid state as open\n"); + } else if (!strncmp(val, "close", sizeof("close") - 1)) { + lid_init_state = ACPI_BUTTON_LID_INIT_CLOSE; + pr_info("Notify initial lid state as close\n"); } else if (!strncmp(val, "method", sizeof("method") - 1)) { lid_init_state = ACPI_BUTTON_LID_INIT_METHOD; pr_info("Notify initial lid state with _LID return value\n"); @@ -579,6 +586,8 @@ static int param_get_lid_init_state(char *buffer, struct kernel_param *kp) switch (lid_init_state) { case ACPI_BUTTON_LID_INIT_OPEN: return sprintf(buffer, "open"); + case ACPI_BUTTON_LID_INIT_CLOSE: + return sprintf(buffer, "close"); case ACPI_BUTTON_LID_INIT_METHOD: return sprintf(buffer, "method"); case ACPI_BUTTON_LID_INIT_IGNORE: