From patchwork Mon May 18 13:07:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Bainbridge X-Patchwork-Id: 6429171 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F41A59F1CC for ; Mon, 18 May 2015 13:09:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 008DD205EE for ; Mon, 18 May 2015 13:09:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D61CE205C7 for ; Mon, 18 May 2015 13:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753899AbbERNIp (ORCPT ); Mon, 18 May 2015 09:08:45 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:35958 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753833AbbERNHn (ORCPT ); Mon, 18 May 2015 09:07:43 -0400 Received: by wizk4 with SMTP id k4so78563160wiz.1 for ; Mon, 18 May 2015 06:07:42 -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=qBSTiocBt/LZIFHzkYTAy6hq3H0156pqLZAwaCV7dlU=; b=LXpJ1DGX5dhLvBayBKqk/OKLzix5FNan/bmLTFgpDJTLT41ptmJMKNdPnzT4t61sAo 1W59KH+mgVNumnvCv7Mq4DPObwAcqM2JN++605vGzuU6aeQ3Yuu7qO1y9FkSId57FMa8 7asfFfxJrLsIS588po6tWObQt3IQKpy+uHrBptCNlNBxlcnzsMoEYJjfiQaWo7/OXc0y R9WxzT/NbenyaaSKsBBhHh5NgdoFEogN0Ny+Y+1tPg44mjAT8cic4nc9+dS4z6ddlAU9 42ufKzN7BBIGy5nznW2qcxRY8gCdTJGu5C/hU3b87tPCJjLNpzx6FQ+pV1v2Ri6sJ1be DILw== X-Received: by 10.194.95.41 with SMTP id dh9mr44895953wjb.55.1431954462619; Mon, 18 May 2015 06:07:42 -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 di9sm12402961wib.16.2015.05.18.06.07.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 May 2015 06:07:41 -0700 (PDT) Date: Mon, 18 May 2015 14:07:39 +0100 From: Chris Bainbridge To: Brad Campbell Cc: linux-acpi@vger.kernel.org Subject: Re: [PATCH] ACPI/sbshc: Add 5us delay to fix SBS hang on MacBook Message-ID: <20150518130739.GA2483@localhost> References: <20150424012530.GA16763@localhost> <4435249.leKkNHm9IZ@vostro.rjw.lan> <20150429202140.GB25904@localhost> <55594C71.9060402@fnarfbargle.com> <20150518122737.GA5850@localhost> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150518122737.GA5850@localhost> 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 On Mon, May 18, 2015 at 01:27:37PM +0100, Chris Bainbridge wrote: > diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c > index 01504c8..74f8596 100644 > --- a/drivers/acpi/sbs.c > +++ b/drivers/acpi/sbs.c > @@ -361,16 +361,21 @@ static int acpi_manager_get_info(struct acpi_sbs *sbs) > static int acpi_battery_get_info(struct acpi_battery *battery) > { > int i, result = 0; > - > - for (i = 0; i < ARRAY_SIZE(info_readers); ++i) { > - result = acpi_smbus_read(battery->sbs->hc, > - info_readers[i].mode, > - ACPI_SBS_BATTERY, > - info_readers[i].command, > - (u8 *) battery + > - info_readers[i].offset); > - if (result) > - break; > + int j; > + > + for (j = 0; j < 1000; j++) { > + for (i = 0; i < ARRAY_SIZE(info_readers); ++i) { > + result = acpi_smbus_read(battery->sbs->hc, > + info_readers[i].mode, > + ACPI_SBS_BATTERY, > + info_readers[i].command, > + (u8 *) battery + > + info_readers[i].offset); > + if (result) { > + printk("FAIL\n"); > + break; > + } > + } > } > return result; > } Better to exit immediately when SBS hangs, otherwise you could be waiting a long time for modprobe to return: I'm sure you get the idea. Forcing repeated SBS reads is a much quicker way to uncover an intermittent fault than through normal usage. After adding the 5us delay, I was able to run the acpi_battery_get_info loop for 20,000 cycles without fault, but this is just one Macbook, others may be different. It's also possible that the delay is just covering up some other problem; some patches were posted a few days ago to fix some underlying hang issues: http://www.spinics.net/lists/linux-acpi/msg57572.html --- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index 01504c8..84f422f 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -361,17 +361,22 @@ static int acpi_manager_get_info(struct acpi_sbs *sbs) static int acpi_battery_get_info(struct acpi_battery *battery) { int i, result = 0; - - for (i = 0; i < ARRAY_SIZE(info_readers); ++i) { - result = acpi_smbus_read(battery->sbs->hc, - info_readers[i].mode, - ACPI_SBS_BATTERY, - info_readers[i].command, - (u8 *) battery + - info_readers[i].offset); - if (result) - break; + int j; + + for (j = 0; j < 100; j++) { + for (i = 0; i < ARRAY_SIZE(info_readers); ++i) { + result = acpi_smbus_read(battery->sbs->hc, + info_readers[i].mode, + ACPI_SBS_BATTERY, + info_readers[i].command, + (u8 *) battery + + info_readers[i].offset); + if (result) + goto end; + } } + end: + printk(result ? "FAIL" : "OK"); return result; }