git: aa7c028adbb4 - main - devd: Improve devmatch support

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 27 Oct 2023 21:24:27 UTC
The branch main has been updated by imp:

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

commit aa7c028adbb48bfb5404c567d66cab313d471cfc
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-10-27 21:23:47 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-10-27 21:24:19 +0000

    devd: Improve devmatch support
    
    We know that calling devmatch will be futile if there's no plug and play
    information for it to match on. Avoid this generically when we see
            "? at +on"
    which happens only when the location and pnpinfo aren't provided. Don't
    call "service devmatch quietstart" here.
    
    We also ignore ACPI devices with a _HID of none. These also will never
    load a new driver, so avoid calling "service devmatch quietstart" here too.
    
    Use the more compatct "$*" instead of "'?'$_" when calling "service
    devmatch quietstart" since it will evaluate to the same thing.
    
    On my laptop, this eliminates 45% of the calls to devmatch. While it
    would be even better to integrate devmatch into devd (so we only parse
    linker.hints once), that will have to wait for another day as it's a bit
    more complex to arrange that avoiding easy to avoid calls.
    
    Sponsored by:           Netflix
    Reviewed by:            emaste
    Differential Revision:  https://reviews.freebsd.org/D42326
---
 sbin/devd/devmatch.conf | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/sbin/devd/devmatch.conf b/sbin/devd/devmatch.conf
index 085338eabca4..a7c27857c0bd 100644
--- a/sbin/devd/devmatch.conf
+++ b/sbin/devd/devmatch.conf
@@ -1,14 +1,32 @@
+# Implement the run-time component of devmatch by reacting to nomatch events.
+
 #
+# Ignore those devices that can't possibly match. When there's neither a
+# location, nor a pnpinfo string, we know that there's nothing devmatch can
+# match on. When it's only a location, it'd debateable, but for nomatch
+# events, we can't disambiguate between the two reliably.
 #
+nomatch 101 {
+	match "_" " +at +on .*";
+};
 
 #
-# Example devd configuration file for automatically
-# loading what modules we can based on nomatch
-# events.
+# Ignore ACPI devices whose _HID is none. These cannot tell us what to load,
+# since 'none' is not a valid id. There's no need to call devvmatch for these either.
+#
+nomatch 101 {
+	match "_HID" "none";
+	match "bus" "acpi[0-9]+";
+};
+
 #
 # Generic NOMATCH event
+#
+# Note: It would be better to have some internal-to-devd action that will do
+# what devmatch does without re-parsing loader.hints for each invocation
+#
 nomatch 100 {
-	action "service devmatch quietstart '?'$_";
+	action "service devmatch quietstart $*";
 };
 
 # Add the following to devd.conf to prevent this from running: