aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2018-12-06 12:34:34 +0000
committerAndriy Gapon <avg@FreeBSD.org>2018-12-06 12:34:34 +0000
commit817b71bbb92f5fcbfd9a573a8a568751af94f6eb (patch)
treea60756e8e23c9bf6cbf3efe7de1b71ece4de1bb9
parent89a9a5b5c9ce129e2e9e9ee40bd01a8ed50538f4 (diff)
downloadsrc-817b71bbb92f5fcbfd9a573a8a568751af94f6eb.tar.gz
src-817b71bbb92f5fcbfd9a573a8a568751af94f6eb.zip
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 <aliovx@gmail.com>. PR: 227191 Reported by: 0mp MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=341632
-rw-r--r--sys/dev/acpica/acpi.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index d0192eddcd15..d66e67fdcc2d 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -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);
}