From patchwork Wed Apr 29 20:21:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Bainbridge X-Patchwork-Id: 6298081 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 708B4BEEE1 for ; Wed, 29 Apr 2015 20:21:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FF662017D for ; Wed, 29 Apr 2015 20:21:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A836E20160 for ; Wed, 29 Apr 2015 20:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750729AbbD2UVp (ORCPT ); Wed, 29 Apr 2015 16:21:45 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36497 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750737AbbD2UVp (ORCPT ); Wed, 29 Apr 2015 16:21:45 -0400 Received: by wizk4 with SMTP id k4so194355188wiz.1 for ; Wed, 29 Apr 2015 13:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=aPJwRn7tGaDc1ioKH42ukC9mniB7ViILmFrGo1cfoN0=; b=xA6tAo97kb+4/YbnpEUkxS4d6O9ta9QteTw2dAKdc24Jh0WWDufmdl7519cOWBn2MM h2GNPZNzt8HAcHlcsMditsv1C/6b8Va5ySvA0yrJqUk9tLwDpvzr2YIQyC62iJCUx93L 9sVUHHiUIigIxc0QCBc8yX/lejbarUKOLIwh2/6m/KYP+jdahzp+FdVU/CEeg19dQhYq +QO/IeaLTXUf3VEHxYF2pkQk6/iiKHPGAVEqHIZatLnK8yUKmT3NAQLtU0plWgvlBAVi CMVw3nuLS3C+Kcfo3y1TPX79EmcGITrtTI1Hy99LMvd5p2bQ6WH39Y53gBWnig2nqTei TF/Q== X-Received: by 10.180.83.6 with SMTP id m6mr12133820wiy.72.1430338904060; Wed, 29 Apr 2015 13:21:44 -0700 (PDT) Received: from localhost (cpc2-sgyl32-2-0-cust142.sgyl.cable.virginm.net. [77.97.242.143]) by mx.google.com with ESMTPSA id n1sm689976wix.0.2015.04.29.13.21.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 13:21:43 -0700 (PDT) Date: Wed, 29 Apr 2015 21:21:40 +0100 From: Chris Bainbridge To: "Rafael J. Wysocki" Cc: Len Brown , linux-acpi@vger.kernel.org Subject: [PATCH] ACPI/sbshc: Add 5us delay to fix SBS hang on MacBook Message-ID: <20150429202140.GB25904@localhost> References: <20150424012530.GA16763@localhost> <4435249.leKkNHm9IZ@vostro.rjw.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4435249.leKkNHm9IZ@vostro.rjw.lan> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Regression in commit 7bc5a2bad0b8d9d1ac9f7b8b33150e4ddf197334 Author: Matthew Garrett Date: Sat Sep 20 13:19:47 2014 +0200 ACPI: Support _OSI("Darwin") correctly Supporting _OSI("Darwin") caused the MacBook firmware to expose the SBS, resulting in intermittent hangs of several minutes on boot, and failure to detect or report the battery. Fix this by adding a 5us delay to the start of each SMBUS transaction. This timing is the result of experimentation - hangs were observed with 3us but never with 5us. Link: https://bugzilla.kernel.org/show_bug.cgi?id=94651 Signed-off-by: Chris Bainbridge --- drivers/acpi/sbshc.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index 26e5b50..bf034f8 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "sbshc.h" #define PREFIX "ACPI: " @@ -87,6 +88,8 @@ enum acpi_smb_offset { ACPI_SMB_ALARM_DATA = 0x26, /* 2 bytes alarm data */ }; +static bool macbook; + static inline int smb_hc_read(struct acpi_smb_hc *hc, u8 address, u8 *data) { return ec_read(hc->offset + address, data); @@ -132,6 +135,8 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, } mutex_lock(&hc->lock); + if (macbook) + udelay(5); if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp)) goto end; if (temp) { @@ -257,12 +262,29 @@ extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, acpi_handle handle, acpi_ec_query_func func, void *data); +static int macbook_dmi_match(const struct dmi_system_id *d) +{ + pr_debug("Detected MacBook, enabling workaround\n"); + macbook = true; + return 0; +} + +static struct dmi_system_id acpi_smbus_dmi_table[] = { + { macbook_dmi_match, "Apple MacBook", { + DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBook") }, + }, + { }, +}; + static int acpi_smbus_hc_add(struct acpi_device *device) { int status; unsigned long long val; struct acpi_smb_hc *hc; + dmi_check_system(acpi_smbus_dmi_table); + if (!device) return -EINVAL;