From 8769a2203ddcaab31ccb1a19e998deda279221f8 Mon Sep 17 00:00:00 2001 From: riastradh Date: Fri, 12 Aug 2022 16:21:41 +0000 Subject: [PATCH] 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. --- sys/dev/acpi/thinkpad_acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/acpi/thinkpad_acpi.c b/sys/dev/acpi/thinkpad_acpi.c index 35005120d57d..395bbb65c034 100644 --- a/sys/dev/acpi/thinkpad_acpi.c +++ b/sys/dev/acpi/thinkpad_acpi.c @@ -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 @@ -27,7 +27,7 @@ */ #include -__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 #include @@ -170,7 +170,7 @@ static void thinkpad_cmos(thinkpad_softc_t *, uint8_t); 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" },