From owner-freebsd-current@FreeBSD.ORG Fri Oct 3 15:14:47 2014 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 31A35770; Fri, 3 Oct 2014 15:14:47 +0000 (UTC) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0D1D3B06; Fri, 3 Oct 2014 15:14:45 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id SAA23920; Fri, 03 Oct 2014 18:14:37 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1Xa4Z2-0003kA-LG; Fri, 03 Oct 2014 18:14:36 +0300 Message-ID: <542EBD1F.2060604@FreeBSD.org> Date: Fri, 03 Oct 2014 18:13:35 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: FreeBSD Current Subject: Re: vt_suspend / vt_resume References: <542A43E1.5010401@FreeBSD.org> In-Reply-To: <542A43E1.5010401@FreeBSD.org> Content-Type: text/plain; charset=X-VIET-VPS Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Oct 2014 15:14:47 -0000 On 30/09/2014 08:47, Andriy Gapon wrote: > > I think that currently vt_suspend / vt_resume are called at quite unsuitable > times. For example, vt_suspend performs a vt switch which requires cooperation > from an X server, but that could be problematic given that some devices may > already be suspended. > I believe that it is better to do what sc(4) does and use power_suspend / > power_resume event handlers instead of device_suspend / device_resume methods. > power_suspend event is posted when a kernel has not entered any special state yet. > > What do you think? > So, I am now using the following patch and suspend/resume works 100% reliable for me, whereas previously there was a quite significant chance that the video subsystem would be in a very confused state after resuming. For example there could be an endless stream of error message and the screen would be frozen: drmn0: error: couldn't schedule ib error: [drm:pid1492:radeon_cs_ib_chunk] *ERROR* Failed to schedule IB ! Or there could be an endless GPU reset loop in the radeon driver: drmn0: error: GPU lockup CP stall for more than 10000msec drmn0: warning: GPU lockup (waiting for 0x0000000000269544 last fence id 0x0000000000269523) error: [drm:pid1492:r600_ib_test] *ERROR* radeon: fence wait failed (-11). error: [drm:pid1492:radeon_ib_ring_tests] *ERROR* radeon: failed testing IB on GFX ring (-11). drmn0: error: ib ring test failed (-11). drmn0: info: GPU softreset: 0x00000003 The patch (I am not sure if fbd_attach is the right place to register the event handlers): diff --git a/sys/dev/fb/fbd.c b/sys/dev/fb/fbd.c index ff2488d..923292a 100644 --- a/sys/dev/fb/fbd.c +++ b/sys/dev/fb/fbd.c @@ -316,6 +316,11 @@ fbd_attach(device_t dev) return (ENXIO); err = fbd_register(sc->sc_info); + EVENTHANDLER_REGISTER(power_suspend, vt_fb_suspend, NULL, + EVENTHANDLER_PRI_ANY); + EVENTHANDLER_REGISTER(power_resume, vt_fb_resume, NULL, + EVENTHANDLER_PRI_ANY); + return (err); } @@ -332,22 +337,6 @@ fbd_detach(device_t dev) return (err); } -static int -fbd_suspend(device_t dev) -{ - - vt_fb_suspend(); - return (bus_generic_suspend(dev)); -} - -static int -fbd_resume(device_t dev) -{ - - vt_fb_resume(); - return (bus_generic_resume(dev)); -} - static device_method_t fbd_methods[] = { /* Device interface */ DEVMETHOD(device_probe, fbd_probe), @@ -355,8 +344,6 @@ static device_method_t fbd_methods[] = { DEVMETHOD(device_detach, fbd_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, fbd_suspend), - DEVMETHOD(device_resume, fbd_resume), { 0, 0 } }; -- Andriy Gapon