From owner-freebsd-acpi@FreeBSD.ORG Tue Apr 14 16:11:21 2009 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2E6A01065691 for ; Tue, 14 Apr 2009 16:11:21 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 5C41B8FC12 for ; Tue, 14 Apr 2009 16:11:18 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id SAA17953; Tue, 14 Apr 2009 18:58:32 +0300 (EEST) (envelope-from avg@freebsd.org) Message-ID: <49E4B2A7.3020302@freebsd.org> Date: Tue, 14 Apr 2009 18:58:31 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.21 (X11/20090406) MIME-Version: 1.0 To: freebsd-acpi@freebsd.org References: <49DB639A.4090504@icyb.net.ua> <49DCF5C2.60805@root.org> <49DDF906.8090400@icyb.net.ua> <49DF3CA4.1090309@freebsd.org> In-Reply-To: <49DF3CA4.1090309@freebsd.org> X-Enigmail-Version: 0.95.7 Content-Type: multipart/mixed; boundary="------------040608080302050903060209" Cc: Subject: run resume code only for S1-S4 states X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2009 16:11:23 -0000 This is a multi-part message in MIME format. --------------040608080302050903060209 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Guys, could you please review the attached patch? Its main idea is to make control flow of acpi_EnterSleepState similar to that of acpi_ReqSleepState: reject invalid state parameter immediately and handle special S5 as early as possible. Primary purpose is to avoid running resume code when it is not necessary - e.g. shutdown_nice() typically returns immediately after initiating a graceful shutdown by sending a signal to init. As such, S5 is handled right after checking/disabling re-entry. switch becomes unneeded, because all remaining possibilities are grouped into a single case. I decided to use do-while(0) statement in the place of the switch for the following reasons: 1. minimize diff by preserving indentation 2. minimize diff by preserving control flow that depends on break statement But I am not sure how this while(0) corresponds with style(9), I couldn't find any reference in the manual page. There is also a concern about calling shutdown_nice() outside of the Giant lock and binding to CPU 0. I am not sure about the pre-requisites for this function. John, maybe you could help me here? -- Andriy Gapon --------------040608080302050903060209 Content-Type: text/plain; name="acpi_s5.diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="acpi_s5.diff" ZGlmZiAtLWdpdCBhL3N5cy9kZXYvYWNwaWNhL2FjcGkuYyBiL3N5cy9kZXYvYWNwaWNhL2Fj cGkuYwppbmRleCA1MGI4NGE1Li5hYzY1NGQyIDEwMDY0NAotLS0gYS9zeXMvZGV2L2FjcGlj YS9hY3BpLmMKKysrIGIvc3lzL2Rldi9hY3BpY2EvYWNwaS5jCkBAIC0yNDgyLDYgKzI0ODIs OSBAQCBhY3BpX0VudGVyU2xlZXBTdGF0ZShzdHJ1Y3QgYWNwaV9zb2Z0YyAqc2MsIGludCBz dGF0ZSkKIAogICAgIEFDUElfRlVOQ1RJT05fVFJBQ0VfVTMyKChjaGFyICopKHVpbnRwdHJf dClfX2Z1bmNfXywgc3RhdGUpOwogCisgICAgaWYgKHN0YXRlIDwgQUNQSV9TVEFURV9TMSB8 fCBzdGF0ZSA+IEFDUElfU1RBVEVfUzUpCisJcmV0dXJuX0FDUElfU1RBVFVTIChBRV9CQURf UEFSQU1FVEVSKTsKKwogICAgIC8qIFJlLWVudHJ5IG9uY2Ugd2UncmUgc3VzcGVuZGluZyBp cyBub3QgYWxsb3dlZC4gKi8KICAgICBzdGF0dXMgPSBhY3BpX3NsZWVwX2Rpc2FibGUoc2Mp OwogICAgIGlmIChBQ1BJX0ZBSUxVUkUoc3Rhd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