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 <ali...@gmail.com>.
  
  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);
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to