From: Chris Bainbridge <chris.bainbridge@gmail.com>
To: Brad Campbell <brad@fnarfbargle.com>
Cc: linux-acpi@vger.kernel.org
Subject: Re: [PATCH] ACPI/sbshc: Add 5us delay to fix SBS hang on MacBook
Date: Mon, 18 May 2015 14:07:39 +0100 [thread overview]
Message-ID: <20150518130739.GA2483@localhost> (raw)
In-Reply-To: <20150518122737.GA5850@localhost>
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:
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;
}
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
prev parent reply other threads:[~2015-05-18 13:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-24 1:25 [PATCH] ACPI SBS: Fix intermittent hangs on Apple Macbook Chris Bainbridge
2015-04-29 0:37 ` Rafael J. Wysocki
2015-04-29 20:13 ` Chris Bainbridge
2015-04-29 20:21 ` [PATCH] ACPI/sbshc: Add 5us delay to fix SBS hang on MacBook Chris Bainbridge
2015-04-30 22:15 ` Rafael J. Wysocki
2015-05-18 2:20 ` Brad Campbell
2015-05-18 12:27 ` Chris Bainbridge
2015-05-18 13:07 ` Chris Bainbridge [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150518130739.GA2483@localhost \
--to=chris.bainbridge@gmail.com \
--cc=brad@fnarfbargle.com \
--cc=linux-acpi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.