git: 44d5f5ed1e95 - main - new-bus: Add taskqueue_bus to process hot-plug device events

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 10 Mar 2025 17:35:39 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=44d5f5ed1e959d8f2c22b6ee69c6a46a45ccdd8e

commit 44d5f5ed1e959d8f2c22b6ee69c6a46a45ccdd8e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-03-10 17:32:23 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-03-10 17:32:23 +0000

    new-bus: Add taskqueue_bus to process hot-plug device events
    
    Use a system-wide taskqueue for hot-plug events.  This avoids possibly
    blocking unrelated events on the thread taskqueue without requiring
    multiple driver-specific taskqueues.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D49268
---
 sys/kern/subr_bus.c | 3 +++
 sys/sys/taskqueue.h | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 0422352bba51..38a8cab639e4 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -51,6 +51,7 @@
 #include <sys/smp.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
+#include <sys/taskqueue.h>
 #include <sys/bus.h>
 #include <sys/cpuset.h>
 #ifdef INTRNG
@@ -120,6 +121,8 @@ struct device_prop_elm {
 	LIST_ENTRY(device_prop_elm) link;
 };
 
+TASKQUEUE_DEFINE_THREAD(bus);
+
 static void device_destroy_props(device_t dev);
 
 /**
diff --git a/sys/sys/taskqueue.h b/sys/sys/taskqueue.h
index 9757e1fce575..9da364a1a716 100644
--- a/sys/sys/taskqueue.h
+++ b/sys/sys/taskqueue.h
@@ -215,4 +215,10 @@ struct taskqueue *taskqueue_create_fast(const char *name, int mflags,
 				    taskqueue_enqueue_fn enqueue,
 				    void *context);
 
+/*
+ * This queue is used to process asynchronous device events such as
+ * hot plug insertion and removal of devices.
+ */
+TASKQUEUE_DECLARE(bus);
+
 #endif /* !_SYS_TASKQUEUE_H_ */