All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] applesmc: Bump max wait and rearrange udelay
@ 2012-09-15 22:42 ` Parag Warudkar
  0 siblings, 0 replies; 43+ messages in thread
From: Parag Warudkar @ 2012-09-15 22:42 UTC (permalink / raw)
  To: lm-sensors, linux-kernel; +Cc: rydberg, khali, linux

I have been getting a steady stream of wait_read timeouts on my 2010 MBP.

After playing around with various values of APPLESMC_MAX_WAIT a value of 
0x10000 reduces the wait_read failures to zero under most normal workloads 
- with and without AC power plugged in, at idle and and at make -j4 loads.

While there I noticed we don't really need to udelay before first inb() - 
so I moved it down to after first and subsequent failures.

Been running this for couple days without any issues.

Signed-off-by: Parag Warudkar <parag.lkml@gmail.com>

diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 2827088..46cb458 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -56,7 +56,7 @@
 /* wait up to 32 ms for a status change. */
 #define APPLESMC_MIN_WAIT	0x0010
 #define APPLESMC_RETRY_WAIT	0x0100
-#define APPLESMC_MAX_WAIT	0x8000
+#define APPLESMC_MAX_WAIT	0x10000
 
 #define APPLESMC_READ_CMD	0x10
 #define APPLESMC_WRITE_CMD	0x11
@@ -170,11 +170,11 @@ static int wait_read(void)
 	u8 status;
 	int us;
 	for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
-		udelay(us);
 		status = inb(APPLESMC_CMD_PORT);
 		/* read: wait for smc to settle */
 		if (status & 0x01)
 			return 0;
+		udelay(us);
 	}
 
 	pr_warn("wait_read() fail: 0x%02x\n", status);
@@ -192,11 +192,12 @@ static int send_byte(u8 cmd, u16 port)
 
 	outb(cmd, port);
 	for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
-		udelay(us);
 		status = inb(APPLESMC_CMD_PORT);
 		/* write: wait for smc to settle */
-		if (status & 0x02)
+		if (status & 0x02) {
+			udelay(us);
 			continue;
+		}
 		/* ready: cmd accepted, return */
 		if (status & 0x04)
 			return 0;

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2012-09-17 22:03 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-15 22:42 [lm-sensors] [PATCH] applesmc: Bump max wait and rearrange udelay Parag Warudkar
2012-09-15 22:42 ` Parag Warudkar
2012-09-15 22:58 ` [lm-sensors] " Guenter Roeck
2012-09-15 22:58   ` Guenter Roeck
2012-09-15 23:35   ` [lm-sensors] " Parag Warudkar
2012-09-15 23:35     ` Parag Warudkar
2012-09-15 23:38     ` [lm-sensors] " Parag Warudkar
2012-09-15 23:38       ` Parag Warudkar
2012-09-16  3:29     ` [lm-sensors] " Parag Warudkar
2012-09-16  3:29       ` Parag Warudkar
2012-09-16  4:31       ` [lm-sensors] " Guenter Roeck
2012-09-16  4:31         ` Guenter Roeck
2012-09-16  9:35         ` [lm-sensors] " Henrik Rydberg
2012-09-16  9:35           ` Henrik Rydberg
2012-09-16 21:22           ` [lm-sensors] " Parag Warudkar
2012-09-16 21:22             ` Parag Warudkar
2012-09-16 22:00             ` [lm-sensors] " Guenter Roeck
2012-09-16 22:00               ` Guenter Roeck
2012-09-16 22:30             ` [lm-sensors] " Henrik Rydberg
2012-09-16 22:30               ` Henrik Rydberg
2012-09-17  0:11               ` [lm-sensors] " Parag Warudkar
2012-09-17  0:11                 ` Parag Warudkar
2012-09-17 16:27                 ` [lm-sensors] " Henrik Rydberg
2012-09-17 16:27                   ` Henrik Rydberg
2012-09-17 16:37                   ` [lm-sensors] " Guenter Roeck
2012-09-17 16:37                     ` Guenter Roeck
2012-09-17 20:14                     ` [lm-sensors] " Henrik Rydberg
2012-09-17 20:14                       ` Henrik Rydberg
2012-09-17 22:03                       ` [lm-sensors] " Guenter Roeck
2012-09-17 22:03                         ` Guenter Roeck
2012-09-17 18:06                   ` [lm-sensors] " Parag Warudkar
2012-09-17 18:06                     ` Parag Warudkar
2012-09-17 18:49                     ` [lm-sensors] " Henrik Rydberg
2012-09-17 18:49                       ` Henrik Rydberg
2012-09-17 18:54                       ` [lm-sensors] " Parag Warudkar
2012-09-17 18:54                         ` Parag Warudkar
2012-09-17 19:14                         ` [lm-sensors] " Henrik Rydberg
2012-09-17 19:14                           ` Henrik Rydberg
2012-09-17 19:46                           ` [lm-sensors] " Henrik Rydberg
2012-09-17 19:46                             ` Henrik Rydberg
2012-09-17 18:22                   ` [lm-sensors] " Parag Warudkar
2012-09-17 18:22                     ` Parag Warudkar
2012-09-17 21:38 ` [lm-sensors] " Parag Warudkar

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.