[ltp] Re: Re: EC Hanging with latest tp-smapi (0.29)

Shem Multinymous linux-thinkpad@linux-thinkpad.org
Thu, 24 Aug 2006 03:01:45 +0300


Hi Sukant,

Thanks for the informative reports, and for the many reboots!
Please try this patch (note the version change)  and report the dmesg
output. I'm testing several things at once, so if it makes a
difference we'll need to narrow it down further.

--- a/thinkpad_ec.c
+++ b/thinkpad_ec.c
@@ -37,5 +37,5 @@
 #include <asm/io.h>

-#define TP_VERSION "0.29"
+#define TP_VERSION "0.29-debug1"

 MODULE_AUTHOR("Shem Multinymous");
@@ -62,5 +62,5 @@
 #define TPC_READ_RETRIES    150
 #define TPC_READ_NDELAY     500
-#define TPC_REQUEST_RETRIES 100
+#define TPC_REQUEST_RETRIES 1000
 #define TPC_REQUEST_NDELAY   10
 #define TPC_PREFETCH_TIMEOUT   (HZ/10)  /* invalidate prefetch after 0.1sec */
@@ -155,4 +155,12 @@
 	}

+	/* Ensure status is stable: */
+	ndelay(1000);
+	str3 = inb(TPC_STR3_PORT) & H8S_STR3_MASK;
+	if (str3 != 0x00) {
+		printk(KERN_WARNING REQ_FMT("unstable STR3", str3));
+		return -EIO;
+	}
+
 	/* Send TWR0MW: */
 	outb(args->val[0], TPC_TWR0_PORT);
@@ -195,5 +203,6 @@
  * requested.
  */
-static int thinkpad_ec_read_data(struct thinkpad_ec_row *data)
+static int thinkpad_ec_read_data(const struct thinkpad_ec_row *args,
+                                 struct thinkpad_ec_row *data)
 {
 	int i;
@@ -210,5 +219,5 @@
 	if (str3 != (H8S_STR3_OBF3B|H8S_STR3_SWMF)) {
 		printk(KERN_WARNING
-		       MSG_FMT("bad initial STR3 (0x%02x)", str3));
+		       REQ_FMT("bad initial STR3", str3));
 		return -EIO;
 	}
@@ -227,5 +236,9 @@
 	if (str3 & H8S_STR3_OBF3B)
 		printk(KERN_WARNING
-		       MSG_FMT("OBF3B=1 after read (0x%02x)", str3));
+		       REQ_FMT("OBF3B=1 after read", str3));
+	/* If port 0x161F returns 0x80 too often, the EC may lock up: */
+	if (data->val[0xF] == 0x80)
+		printk(KERN_WARNING
+		       REQ_FMT("0x161F reports error", data->val[0xF]));
 	return 0;
 }
@@ -283,5 +296,5 @@
 	/* Read the row's data */
 	for (retries=0; retries<TPC_READ_RETRIES; ++retries) {
-		ret = thinkpad_ec_read_data(data);
+		ret = thinkpad_ec_read_data(args, data);
 		if (!ret)
 			goto out;
@@ -320,5 +333,5 @@
 		ret = -ENODATA;
 	} else {
-		ret = thinkpad_ec_read_data(data);
+		ret = thinkpad_ec_read_data(args, data);
 		if (!ret)
 			prefetch_jiffies = TPC_PREFETCH_NONE; /* eaten up */
--- a/tp_smapi.c
+++ b/tp_smapi.c
@@ -1105,5 +1105,5 @@
 	int ret;

-	for (arg0=0x00; arg0<=0x0b; ++arg0) {
+	for (arg0=0x00; arg0<=0x08; ++arg0) {
 		if ( (p-buf) > PAGE_SIZE-TP_CONTROLLER_ROW_LEN*5 )
 			return -ENOMEM; /* don't overflow sysfs buf */