git: 68c3f0302106 - main - newbus: Change attach failure behavior

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sun, 04 Dec 2022 23:33:02 UTC
The branch main has been updated by imp:

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

commit 68c3f0302106643207dcdfe3b414810e245228e5
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-12-04 23:22:43 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-12-04 23:29:03 +0000

    newbus: Change attach failure behavior
    
    In the rare case that we succeed in probing, but fail to attach, flip
    the default to be to disable the
    device. hw.bus.disable_failed_devices=false is no required to restore
    the old behavior. The old behavior dates form a time when dynamic
    control of devices wasn't yet present (devctl didn't exist). Now that
    one can retry probe/attach the device with devctl, the default doesn't
    make sense: The more desirable behaivor is to have stable device numbers
    when one has several instances of the same device in a system (common
    for NICs or HBAs).
    
    Reviewed by:            jhb (verbal)
    Sponsored by:           Netflix
---
 UPDATING            | 8 ++++++++
 sys/kern/subr_bus.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/UPDATING b/UPDATING
index 564336295e7b..e14e609e30b7 100644
--- a/UPDATING
+++ b/UPDATING
@@ -27,6 +27,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 14.x IS SLOW:
 	world, or to merely disable the most expensive debugging functionality
 	at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20221204:
+	hw.bus.disable_failed_devices has changed from 'false' to 'true' by
+	default. Now if newbus succeeds in probing a device, but fails to attach
+	the device, we'll disable the device. In the past, we'd keep retrying
+	the device on each new driver loaded. To get that behavior now, one
+	needs to use devctl to re-enable the device, and repobe it (or set
+	the sysctl/tunable hw.bus.disable_failed_devices=false).
+
 20221122:
 	pf no longer accepts 'scrub fragment crop' or 'scrub fragment drop-ovl'.
 	These configurations are no longer automatically reinterpreted as
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index b9615b033007..6a5ec4efc38d 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -69,7 +69,7 @@ SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL,
 SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL,
     NULL);
 
-static bool disable_failed_devs = false;
+static bool disable_failed_devs = true;
 SYSCTL_BOOL(_hw_bus, OID_AUTO, disable_failed_devices, CTLFLAG_RWTUN, &disable_failed_devs,
     0, "Do not retry attaching devices that return an error from DEVICE_ATTACH the first time");