From owner-svn-src-all@freebsd.org Thu Dec 6 12:34:35 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D9EE132B51A; Thu, 6 Dec 2018 12:34:35 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E839E8F955; Thu, 6 Dec 2018 12:34:34 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B096A23914; Thu, 6 Dec 2018 12:34:34 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB6CYYtn000635; Thu, 6 Dec 2018 12:34:34 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB6CYY51000634; Thu, 6 Dec 2018 12:34:34 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201812061234.wB6CYY51000634@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 6 Dec 2018 12:34:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341632 - head/sys/dev/acpica X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/dev/acpica X-SVN-Commit-Revision: 341632 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E839E8F955 X-Spamd-Result: default: False [-1.57 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.87)[-0.865,0]; NEURAL_HAM_SHORT(-0.65)[-0.648,0]; NEURAL_HAM_LONG(-0.05)[-0.054,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 12:34:35 -0000 Author: avg Date: Thu Dec 6 12:34:34 2018 New Revision: 341632 URL: https://svnweb.freebsd.org/changeset/base/341632 Log: acpi_{Device,Battery}IsPresent: restore pre-r330957 behaviour Specifically, assume that the device is present if evaluation of _STA method fails. Before r330957 we ignored any _STA evaluation failure (which was performed by AcpiGetObjectInfo in ACPICA contrib code) for the purpose of acpi_DeviceIsPresent and acpi_BatteryIsPresent. ACPICA 20180313 removed evaluation of _STA from AcpiGetObjectInfo. So, we added evaluation of _STA to acpi_DeviceIsPresent and acpi_BatteryIsPresent. One important difference is that the new code ignored a failure only if _STA did not exist (AE_NOT_FOUND). Any other kind of failure was treated as a fatal failure. Apparently, on some systems we can get AE_NOT_EXIST when evaluating _STA. And that error is not an evil twin of AE_NOT_FOUND, despite a very similar name, but a distinct error related to a missing handler for an ACPI operation region. It's possible that for some people the problem was already fixed by changes in ACPICA and/or in acpi_ec driver (or even in BIOS) that fixed the AE_NOT_EXIST failure related to EC operation region. This work is based on a great analysis by cem and an earlier patch by Ali Abdallah . PR: 227191 Reported by: 0mp MFC after: 2 weeks Modified: head/sys/dev/acpica/acpi.c Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Thu Dec 6 11:52:07 2018 (r341631) +++ head/sys/dev/acpica/acpi.c Thu Dec 6 12:34:34 2018 (r341632) @@ -2203,8 +2203,6 @@ acpi_DeviceIsPresent(device_t dev) h = acpi_get_handle(dev); if (h == NULL) return (FALSE); - status = acpi_GetInteger(h, "_STA", &s); - /* * Certain Treadripper boards always returns 0 for FreeBSD because it * only returns non-zero for the OS string "Windows 2015". Otherwise it @@ -2214,9 +2212,14 @@ acpi_DeviceIsPresent(device_t dev) if (acpi_MatchHid(h, "AMDI0020") || acpi_MatchHid(h, "AMDI0010")) return (TRUE); - /* If no _STA method, must be present */ + status = acpi_GetInteger(h, "_STA", &s); + + /* + * If no _STA method or if it failed, then assume that + * the device is present. + */ if (ACPI_FAILURE(status)) - return (status == AE_NOT_FOUND ? TRUE : FALSE); + return (TRUE); return (ACPI_DEVICE_PRESENT(s) ? TRUE : FALSE); } @@ -2236,9 +2239,12 @@ acpi_BatteryIsPresent(device_t dev) return (FALSE); status = acpi_GetInteger(h, "_STA", &s); - /* If no _STA method, must be present */ + /* + * If no _STA method or if it failed, then assume that + * the device is present. + */ if (ACPI_FAILURE(status)) - return (status == AE_NOT_FOUND ? TRUE : FALSE); + return (TRUE); return (ACPI_BATTERY_PRESENT(s) ? TRUE : FALSE); }