From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lv Zheng Subject: [PATCH v2 3/3] ACPI / button: Send "open" state after boot/resume Date: Fri, 27 May 2016 15:16:05 +0800 Message-ID: <4472be3d63af1b56c2f0f7cfbccd73538dc36252.1464332745.git.lv.zheng@intel.com> References: Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, "Bastien Nocera:" List-Id: linux-acpi@vger.kernel.org Linux userspace (systemd-logind) keeps on rechecking lid state when the lid state is closed. If it failed to update the lid state to open after boot/resume, the system suspending right after the boot/resume could be resulted. Graphics drivers also uses the lid notifications to implment MODESET_ON_LID_OPEN option. Before the situation is improved from the userspace and from the graphics driver, simply send initial "open" lid state to avoid issues. After this is improved from the userspace and from the graphics driver, Linux kernel could simply revert this minimal commit. Link 1: https://lkml.org/2016/3/7/460 Link 2: https://github.com/systemd/systemd/issues/2087 Signed-off-by: Lv Zheng Cc: Bastien Nocera: --- drivers/acpi/button.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index e706e4b..6e77312 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -342,6 +342,8 @@ static int acpi_button_resume(struct device *dev) struct acpi_button *button = acpi_driver_data(device); button->suspended = false; + if (button->type == ACPI_BUTTON_TYPE_LID) + return acpi_lid_notify_state(device, 1); return 0; } #endif @@ -422,6 +424,7 @@ static int acpi_button_add(struct acpi_device *device) if (error) goto err_remove_fs; if (button->type == ACPI_BUTTON_TYPE_LID) { + (void)acpi_lid_notify_state(device, 1); /* * This assumes there's only one lid device, or if there are * more we only care about the last one... -- 1.7.10 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755670AbcE0HQR (ORCPT ); Fri, 27 May 2016 03:16:17 -0400 Received: from mga04.intel.com ([192.55.52.120]:28482 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754893AbcE0HQO (ORCPT ); Fri, 27 May 2016 03:16:14 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,372,1459839600"; d="scan'208";a="709690537" From: Lv Zheng To: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org, "Bastien Nocera:" Subject: [PATCH v2 3/3] ACPI / button: Send "open" state after boot/resume Date: Fri, 27 May 2016 15:16:05 +0800 Message-Id: <4472be3d63af1b56c2f0f7cfbccd73538dc36252.1464332745.git.lv.zheng@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linux userspace (systemd-logind) keeps on rechecking lid state when the lid state is closed. If it failed to update the lid state to open after boot/resume, the system suspending right after the boot/resume could be resulted. Graphics drivers also uses the lid notifications to implment MODESET_ON_LID_OPEN option. Before the situation is improved from the userspace and from the graphics driver, simply send initial "open" lid state to avoid issues. After this is improved from the userspace and from the graphics driver, Linux kernel could simply revert this minimal commit. Link 1: https://lkml.org/2016/3/7/460 Link 2: https://github.com/systemd/systemd/issues/2087 Signed-off-by: Lv Zheng Cc: Bastien Nocera: --- drivers/acpi/button.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index e706e4b..6e77312 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -342,6 +342,8 @@ static int acpi_button_resume(struct device *dev) struct acpi_button *button = acpi_driver_data(device); button->suspended = false; + if (button->type == ACPI_BUTTON_TYPE_LID) + return acpi_lid_notify_state(device, 1); return 0; } #endif @@ -422,6 +424,7 @@ static int acpi_button_add(struct acpi_device *device) if (error) goto err_remove_fs; if (button->type == ACPI_BUTTON_TYPE_LID) { + (void)acpi_lid_notify_state(device, 1); /* * This assumes there's only one lid device, or if there are * more we only care about the last one... -- 1.7.10