Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi introduce acpi_device_present() to...



details:   https://anonhg.NetBSD.org/src/rev/aba47b48fd58
branches:  trunk
changeset: 318802:aba47b48fd58
user:      christos <christos%NetBSD.org@localhost>
date:      Sat May 05 17:16:23 2018 +0000
description:
introduce acpi_device_present() to replace the previous _STA checks.

diffstat:

 sys/dev/acpi/acpi.c     |  35 +++++++++++++++++++++++++++++++++--
 sys/dev/acpi/acpi_i2c.c |   6 ++++--
 sys/dev/acpi/acpi_pci.c |   7 +++++--
 sys/dev/acpi/acpivar.h  |   4 +++-
 4 files changed, 45 insertions(+), 7 deletions(-)

diffs (150 lines):

diff -r 2b86deaa3f35 -r aba47b48fd58 sys/dev/acpi/acpi.c
--- a/sys/dev/acpi/acpi.c       Sat May 05 16:24:26 2018 +0000
+++ b/sys/dev/acpi/acpi.c       Sat May 05 17:16:23 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi.c,v 1.269 2018/04/07 15:49:52 christos Exp $      */
+/*     $NetBSD: acpi.c,v 1.270 2018/05/05 17:16:23 christos Exp $      */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.269 2018/04/07 15:49:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.270 2018/05/05 17:16:23 christos Exp $");
 
 #include "pci.h"
 #include "opt_acpi.h"
@@ -898,6 +898,17 @@
 
                di = ad->ad_devinfo;
 
+               /*
+                * We only attach devices which are present, enabled, and
+                * functioning properly. However, if a device is enabled,
+                * it is decoding resources and we should claim these,
+                * if possible. This requires changes to bus_space(9).
+                */
+               if (di->Type == ACPI_TYPE_DEVICE &&
+                   !acpi_device_present(ad->ad_handle)) {
+                       continue;
+               }
+
                if (di->Type == ACPI_TYPE_POWER)
                        continue;
 
@@ -1749,6 +1760,22 @@
        return false;
 }
 
+bool
+acpi_device_present(ACPI_HANDLE handle)
+{
+       ACPI_STATUS rv;
+       ACPI_INTEGER sta;
+
+       rv = acpi_eval_integer(handle, "_STA", &sta);
+
+       if (ACPI_FAILURE(rv)) {
+               /* No _STA method -> must be there */
+               return rv == AE_NOT_FOUND;
+       }
+
+       return (sta & ACPI_STA_OK) == ACPI_STA_OK;
+}
+
 /*
  * ACPIVERBOSE.
  */
@@ -1797,6 +1824,7 @@
        ACPI_DEVICE_INFO *newdi;
        ACPI_STATUS rv;
 
+
        /*
         * If the device is valid and present,
         * but not enabled, try to activate it.
@@ -1804,6 +1832,9 @@
        if (((*di)->Valid & valid) != valid)
                return;
 
+       if (!acpi_device_present(handle))
+               return;
+
        rv = acpi_allocate_resources(handle);
 
        if (ACPI_FAILURE(rv))
diff -r 2b86deaa3f35 -r aba47b48fd58 sys/dev/acpi/acpi_i2c.c
--- a/sys/dev/acpi/acpi_i2c.c   Sat May 05 16:24:26 2018 +0000
+++ b/sys/dev/acpi/acpi_i2c.c   Sat May 05 17:16:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.c,v 1.3 2018/04/07 15:49:52 christos Exp $ */
+/* $NetBSD: acpi_i2c.c,v 1.4 2018/05/05 17:16:23 christos Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.3 2018/04/07 15:49:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.4 2018/05/05 17:16:23 christos Exp $");
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -228,6 +228,8 @@
        SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) {
                if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
                        continue;
+               if (!acpi_device_present(ad->ad_handle))
+                       continue;
                acpi_enter_i2c_device(ad, array);
        }
        return array;
diff -r 2b86deaa3f35 -r aba47b48fd58 sys/dev/acpi/acpi_pci.c
--- a/sys/dev/acpi/acpi_pci.c   Sat May 05 16:24:26 2018 +0000
+++ b/sys/dev/acpi/acpi_pci.c   Sat May 05 17:16:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci.c,v 1.21 2018/04/07 15:49:52 christos Exp $ */
+/* $NetBSD: acpi_pci.c,v 1.22 2018/05/05 17:16:23 christos Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.21 2018/04/07 15:49:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci.c,v 1.22 2018/05/05 17:16:23 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -185,6 +185,9 @@
        if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
                goto rec;
 
+       if (!acpi_device_present(ad->ad_handle))
+               goto rec;
+
        if (ad->ad_devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) {
 
                ap = kmem_zalloc(sizeof(*ap), KM_SLEEP);
diff -r 2b86deaa3f35 -r aba47b48fd58 sys/dev/acpi/acpivar.h
--- a/sys/dev/acpi/acpivar.h    Sat May 05 16:24:26 2018 +0000
+++ b/sys/dev/acpi/acpivar.h    Sat May 05 17:16:23 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpivar.h,v 1.74 2016/06/21 11:33:33 nonaka Exp $      */
+/*     $NetBSD: acpivar.h,v 1.75 2018/05/05 17:16:23 christos Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -303,6 +303,8 @@
 void           acpi_disable(void);
 int            acpi_check(device_t, const char *);
 
+bool           acpi_device_present(ACPI_HANDLE);
+
 int            acpi_reset(void);
 
 ACPI_PHYSICAL_ADDRESS  acpi_OsGetRootPointer(void);



Home | Main Index | Thread Index | Old Index