Module Name: src
Committed By: jmcneill
Date: Tue Jan 11 10:53:08 UTC 2022
Modified Files:
src/sys/dev/acpi: acpi_event.c acpi_event.h acpi_ged.c
Log Message:
acpi: ged: Mask interrupts before dispatching handler
For the benefit of GEDs backed by level interrupts, mask the interrupt
source before dispatching the handler to a worker thread and unmask it
after it has been handled.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/acpi_event.c \
src/sys/dev/acpi/acpi_event.h
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/acpi/acpi_ged.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/acpi/acpi_event.c
diff -u src/sys/dev/acpi/acpi_event.c:1.1 src/sys/dev/acpi/acpi_event.c:1.2
--- src/sys/dev/acpi/acpi_event.c:1.1 Mon Oct 22 22:29:35 2018
+++ src/sys/dev/acpi/acpi_event.c Tue Jan 11 10:53:08 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_event.c,v 1.1 2018/10/22 22:29:35 jmcneill Exp $ */
+/* $NetBSD: acpi_event.c,v 1.2 2022/01/11 10:53:08 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_event.c,v 1.1 2018/10/22 22:29:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_event.c,v 1.2 2022/01/11 10:53:08 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -40,12 +40,14 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_event.c
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
#include <dev/acpi/acpi_event.h>
+#include <dev/acpi/acpi_intr.h>
struct acpi_event {
device_t ev_dev;
ACPI_HANDLE ev_method;
bool ev_method_evt;
UINT16 ev_data;
+ void *ev_intrcookie;
};
struct acpi_event_gpio_context {
@@ -68,6 +70,7 @@ acpi_event_create(device_t dev, ACPI_HAN
ev->ev_method = NULL;
ev->ev_method_evt = false;
ev->ev_data = data;
+ ev->ev_intrcookie = NULL;
if (data <= 255) {
snprintf(namebuf, sizeof(namebuf), "_%c%02X", trigchar, data);
@@ -169,13 +172,30 @@ acpi_event_invoke(void *priv)
}
rv = AcpiEvaluateObject(ev->ev_method, NULL, arg, NULL);
- if (ACPI_FAILURE(rv))
+ if (ACPI_FAILURE(rv)) {
device_printf(ev->ev_dev, "failed to handle %s event: %s\n",
acpi_name(ev->ev_method), AcpiFormatException(rv));
+ }
+
+ if (ev->ev_intrcookie != NULL) {
+ acpi_intr_unmask(ev->ev_intrcookie);
+ }
}
ACPI_STATUS
acpi_event_notify(struct acpi_event *ev)
{
+ if (ev->ev_intrcookie != NULL) {
+ acpi_intr_mask(ev->ev_intrcookie);
+ }
+
return AcpiOsExecute(OSL_NOTIFY_HANDLER, acpi_event_invoke, ev);
}
+
+void
+acpi_event_set_intrcookie(struct acpi_event *ev, void *intrcookie)
+{
+ KASSERT(ev->ev_intrcookie == NULL);
+
+ ev->ev_intrcookie = intrcookie;
+}
Index: src/sys/dev/acpi/acpi_event.h
diff -u src/sys/dev/acpi/acpi_event.h:1.1 src/sys/dev/acpi/acpi_event.h:1.2
--- src/sys/dev/acpi/acpi_event.h:1.1 Mon Oct 22 22:29:35 2018
+++ src/sys/dev/acpi/acpi_event.h Tue Jan 11 10:53:08 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_event.h,v 1.1 2018/10/22 22:29:35 jmcneill Exp $ */
+/* $NetBSD: acpi_event.h,v 1.2 2022/01/11 10:53:08 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,5 +39,6 @@ ACPI_STATUS acpi_event_create_gpio(devic
ACPI_STATUS acpi_event_create_int(device_t, ACPI_HANDLE,
void (*)(void *, struct acpi_event *, struct acpi_irq *), void *);
ACPI_STATUS acpi_event_notify(struct acpi_event *);
+void acpi_event_set_intrcookie(struct acpi_event *, void *);
#endif /* !_DEV_ACPI_ACPI_EVENT_H */
Index: src/sys/dev/acpi/acpi_ged.c
diff -u src/sys/dev/acpi/acpi_ged.c:1.3 src/sys/dev/acpi/acpi_ged.c:1.4
--- src/sys/dev/acpi/acpi_ged.c:1.3 Fri Jan 29 15:49:55 2021
+++ src/sys/dev/acpi/acpi_ged.c Tue Jan 11 10:53:08 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_ged.c,v 1.3 2021/01/29 15:49:55 thorpej Exp $ */
+/* $NetBSD: acpi_ged.c,v 1.4 2022/01/11 10:53:08 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_ged.c,v 1.3 2021/01/29 15:49:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_ged.c,v 1.4 2022/01/11 10:53:08 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -87,6 +87,7 @@ acpi_ged_register_event(void *priv, stru
aprint_error_dev(dev, "couldn't establish interrupt (irq %d)\n", irq->ar_irq);
return;
}
+ acpi_event_set_intrcookie(ev, ih);
}
static int