Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi acpivga(4): Provide hooks for ACPI display noti...
details: https://anonhg.NetBSD.org/src/rev/f747342ab35a
branches: trunk
changeset: 362462:f747342ab35a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Feb 27 21:21:51 2022 +0000
description:
acpivga(4): Provide hooks for ACPI display notifications.
The Intel i915 graphics driver needs to receive ACPI VGA 0x80
notifications, but with NetBSD's ACPI API, each ACPI node -- such as
the VGA node -- can only have one notifier attached, and acpivga(4)
already uses it.
diffstat:
sys/dev/acpi/acpi_display.c | 76 +++++++++++++++++++++++++++++++++++++++++++-
sys/dev/acpi/acpi_display.h | 42 ++++++++++++++++++++++++
2 files changed, 115 insertions(+), 3 deletions(-)
diffs (177 lines):
diff -r a8d6bc3cbaea -r f747342ab35a sys/dev/acpi/acpi_display.c
--- a/sys/dev/acpi/acpi_display.c Sun Feb 27 21:05:11 2022 +0000
+++ b/sys/dev/acpi/acpi_display.c Sun Feb 27 21:21:51 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_display.c,v 1.21 2021/12/30 14:40:06 riastradh Exp $ */
+/* $NetBSD: acpi_display.c,v 1.22 2022/02/27 21:21:51 riastradh Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -66,19 +66,23 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.21 2021/12/30 14:40:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.22 2022/02/27 21:21:51 riastradh Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/kmem.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/pserialize.h>
+#include <sys/pslist.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <sys/xcall.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcidevs.h>
+#include <dev/acpi/acpi_display.h>
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
@@ -386,6 +390,65 @@
uint8_t *);
/*
+ * Display notification callbacks -- used by i915
+ */
+
+struct acpidisp_notifier {
+ void (*adn_func)(ACPI_HANDLE, uint32_t, void *);
+ void *adn_cookie;
+ struct pslist_entry adn_entry;
+};
+
+static struct {
+ kmutex_t lock;
+ struct pslist_head list;
+} acpidisp_notifiers;
+
+struct acpidisp_notifier *
+acpidisp_register_notify(void (*func)(ACPI_HANDLE, uint32_t, void *),
+ void *cookie)
+{
+ struct acpidisp_notifier *adn;
+
+ adn = kmem_zalloc(sizeof(*adn), KM_SLEEP);
+ adn->adn_func = func;
+ adn->adn_cookie = cookie;
+ PSLIST_ENTRY_INIT(adn, adn_entry);
+
+ mutex_enter(&acpidisp_notifiers.lock);
+ PSLIST_WRITER_INSERT_HEAD(&acpidisp_notifiers.list, adn, adn_entry);
+ mutex_exit(&acpidisp_notifiers.lock);
+
+ return adn;
+}
+
+void
+acpidisp_deregister_notify(struct acpidisp_notifier *adn)
+{
+
+ mutex_enter(&acpidisp_notifiers.lock);
+ PSLIST_WRITER_REMOVE(adn, adn_entry);
+ mutex_exit(&acpidisp_notifiers.lock);
+
+ xc_barrier(0);
+ kmem_free(adn, sizeof(*adn));
+}
+
+static void
+acpidisp_notify(ACPI_HANDLE handle, uint32_t notify)
+{
+ struct acpidisp_notifier *adn;
+ int s;
+
+ s = pserialize_read_enter();
+ PSLIST_READER_FOREACH(adn, &acpidisp_notifiers.list,
+ struct acpidisp_notifier, adn_entry) {
+ (*adn->adn_func)(handle, notify, adn->adn_cookie);
+ }
+ pserialize_read_exit(s);
+}
+
+/*
* Autoconfiguration for the acpivga driver.
*/
@@ -863,6 +926,8 @@
KASSERT(callback != NULL);
(void)AcpiOsExecute(OSL_NOTIFY_HANDLER, callback, asc);
+
+ acpidisp_notify(handle, notify);
}
static void
@@ -2081,7 +2146,9 @@
switch (cmd) {
case MODULE_CMD_INIT:
-
+ KASSERT(PSLIST_READER_FIRST(&acpidisp_notifiers.list,
+ struct acpidisp_notifier, adn_entry) == NULL);
+ mutex_init(&acpidisp_notifiers.lock, MUTEX_DEFAULT, IPL_NONE);
#ifdef _MODULE
rv = config_init_component(cfdriver_ioconf_acpivga,
cfattach_ioconf_acpivga, cfdata_ioconf_acpivga);
@@ -2093,7 +2160,10 @@
#ifdef _MODULE
rv = config_fini_component(cfdriver_ioconf_acpivga,
cfattach_ioconf_acpivga, cfdata_ioconf_acpivga);
+ if (rv)
+ break;
#endif
+ mutex_destroy(&acpidisp_notifiers.lock);
break;
default:
diff -r a8d6bc3cbaea -r f747342ab35a sys/dev/acpi/acpi_display.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/acpi/acpi_display.h Sun Feb 27 21:21:51 2022 +0000
@@ -0,0 +1,42 @@
+/* $NetBSD: acpi_display.h,v 1.1 2022/02/27 21:21:51 riastradh Exp $ */
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_ACPI_ACPI_DISPLAY_H_
+#define _DEV_ACPI_ACPI_DISPLAY_H_
+
+#include <sys/types.h>
+
+#include <dev/acpi/acpica.h>
+
+struct acpidisp_notifier;
+
+struct acpidisp_notifier *acpidisp_register_notify(void (*func)(ACPI_HANDLE,
+ uint32_t, void *), void *);
+void acpidisp_deregister_notify(struct acpidisp_notifier *);
+
+#endif /* _DEV_ACPI_ACPI_DISPLAY_H_ */
Home |
Main Index |
Thread Index |
Old Index