From patchwork Mon May 6 12:27:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 2523951 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C52363FC5A for ; Mon, 6 May 2013 12:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752873Ab3EFMdY (ORCPT ); Mon, 6 May 2013 08:33:24 -0400 Received: from mga01.intel.com ([192.55.52.88]:61557 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752280Ab3EFMdX (ORCPT ); Mon, 6 May 2013 08:33:23 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 06 May 2013 05:33:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,621,1363158000"; d="scan'208";a="329524512" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.36.18]) by fmsmga001.fm.intel.com with ESMTP; 06 May 2013 05:33:22 -0700 From: Lan Tianyu To: rjw@sisk.pl, lenb@kernel.org Cc: Lan Tianyu , linux-acpi@vger.kernel.org Subject: [FIX PATCH] ACPI/AC: Add sleep quirk for Thinkpad e530 Date: Mon, 6 May 2013 20:27:33 +0800 Message-Id: <1367843253-13021-1-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Thinkpad e530 bios notify ac device first and then sleep a specific time before doing actual operations in the EC event handler(_Qxx). This will cause the AC state reported by ACPI event. Method (_Q27, 0, NotSerialized) { Notify (AC, 0x80) Sleep (0x03E8) Store (Zero, PWRS) PNOT () } This patch is to add a 1s sleep in the ac driver's notify handler before acpi_ac_get_state() to make sure get right state. https://bugzilla.kernel.org/show_bug.cgi?id=45221 Signed-off-by: Lan Tianyu --- drivers/acpi/ac.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 6d5bf64..0292cbb 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #ifdef CONFIG_ACPI_PROCFS_POWER #include #include @@ -74,6 +76,8 @@ static int acpi_ac_resume(struct device *dev); #endif static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); +static int ac_flag_sleep_for_get_state; + static struct acpi_driver acpi_ac_driver = { .name = "ac", .class = ACPI_AC_CLASS, @@ -252,6 +256,15 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event) case ACPI_AC_NOTIFY_STATUS: case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_DEVICE_CHECK: + /* Some buggy bios notify ac device first and then sleep + * a specific time before doing actual operations in the + * EC event handler(_Qxx). This will cause the AC state + * reported by ACPI event wrong. So add a 1s sleep here + * to ensure get correct state. + */ + if (ac_flag_sleep_for_get_state) + msleep(1000); + acpi_ac_get_state(ac); acpi_bus_generate_proc_event(device, event, (u32) ac->state); acpi_bus_generate_netlink_event(device->pnp.device_class, @@ -264,6 +277,24 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event) return; } +static int ac_sleep_for_get_state(const struct dmi_system_id *d) +{ + ac_flag_sleep_for_get_state = 1; + return 0; +} + +static struct dmi_system_id __initdata ac_dmi_table[] = { + { + .callback = ac_sleep_for_get_state, + .ident = "thinkpad e530", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "32597CG"), + }, + }, + {}, +}; + static int acpi_ac_add(struct acpi_device *device) { int result = 0; @@ -312,6 +343,7 @@ static int acpi_ac_add(struct acpi_device *device) kfree(ac); } + dmi_check_system(ac_dmi_table); return result; }