NetBSD Problem Report #43327

From khorben@defora.org  Wed May 19 11:06:40 2010
Return-Path: <khorben@defora.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 019C463B873
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 19 May 2010 11:06:39 +0000 (UTC)
Message-Id: <20100519110635.57C74D0@kwarx.defora.lan>
Date: Wed, 19 May 2010 13:06:35 +0200 (CEST)
From: Pierre Pronchery <khorben@defora.org>
To: gnats-bugs@gnats.NetBSD.org
Subject: Allowing suspend with radeondrm on NetBSD 5
X-Send-Pr-Version: 3.95

>Number:         43327
>Category:       kern
>Synopsis:       It is currently not possible to suspend with radeondrm configured
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    mrg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 19 11:10:00 +0000 2010
>Closed-Date:    Sun Jun 20 06:51:05 +0000 2010
>Last-Modified:  Sun Jun 20 15:00:03 +0000 2010
>Originator:     Pierre Pronchery
>Release:        NetBSD 5.1_RC1
>Organization:
>Environment:
System: NetBSD kwarx.defora.lan 5.1_RC1 NetBSD 5.1_RC1 (GENERIC) #2: Wed May 5 04:21:36 CEST 2010 khorben@kwarx.defora.lan:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

A fix was committed two months ago by mrg@ to "make suspend/resume actually work" with radeondrm configured. I have just backported and tested these changes, which I think would be nice to have in the netbsd-5 branch.

>How-To-Repeat:
Enable radeondrm in the kernel and try to suspend; it refuses:

| Devices without power management support: radeondrm0

With the following patch, suspend and resume works fine, even though I could observe the following errors with my Lenovo ThinkPad T60 on docking station:

| ACPI Error (utmutex-0422): Mutex [4] is not acquired, cannot release [20080321] ACPI Error (dswstate-0259): Failed to extend the result stack [20080321]
| ACPI Error (dswstate-0185): Result stack is empty! State=0xffff800004878000 [20080321]
| ACPI Error (utmutex-0422): ACPI Error (psparse-0627): Mutex [4] is not acquired, cannot releaseMethod parse/execution failed  [20080321]
[\_GPE._L01] (Node 0xffff800004019be0), AE_NO_MEMORY                            ACPI Exception (evgpe-0711): AE_NO_MEMORY, while evaluating GPE method [_L01] [20080321]
| ACPI Error (utmutex-0422): Mutex [1] is not acquired, cannot release [20080321] ACPI Error (utmutex-0422): Mutex [0] is not acquired, cannot release [20080321]
| ACPI Error (exutils-0249): Could not release AML Interpreter mutex [20080321]   ioapic0 reenabling
| ACPI Error (utmutex-0422): Mutex [0] is not acquired, cannot release [20080321] ACPI Error (exutils-0249): Could not release AML Interpreter mutex [20080321]

>Fix:

Index: sys/external/bsd/drm/dist/bsd-core/radeon_drv.c
===================================================================
RCS file: /cvsroot/src/sys/external/bsd/drm/dist/bsd-core/radeon_drv.c,v
retrieving revision 1.2.10.1
diff -p -u -r1.2.10.1 radeon_drv.c
--- sys/external/bsd/drm/dist/bsd-core/radeon_drv.c	20 Jun 2009 23:36:59 -0000	1.2.10.1
+++ sys/external/bsd/drm/dist/bsd-core/radeon_drv.c	19 May 2010 10:41:47 -0000
@@ -134,6 +134,38 @@ MODULE_DEPEND(radeon, drm, 1, 1, 1);

 #elif   defined(__NetBSD__)

+static bool
+radeondrm_suspend(device_t self PMF_FN_ARGS)
+{
+	struct drm_device *dev = device_private(self);
+	drm_radeon_cp_stop_t stop_args;
+	bool rv = true;
+
+	stop_args.flush = stop_args.idle = 0;
+	DRM_LOCK();
+	if (drm_find_file_by_proc(dev, curlwp->l_proc) &&
+	    radeon_cp_stop(dev, &stop_args, dev->lock.file_priv) != 0)
+		rv = false;
+	DRM_UNLOCK();
+
+	return rv;
+}
+
+static bool
+radeondrm_resume(device_t self PMF_FN_ARGS)
+{
+	struct drm_device *dev = device_private(self);
+	bool rv = true;
+
+	DRM_LOCK();
+	if (drm_find_file_by_proc(dev, curlwp->l_proc) &&
+	    radeon_cp_resume(dev, NULL, NULL) != 0)
+		rv =  false;
+	DRM_UNLOCK();
+	
+	return rv;
+}
+
 static int
 radeondrm_probe(device_t parent, cfdata_t match, void *aux)
 {
@@ -152,11 +184,22 @@ radeondrm_attach(device_t parent, device

 	radeon_configure(dev);

+	if (!pmf_device_register(self, radeondrm_suspend, radeondrm_resume))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	drm_attach(self, pa, radeon_pciidlist);
 }

+static int
+radeondrm_detach(device_t self, int flags)
+{
+	pmf_device_deregister(self);
+
+	return drm_detach(self, flags);
+}
+
 CFATTACH_DECL_NEW(radeondrm, sizeof(struct drm_device),
-    radeondrm_probe, radeondrm_attach, drm_detach, drm_activate);
+    radeondrm_probe, radeondrm_attach, radeondrm_detach, NULL);

 #ifdef _MODULE


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->mrg
Responsible-Changed-By: mrg@NetBSD.org
Responsible-Changed-When: Mon, 24 May 2010 02:18:05 +0000
Responsible-Changed-Why:
mine.


State-Changed-From-To: open->pending-pullups
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Mon, 24 May 2010 02:18:05 +0000
State-Changed-Why:
i've forwarded this patch to the netbsd 5 releng team for consideration.


State-Changed-From-To: pending-pullups->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Sun, 20 Jun 2010 06:51:05 +0000
State-Changed-Why:
this was pulled up to netbsd-5.1. thanks.


From: Jeff Rizzo <riz@tastylime.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/43327 (It is currently not possible to suspend with radeondrm
 configured)
Date: Sun, 20 Jun 2010 07:58:42 -0700

 On 6/19/10 11:51 PM, mrg@NetBSD.org wrote:
 > Synopsis: It is currently not possible to suspend with radeondrm configured
 >
 > State-Changed-From-To: pending-pullups->closed
 > State-Changed-By: mrg@NetBSD.org
 > State-Changed-When: Sun, 20 Jun 2010 06:51:05 +0000
 > State-Changed-Why:
 > this was pulled up to netbsd-5.1. thanks.
 >
 >
 >    
 Actually, this pullup is stalled until after 5.1 is released, but it 
 should be pulled up right after.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.