Module Name:    src
Committed By:   riastradh
Date:           Fri Aug 12 16:21:41 UTC 2022

Modified Files:
        src/sys/dev/acpi: thinkpad_acpi.c

Log Message:
thinkpad(4): Don't detach on shutdown.

There's no important state that needs to be recorded, or resources
that need to be relinquished, so detach-on-shutdown isn't necessary.

At the moment, detach-on-shutdown is actually harmful here: if
shutdown is triggered by a sysmon power switch event, then
config_detach will be called from the sysmon taskqueue, but
thinkpad_detach has to wait for ACPI notifiers to finish running
which means waiting for the sysmon taskqueue -> deadlock or crash.

We should maybe arrange to do config_detach from a thread other than
the sysmon taskqueue thread to avoid this class of problems -- but
for now, thinkpad(4) has no reason to detach on shutdown anyway, so
let's take the easy path.

Note: There are many drivers that set DVF_DETACH_SHUTDOWN which
probably shouldn't; the flag means the kernel _will_ detach on
shutdown, not that it _may_.  Even those that do need to record state
or relinquish resources might be better served by pmf shutdown hooks
which can skip freeing software resources for faster shutdown.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/acpi/thinkpad_acpi.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/thinkpad_acpi.c
diff -u src/sys/dev/acpi/thinkpad_acpi.c:1.54 src/sys/dev/acpi/thinkpad_acpi.c:1.55
--- src/sys/dev/acpi/thinkpad_acpi.c:1.54	Fri Dec 31 17:22:35 2021
+++ src/sys/dev/acpi/thinkpad_acpi.c	Fri Aug 12 16:21:41 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: thinkpad_acpi.c,v 1.54 2021/12/31 17:22:35 riastradh Exp $ */
+/* $NetBSD: thinkpad_acpi.c,v 1.55 2022/08/12 16:21:41 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.54 2021/12/31 17:22:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.55 2022/08/12 16:21:41 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -170,7 +170,7 @@ static void	thinkpad_cmos(thinkpad_softc
 
 CFATTACH_DECL3_NEW(thinkpad, sizeof(thinkpad_softc_t),
     thinkpad_match, thinkpad_attach, thinkpad_detach, NULL, NULL, NULL,
-    DVF_DETACH_SHUTDOWN);
+    0);
 
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "IBM0068" },

Reply via email to