Re: ACPI panic on unplugging the power cord.

2013-01-28 Thread Jung-uk Kim
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2013-01-26 11:58:16 -0500, Pawel Jakub Dawidek wrote:
 On Fri, Jan 25, 2013 at 04:19:44PM -0500, Jung-uk Kim wrote:
 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1
 
 On 2013-01-25 04:26:02 -0500, Pawel Jakub Dawidek wrote:
 On Thu, Jan 24, 2013 at 05:18:48PM +0100, Pawel Jakub Dawidek 
 wrote:
 One is when I leave laptop idle for some time (few hours?):
 
 http://people.freebsd.org/~pjd/misc/acpi_idle_panic_0.jpg 
 http://people.freebsd.org/~pjd/misc/acpi_idle_panic_1.jpg
 
 Small update. This panic doesn't happen when the system is
 idle, it happens we I close the lid to the point when display
 is turned off (which is almost closed, but not entirely
 closed).
 
 Closing lid doesn't trigger suspend or anything like that. It
 just turns off the display.
 
 Please try the attached patch (with my previous patch).  Also, 
 available from here:
 
 http://people.freebsd.org/~jkim/acpi_exit.diff
 
 Your patch fixes panic triggered by unplugging power cable as well
 the one triggered by closing the lid. I haven't tried booting from
 battery and connecting power cable, but I expect happy end there as
 well.

Committed, thanks!

Jung-uk Kim
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBAgAGBQJRButnAAoJECXpabHZMqHO+C4IAJVcT97/ZBylUajuBpY/s+rb
uiBLHALbXpKiHqRDiaTmkGdROdfMKc8IhnOB97N7YlLMzYhEFKXCL4JCMxGtxT8K
sQ3FzKsbdNaEVZl0k1Ql7ogLSMaCLS9Gjbd4/4Rm7oQUf+k90x9aSavsDBPfszgD
uPrhBNgAvWVP9rHjMgW7mYsM73j33cbNYE5XBBV6R6RqDF4CjbhpwD4gIIQDsx3y
0ff3lc1RFed9syjlg6suL3jL+2Cnv+JkSVon5KA77n+g1zLkI6TifnWFYJnNt48r
P7mhrmknazkoEdIEpDDFJEJTt4QE0qm0VRjCfzUPhsNdR1dJy85Hrijem9HmEWg=
=vdbF
-END PGP SIGNATURE-
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: ACPI panic on unplugging the power cord.

2013-01-26 Thread Pawel Jakub Dawidek
On Fri, Jan 25, 2013 at 04:19:44PM -0500, Jung-uk Kim wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 2013-01-25 04:26:02 -0500, Pawel Jakub Dawidek wrote:
  On Thu, Jan 24, 2013 at 05:18:48PM +0100, Pawel Jakub Dawidek
  wrote:
  One is when I leave laptop idle for some time (few hours?):
  
  http://people.freebsd.org/~pjd/misc/acpi_idle_panic_0.jpg 
  http://people.freebsd.org/~pjd/misc/acpi_idle_panic_1.jpg
  
  Small update. This panic doesn't happen when the system is idle,
  it happens we I close the lid to the point when display is turned
  off (which is almost closed, but not entirely closed).
  
  Closing lid doesn't trigger suspend or anything like that. It just
  turns off the display.
 
 Please try the attached patch (with my previous patch).  Also,
 available from here:
 
 http://people.freebsd.org/~jkim/acpi_exit.diff

Your patch fixes panic triggered by unplugging power cable as well the
one triggered by closing the lid. I haven't tried booting from battery
and connecting power cable, but I expect happy end there as well.
Thank you very much for the fix.

BTW. When I'm closing the lid and opening it again (not cosing it
entirely, just to the point when display is turned off) I see this
message to be printed twice on the console:

CPU0: local APIC error 0x80

Although I must admit I see this message from time to time, but I
haven't found a pattern. Closing and opening the lid always make it
appear. Not sure how much it is related to ACPI, though.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpgOFfnWqmSv.pgp
Description: PGP signature


Re: ACPI panic on unplugging the power cord.

2013-01-25 Thread Pawel Jakub Dawidek
On Thu, Jan 24, 2013 at 05:18:48PM +0100, Pawel Jakub Dawidek wrote:
 One is when I leave laptop idle for some time (few hours?):
 
   http://people.freebsd.org/~pjd/misc/acpi_idle_panic_0.jpg
   http://people.freebsd.org/~pjd/misc/acpi_idle_panic_1.jpg

Small update. This panic doesn't happen when the system is idle, it
happens we I close the lid to the point when display is turned off
(which is almost closed, but not entirely closed).

Closing lid doesn't trigger suspend or anything like that. It just turns
off the display.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpt_6zGlZaPi.pgp
Description: PGP signature


Re: ACPI panic on unplugging the power cord.

2013-01-25 Thread Jung-uk Kim
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2013-01-25 04:26:02 -0500, Pawel Jakub Dawidek wrote:
 On Thu, Jan 24, 2013 at 05:18:48PM +0100, Pawel Jakub Dawidek
 wrote:
 One is when I leave laptop idle for some time (few hours?):
 
 http://people.freebsd.org/~pjd/misc/acpi_idle_panic_0.jpg 
 http://people.freebsd.org/~pjd/misc/acpi_idle_panic_1.jpg
 
 Small update. This panic doesn't happen when the system is idle,
 it happens we I close the lid to the point when display is turned
 off (which is almost closed, but not entirely closed).
 
 Closing lid doesn't trigger suspend or anything like that. It just
 turns off the display.

Please try the attached patch (with my previous patch).  Also,
available from here:

http://people.freebsd.org/~jkim/acpi_exit.diff

Thanks,

Jung-uk Kim
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBAgAGBQJRAvbwAAoJECXpabHZMqHOhkwIALmKk6ylgFwrvgTCWUZKrJXM
X41gMBhbNnMoa+g/lBwxIsTxb17zXRAN2T8K6xOQZoB66vjW+ykq38SU0qQTaTLt
ldihTV7xZawmMz/t5meshDZCbXUTtwOd6ChdFrjgc8+FUq+siL3mRi5UpoIk8o0k
wblQ2werCGESIReW57cfGTnF+Sbfz1fBbobos+04gvs9d72FEfrsGRwSZv/wsBYP
RKv2zGGWFzXSgPwYHbA+Nz1Tt36zl1npLV7mx/nijA6CNtYvL/RX4QDUTxFw2G5h
Bjr3kVXTqz2ITM/K6Oajel6HE1utYDEMgBUL3kaEKdmxK2cguZmcP3p04f1XzRw=
=AUMk
-END PGP SIGNATURE-
Index: sys/contrib/dev/acpica/include/acoutput.h
===
--- sys/contrib/dev/acpica/include/acoutput.h	(revision 245916)
+++ sys/contrib/dev/acpica/include/acoutput.h	(working copy)
@@ -329,9 +329,9 @@
 
 /* Helper macro */
 
-#define ACPI_TRACE_ENTRY(Name, Function, Cast, Param) \
+#define ACPI_TRACE_ENTRY(Name, Function, Type, Param) \
 ACPI_FUNCTION_NAME (Name) \
-Function (ACPI_DEBUG_PARAMETERS, Cast (Param))
+Function (ACPI_DEBUG_PARAMETERS, (Type) (Param))
 
 /* The actual entry trace macros */
 
@@ -340,13 +340,13 @@
 AcpiUtTrace (ACPI_DEBUG_PARAMETERS)
 
 #define ACPI_FUNCTION_TRACE_PTR(Name, Pointer) \
-ACPI_TRACE_ENTRY (Name, AcpiUtTracePtr, (void *), Pointer)
+ACPI_TRACE_ENTRY (Name, AcpiUtTracePtr, void *, Pointer)
 
 #define ACPI_FUNCTION_TRACE_U32(Name, Value) \
-ACPI_TRACE_ENTRY (Name, AcpiUtTraceU32, (UINT32), Value)
+ACPI_TRACE_ENTRY (Name, AcpiUtTraceU32, UINT32, Value)
 
 #define ACPI_FUNCTION_TRACE_STR(Name, String) \
-ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, (char *), String)
+ACPI_TRACE_ENTRY (Name, AcpiUtTraceStr, char *, String)
 
 #define ACPI_FUNCTION_ENTRY() \
 AcpiUtTrackStackPtr()
@@ -361,16 +361,37 @@
  *
  * One of the FUNCTION_TRACE macros above must be used in conjunction
  * with these macros so that _AcpiFunctionName is defined.
+ *
+ * There are two versions of most of the return macros. The default version is
+ * safer, since it avoids side-effects by guaranteeing that the argument will
+ * not be evaluated twice.
+ *
+ * A less-safe version of the macros is provided for optional use if the
+ * compiler uses excessive CPU stack (for example, this may happen in the
+ * debug case if code optimzation is disabled.)
  */
 
 /* Exit trace helper macro */
 
-#define ACPI_TRACE_EXIT(Function, Cast, Param) \
+#ifndef ACPI_SIMPLE_RETURN_MACROS
+
+#define ACPI_TRACE_EXIT(Function, Type, Param) \
 ACPI_DO_WHILE0 ({ \
-Function (ACPI_DEBUG_PARAMETERS, Cast (Param)); \
-return ((Param)); \
+register Type _Param = (Type) (Param); \
+Function (ACPI_DEBUG_PARAMETERS, _Param); \
+return (_Param); \
 })
 
+#else /* Use original less-safe macros */
+
+#define ACPI_TRACE_EXIT(Function, Type, Param) \
+ACPI_DO_WHILE0 ({ \
+Function (ACPI_DEBUG_PARAMETERS, (Type) (Param)); \
+return (Param); \
+})
+
+#endif /* ACPI_SIMPLE_RETURN_MACROS */
+
 /* The actual exit macros */
 
 #define return_VOID \
@@ -380,13 +401,13 @@
 })
 
 #define return_ACPI_STATUS(Status) \
-ACPI_TRACE_EXIT (AcpiUtStatusExit, (ACPI_STATUS), Status)
+ACPI_TRACE_EXIT (AcpiUtStatusExit, ACPI_STATUS, Status)
 
 #define return_PTR(Pointer) \
-ACPI_TRACE_EXIT (AcpiUtPtrExit, (UINT8 *), Pointer)
+ACPI_TRACE_EXIT (AcpiUtPtrExit, void *, Pointer)
 
 #define return_VALUE(Value) \
-ACPI_TRACE_EXIT (AcpiUtValueExit, (UINT64), Value)
+ACPI_TRACE_EXIT (AcpiUtValueExit, UINT64, Value)
 
 
 /* Conditional execution */
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

Re: ACPI panic on unplugging the power cord.

2013-01-24 Thread Andriy Gapon
on 24/01/2013 02:54 Jung-uk Kim said the following:
 
 Can you please try the attached patch?  It is also available from here:
 
 http://people.freebsd.org/~jkim/utcache.diff

Jung-uk,

I think that I have a much better patch for all potential ACPI object cache
problems :-)
http://people.freebsd.org/~avg/acpi-uma-cache.diff

What do you think?

-- 
Andriy Gapon
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: ACPI panic on unplugging the power cord.

2013-01-24 Thread Pawel Jakub Dawidek
On Wed, Jan 23, 2013 at 07:54:57PM -0500, Jung-uk Kim wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 2013-01-22 12:56:29 -0500, Pawel Jakub Dawidek wrote:
  I just upgraded to HEAD today and was wondering what will explode. 
  Now I know.
  
  When I unplug power cord from my laptop, ACPI panics. Pictures
  here:
  
  http://people.freebsd.org/~pjd/misc/acpi_panic_0.jpg 
  http://people.freebsd.org/~pjd/misc/acpi_panic_1.jpg
  
  Let me know if you need more info.
 
 Can you please try the attached patch?  It is also available from here:
 
 http://people.freebsd.org/~jkim/utcache.diff
 
 Please note the patch may or may not fix the problem but I think I
 found an ancient bug. :-(

This patch didn't fix the panic:

http://people.freebsd.org/~pjd/misc/acpi_unplug_panic_0.jpg
http://people.freebsd.org/~pjd/misc/acpi_unplug_panic_1.jpg

In the meantime I found two other panics.

One is when I leave laptop idle for some time (few hours?):

http://people.freebsd.org/~pjd/misc/acpi_idle_panic_0.jpg
http://people.freebsd.org/~pjd/misc/acpi_idle_panic_1.jpg

And when is when I boot laptop without power connected and I connect the
power:

http://people.freebsd.org/~pjd/misc/acpi_power_connect_panic_0.jpg
http://people.freebsd.org/~pjd/misc/acpi_power_connect_panic_1.jpg

BTW. On the acpi_power_connect_panic_0.JPG photo, at the top of the
screen you can see error messages that are logged every second when I
have power disconnected. This is not a new problem. I had this problem
when I bought this laptop, but now that I'm reporting those bugs, I can
as well let you know about this one.

I'm running this on Thinkpad T530.

I understand that those problems are specific to my laptop and that on
your laptop all of the above work just fine?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpEcz4SnSEh8.pgp
Description: PGP signature


Re: ACPI panic on unplugging the power cord.

2013-01-24 Thread Jung-uk Kim
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2013-01-24 04:41:08 -0500, Andriy Gapon wrote:
 on 24/01/2013 02:54 Jung-uk Kim said the following:
 
 Can you please try the attached patch?  It is also available from
 here:
 
 http://people.freebsd.org/~jkim/utcache.diff
 
 Jung-uk,
 
 I think that I have a much better patch for all potential ACPI
 object cache problems :-) 
 http://people.freebsd.org/~avg/acpi-uma-cache.diff
 
 What do you think?

We have to fix this bug because local cache is always used for
userland applications, e.g., iasl.

BTW, I tried something like that long ago.  In fact, the first attempt
goes all the way back to this patch (warning: it's naive, broken, and
overly complicated):

http://people.freebsd.org/~jkim/acpica/OsdCache.diff

I have more up-to-date and correct patch to use UMA but I'm still not
100% convinced whether we want to do it or not.  When utcache.c works,
it works fairly well, actually. :-)

Jung-uk Kim
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBAgAGBQJRAX15AAoJECXpabHZMqHOyoAH/i1eccONiETE+LiHlApmL+zy
Y1h1D+R/S8hJ55fQ7i/2CkqAhNdHFI+TCrt2YIPNXS79VP9xyNRa+gPGHNqYUTF4
nv34ZpSi5MMERg7r+mOitNjPZfy+aiyDHI/PQFZ4lQR+by3c1HogKAwNPhLn0rxF
NiA+X11lkcbBCxb4HzH8kSI5wFW/e5tEAHgGTrxJLzS1IGTbRBYLV6lA+ITBR0wu
EzGw3FEU2pO2jDL3WxsM0vg/4VMCZvsnezxvRQ1XPbdJe4UU0ri3VgqzFX6N5ThI
AeDuehji9lZiZc6Hjn35jSxq5KpzMiOj6bjLTEeO5zIdjmeGUWiMex+aoRrFOGU=
=/bG6
-END PGP SIGNATURE-
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: ACPI panic on unplugging the power cord.

2013-01-23 Thread Jung-uk Kim
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2013-01-22 12:56:29 -0500, Pawel Jakub Dawidek wrote:
 I just upgraded to HEAD today and was wondering what will explode. 
 Now I know.
 
 When I unplug power cord from my laptop, ACPI panics. Pictures
 here:
 
 http://people.freebsd.org/~pjd/misc/acpi_panic_0.jpg 
 http://people.freebsd.org/~pjd/misc/acpi_panic_1.jpg
 
 Let me know if you need more info.

Can you please try the attached patch?  It is also available from here:

http://people.freebsd.org/~jkim/utcache.diff

Please note the patch may or may not fix the problem but I think I
found an ancient bug. :-(

Thanks,

Jung-uk Kim
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBAgAGBQJRAIZhAAoJECXpabHZMqHOWl8H/3pUGshUkzCNbEOQHoZOYXMW
TtLaUqdV3/zYGEYDYl5Tbxv2JUz4tWDU5KlWhnZk+MjNnR1+g0fgzQu3mK056NU+
rpZucEnoaEeKriLpd+Hsw3Y28eXiY8/9T8/SnFMUW7AS6HZk8G7itdu9cx9A+IY6
A2tQBIpDXes4a5BLNZzyP/2dSMrcKVeS28+fZlxGdWWakFs5/FWYguK5kR2PIkCS
3yh8vEv7XH8WJz+sK/v/jcpcxt+heCG+j8XIwJieqk1CDXaCtH6g+4mlKQogsZY1
1YSYaGE+/szNvnR9UjW1+x/mhA5atFa9ysCq96zvVOs/Ih7X9Id4fZ6laetSDIs=
=rUXs
-END PGP SIGNATURE-
Index: sys/contrib/dev/acpica/components/utilities/utcache.c
===
--- sys/contrib/dev/acpica/components/utilities/utcache.c	(revision 245848)
+++ sys/contrib/dev/acpica/components/utilities/utcache.c	(working copy)
@@ -95,7 +95,6 @@ AcpiOsCreateCache (
 /* Populate the cache object and return it */
 
 ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
-Cache-LinkOffset = 8;
 Cache-ListName   = CacheName;
 Cache-ObjectSize = ObjectSize;
 Cache-MaxDepth   = MaxDepth;
@@ -121,7 +120,7 @@ ACPI_STATUS
 AcpiOsPurgeCache (
 ACPI_MEMORY_LIST*Cache)
 {
-char*Next;
+void*Next;
 ACPI_STATUS Status;
 
 
@@ -145,8 +144,7 @@ AcpiOsPurgeCache (
 {
 /* Delete and unlink one cached state object */
 
-Next = *(ACPI_CAST_INDIRECT_PTR (char,
-(((char *) Cache-ListHead)[Cache-LinkOffset])));
+Next = ((ACPI_OBJECT_COMMON *) Cache-ListHead)-NextObject;
 ACPI_FREE (Cache-ListHead);
 
 Cache-ListHead = Next;
@@ -251,8 +249,7 @@ AcpiOsReleaseObject (
 
 /* Put the object at the head of the cache list */
 
-* (ACPI_CAST_INDIRECT_PTR (char,
-(((char *) Object)[Cache-LinkOffset]))) = Cache-ListHead;
+((ACPI_OBJECT_COMMON *) Object)-NextObject = Cache-ListHead;
 Cache-ListHead = Object;
 Cache-CurrentDepth++;
 
@@ -307,8 +304,7 @@ AcpiOsAcquireObject (
 /* There is an object available, use it */
 
 Object = Cache-ListHead;
-Cache-ListHead = *(ACPI_CAST_INDIRECT_PTR (char,
-(((char *) Object)[Cache-LinkOffset])));
+Cache-ListHead = ((ACPI_OBJECT_COMMON *) Object)-NextObject;
 
 Cache-CurrentDepth--;
 
Index: sys/contrib/dev/acpica/include/actypes.h
===
--- sys/contrib/dev/acpica/include/actypes.h	(revision 245848)
+++ sys/contrib/dev/acpica/include/actypes.h	(working copy)
@@ -1226,7 +1226,6 @@ typedef struct acpi_memory_list
 UINT16  ObjectSize;
 UINT16  MaxDepth;
 UINT16  CurrentDepth;
-UINT16  LinkOffset;
 
 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
 
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org