From nobody@FreeBSD.org  Tue Jul 17 01:33:48 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 4CB2716A405
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Jul 2007 01:33:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (groups.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 3A28613C49D
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Jul 2007 01:33:48 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l6H1XmUi015643
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Jul 2007 01:33:48 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l6H1Xlv8015631;
	Tue, 17 Jul 2007 01:33:47 GMT
	(envelope-from nobody)
Message-Id: <200707170133.l6H1Xlv8015631@www.freebsd.org>
Date: Tue, 17 Jul 2007 01:33:47 GMT
From: Cristian KLEIN <cristi@net.utcluj.ro>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch][acpi] panic: recursed on non-recursive mutex
X-Send-Pr-Version: www-3.0

>Number:         114649
>Category:       kern
>Synopsis:       [patch][acpi] panic: recursed on non-recursive mutex
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-acpi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 17 01:40:03 GMT 2007
>Closed-Date:    Sun Apr 06 02:42:38 UTC 2008
>Last-Modified:  Sun Apr 06 02:42:38 UTC 2008
>Originator:     Cristian KLEIN
>Release:        7.0-CURRENT
>Organization:
Technical University of Cluj-Napoca
>Environment:
FreeBSD hades.local 7.0-CURRENT FreeBSD 7.0-CURRENT #11: Tue Jul 17 04:08:17 EEST 2007     cristi@hades.local:/usr/obj/usr/src/sys/GENERIC  i386
(source updated immediately before compiling)

>Description:
When resuming (from S3) an IBM Thinkpad R51 laptop, KDB is entered with the following panic string (written by hand):

panic: _mtx_lock_sleep: recursed on non-recursive mutex acpi subsystem GPE lock
@ ......./OsdSynch.c:377
>How-To-Repeat:
Suspend (S3) / resume a laptop. Panic will always occur after the first resume.

>Fix:
It seems to me that ACPI vendor code was not designed to use non-recursive mutexes. For example:

* AcpiEvGpeDetect() calls AcpiOsAcquireLock(AcpiGbl_GpeLock) in contrib/dev/acpica/evgpe.c:511, then calls AcpiEvGpeDispatch()
* AcpiEvGpeDispatch() calls AcpiHwDisableAllGpes() in evgpe.c:762
* AcpiHwDisableAllGpes() calls AcpiEvWalkGpeList in hwgpe.c:487
* AcpiEvWalkGpeList() calls AcpiOsAcquireLock(AcpiGbl_GpeLock) *again* in evgpeblk.c:237

Rather that correcting contributed code (in who knows how many places) and then have problems in the future (when the ACPI vendor code is upgraded), I suggest making the ACPI GPE lock recursable. The patch below does this.

After applying this patch, I've been able to suspend / resume 20+ times.

Patch attached with submission follows:

--- sys/dev/acpica/Osd/OsdSynch.c.orig	2007-03-27 02:04:02.000000000 +0300
+++ sys/dev/acpica/Osd/OsdSynch.c	2007-07-17 04:17:37.073597342 +0300
@@ -346,7 +346,7 @@
 	snprintf(h->name, sizeof(h->name), "acpi subsystem HW lock");
     else
 	snprintf(h->name, sizeof(h->name), "acpi subsys %p", OutHandle);
-    mtx_init(&h->lock, h->name, NULL, MTX_DEF);
+    mtx_init(&h->lock, h->name, NULL, MTX_DEF | MTX_RECURSE);
     *OutHandle = (ACPI_SPINLOCK)h;
     return (AE_OK);
 }


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->acpi 
Responsible-Changed-By: kmacy 
Responsible-Changed-When: Fri Nov 16 18:18:34 UTC 2007 
Responsible-Changed-Why:  

Assign to owner 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114649 
Responsible-Changed-From-To: acpi->freebsd-acpi 
Responsible-Changed-By: remko 
Responsible-Changed-When: Fri Nov 16 18:21:26 UTC 2007 
Responsible-Changed-Why:  
Towards expanded group 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114649 

From: Ed Maste <emaste@freebsd.org>
To: bug-followup@freebsd.org, freebsd-acpi@freebsd.org
Cc:  
Subject: Re: kern/114649: [patch][acpi] panic: recursed on non-recursive mutex
Date: Thu, 3 Apr 2008 15:44:53 -0400

 I have this same problem on my thinkpad T20.
 
 kern/114113 is the same issue.
State-Changed-From-To: open->closed 
State-Changed-By: takawata 
State-Changed-When: Sun Apr 6 02:37:46 UTC 2008 
State-Changed-Why:  
I encountered same problem on ThinkPad X61 uni processor suspend/resume. And  
fixed on the same way. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=114649 
>Unformatted:
