NetBSD Problem Report #59179

From www@netbsd.org  Sat Mar 15 20:31:13 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 073BA1A923E
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 15 Mar 2025 20:31:13 +0000 (UTC)
Message-Id: <20250315203111.DFF781A923F@mollari.NetBSD.org>
Date: Sat, 15 Mar 2025 20:31:11 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: DVF_DETACH_SHUTDOWN: audit drivers for unnecessary use
X-Send-Pr-Version: www-1.0

>Number:         59179
>Category:       kern
>Synopsis:       DVF_DETACH_SHUTDOWN: audit drivers for unnecessary use
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 15 20:35:00 +0000 2025
>Last-Modified:  Mon Mar 31 14:50:06 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NotBeingShutDown Foundation
>Environment:
>Description:
Various drivers like ohci@pci have DVF_DETACH_SHUTDOWN set for no apparent reason.

The only reason to set it is if some kind of persistent storage must be synced, or some kind of resource must be released, in order for software and hardware to properly function.

It makes no sense to set it on a generic USB host controller interface driver, for example: there is no persistent state and no resources that need to be released before it can be shut down.  Individual USB drivers -- like sd(4) via umass(4) -- might reasonably use DVF_DETACH_SHUTDOWN (or a pmf shutdown hook) to sync persistent storage, but there is no reason for the HCI driver to do that.

And when the detach function, which is inevitably less well-tested (disappointing as that may be), is broken, that unnecessarily breaks shutdown on affected machines.
>How-To-Repeat:
shutdown on a machine with a broken driver detach routine
>Fix:
1. review all cases of DVF_DETACH_SHUTDOWN
2. for each case, write justification or nix it

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59179 CVS commit: src/sys/dev/pci
Date: Mon, 31 Mar 2025 14:48:50 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Mon Mar 31 14:48:50 UTC 2025

 Modified Files:
 	src/sys/dev/pci: ohci_pci.c

 Log Message:
 ohci@pci: Don't detach on shutdown.

 If there's some USB device that requires detach on shutdown (which
 would be surprising, because USB devices should generally be safe to
 yank at any time, and _storage_ drivers such as ld(4) or sd(4) should
 already be synced at shutdown some other way) then that driver should
 have DVF_DETACH_SHUTDOWN -- not the entire HCI.

 PR port-amd64/59180: System reboots instead of shutting down
 PR kern/59179: DVF_DETACH_SHUTDOWN: audit drivers for unnecessary use


 To generate a diff of this commit:
 cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ohci_pci.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.