NetBSD Problem Report #60428
From john@klos.com Wed Jul 8 16:25:39 2026
Return-Path: <john@klos.com>
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 "YR2" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 4C7611A923A
for <gnats-bugs@gnats.NetBSD.org>; Wed, 8 Jul 2026 16:25:39 +0000 (UTC)
Message-Id: <202607081625.668GPaBa005721@bunny.zia.io>
Date: Wed, 8 Jul 2026 16:25:36 GMT
From: john@ziaspace.com
Reply-To: john@ziaspace.com
To: gnats-bugs@NetBSD.org
Subject: NetBSD 11.99.6/sparc64 panics on USB insertion
X-Send-Pr-Version: 3.95
X-From4GNATS: "john@ziaspace.com via gnats" <gnats-admin@NetBSD.org>
>Number: 60428
>Category: port-sparc64
>Synopsis: NetBSD 11.99.6/sparc64 panics on USB insertion
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: thorpej
>State: feedback
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jul 08 16:30:01 +0000 2026
>Closed-Date:
>Last-Modified: Fri Sep 18 15:30:01 +0000 2026
>Originator: John Klos
>Release: NetBSD 11.99.6
>Organization:
>Environment:
System: NetBSD sparky.zia.io 11.99.6 NetBSD 11.99.6 (SPARKY) #0: Tue Jul 7 22:30:01 UTC 2026 john@frigg.zia.io:/usr/current/obj-sparc64/sys/arch/sparc64/compile/SPARKY sparc64
Architecture: sparc64
Machine: sparc64
>Description:
NetBSD 10 on sparc64 (Sun Fire V245) couldn't use mpt*, so I used an SSD
attached via USB with a kernel which didn't have mpt*.
I decided to give a new -current kernel a try, and it panicked on boot with:
[ 1.0000000] NetBSD 11.99.6 (GENERIC) #0: Sun Jul 5 23:38:34 UTC 2026
[ 1.0000000] mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/sparc64/compile/GENERIC
[ 1.0000000] total memory = 16384 MB
[ 1.0000000] avail memory = 16070 MB
[ 1.0000000] mainbus0 (root): SUNW,Sun-Fire-V245 (Sun Fire V245): hostid 84a238ca
[ 1.0000000] cpu0 at mainbus0: SUNW,UltraSPARC-IIIi @ 1504 MHz, CPU id 0
...
[ 2.7483809] uhub0 at usb0: NetBSD (0x0000) OHCI root hub (0x0000), class 9/0, rev 1.00/1.00, addr 1
[ 2.7483809] uhub1 at usb1: NetBSD (0x0000) OHCI root hub (0x0000), class 9/0, rev 1.00/1.00, addr 1
[ 2.7483809] uhub2 at usb2: NetBSD (0x0000) EHCI root hub (0x0000), class 9/0, rev 2.00/1.00, addr 1
[ 2.7483809] scsibus0: waiting 2 seconds for devices to settle...
[ 2.9047207] atapibus0 at atabus0: 2 targets
[ 2.9547218] cd0 at atapibus0 drive 0: <MATSHITADVD-RAM UJ-85JS, , F100> cdrom removable
[ 3.2547203] umass0 at uhub2 port 1 configuration 1 interface 0
[ 3.3247204] umass0: SABRENT (0x152d) SABRENT (0x1561), rev 2.10/2.04, addr 2
[ 3.4047198] scsibus1 at umass0: 2 targets, 1 lun per target
[ 4.0647202] ehci0: handing over full speed device on port 3 to ohci0
[ 4.7947203] sd0 at scsibus0 target 0 lun 0: <ATA, SAMSUNG MZ7LM480, 204Q> disk fixed
[ 4.8894218] sd0: 447 GB, 457863 cyl, 16 head, 127 sec, 512 bytes/sect x 937703088 sectors
[ 4.9873350] sd0: tagged queueing
[ 5.0447213] sd1 at scsibus1 target 0 lun 0: <SABRENT, , 0204> disk fixedpanic: kernel diagnostic assertion "devhandle_type(devhandle) == DEVHANDLE_TYPE_OF" failed: file "/usr/src/sys/arch/sparc64/sparc64/autoconf.c", line 1240
[ 5.2847198] cpu1: Begin traceback...
[ 5.3247198] cpu1: End traceback...
Stopped in pid 0.169 (system) at netbsd:cpu_Debugger+0x4: nop
db{1}> bt
kern_assert(1abc2f8, 1abc2e8, 1ac1008, 1ac0fd8, 4d8, 1c01e80) at netbsd:kern_assert+0x34
device_register(110a017c0, 5b3ec9b00, 110a00780, 0, 2060cf0, 110a00ac0) at netbsd:device_register+0x860
config_attach_internal(110a00ac0, 1, 5b3ec9b00, 0, 1ac0fc0, 20c5000) at netbsd:config_attach_internal+0x1c8
config_attach(110a00ac0, 2069fb8, 5b3ec9b00, 117c9a0, 5b3ec9b70, 8) at netbsd:config_attach+0x38
scsi_probe_device(1109b0580, 5b3ec9af8, 2069fb8, 1109e6530, 1, 2060cf0) at netbsd:scsi_probe_device+0x420
scsi_probe_bus(1109b0580, 1, 0, 1109b06a0, 110ae6090, 10dccc492) at netbsd:scsi_probe_bus+0x450
scsibus_discover_thread(1109b0580, 209c038, 209c030, 209c020, 1109e6530, 110ae23d0) at netbsd:scsibus_discover_thread+0x7clwp_trampoline(1000, 5a3d20200, 1106043d0, 1105e7680, 20000, 1105e7640) at netbsd:lwp_trampoline+0x8
That was while booting the install ISO with the USB-SSD attached.
After unplugging and installing 11.99.6 fully, and on a multiuser system, I tried
inserting the USB-SSD and got this:
[ 57150.4058078] umass0 at uhub2 port 1 configuration 1 interface 0
[ 57150.4773675] umass0: SABRENT (0x152d) SABRENT (0x1561), rev 2.10/2.04, addr 2
[ 57150.5659083] scsibus1 at umass0: 2 targets, 1 lun per target
[ 57150.6358132] sd2 at scsibus1 target 0 lun 0: <SABRENT, , 0204> disk fixedpanic: kernel diagnostic assertion "devhandle_type(devhandle) == DEVHANDLE_TYPE_OF" failed: file "/usr/current/src/sys/arch/sparc64/sparc64/autoconf.c", line 1240
[ 57150.8858165] cpu1: Begin traceback...
[ 57150.9258172] cpu1: End traceback...
[ 57150.9758182] Frame pointer is at 0x5dc8e2b41
[ 57151.0258190] Call traceback:
[ 57151.0658198] netbsd:cpu_reboot+0x254(20c6d20, 113229000, ff0f0000000001, 0, 2070400, 0) fp = 5dc8e2c21
[ 57151.1758218] netbsd:kern_reboot+0x60(104, 0, 20bec00, 0, 0, 113229000) fp = 5dc8e2cd1
[ 57151.2658234] netbsd:vpanic+0x188(104, 0, ff0f0000000001, 0, e0048000, 0) fp = 5dc8e2d81
[ 57151.3658253] netbsd:kern_assert+0x34(1ac0648, 5dc8e3778, 20c6b70, 104, 20c6c00, 20c5800) fp = 5dc8e2e31
[ 57151.4858275] netbsd:device_register+0x860(1ac0648, 1ac0638, 1ac5450, 1ac5418, 4d8, 1c08590) fp = 5dc8e2ef1
[ 57151.5958295] netbsd:config_attach_internal+0x1c8(110b5c800, 5dc8e3b00, 11322ab40, 0, 2060cf0, 1151b1240) fp = 5dc8e3081
[ 57151.7258319] netbsd:config_attach+0x38(1151b1240, 1, 5dc8e3b00, 0, 1ac5400, 20c5000) fp = 5dc8e3161
[ 57151.8458343] netbsd:scsi_probe_device+0x420(1151b1240, 206a018, 5dc8e3b00, 117ce80, 5dc8e3b70, 8) fp = 5dc8e3241
[ 57151.9658364] netbsd:scsi_probe_bus+0x450(1156b6ea0, 5dc8e3af8, 206a018, 115e739b0, 1, 2060cf0) fp = 5dc8e3401
[ 57152.0858385] netbsd:scsibus_discover_thread+0x7c(1156b6ea0, 1, 0, 112135220, 11519d290, 1159ed042) fp = 5dc8e3571
[ 57152.2158409] netbsd:lwp_trampoline+0x8(1156b6ea0, 113229000, 113229000, 5a2e38000, 115e739b0, 1200fd5d0) fp = 5dc8e3621
[ 57152.3458435] netbsd:1106515d0+0(1108dc180, 9c, 1106568c0, 20, 20000, 1105e7640) fp = 2069e98
[ 57152.4458454] dumping to dev 7,1 offset 95
15997 M [ 57162.5060308] cpu0[123 nd6_timer]: kernel lock spinout
...and it just hung and made no progress in writing out the dump.
>How-To-Repeat:
Connect USB storage to system running 11.99.6.
Note: this machine takes too much power, so I can't leave it plugged in,
and I won't be physically local to it for a while, so I won't be able to
test any fixes.
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-sparc64-maintainer->thorpej
Responsible-Changed-By: riastradh@NetBSD.org
Responsible-Changed-When: Wed, 08 Jul 2026 17:04:58 +0000
Responsible-Changed-Why:
Can you please take a look?
State-Changed-From-To: open->analyzed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Wed, 08 Jul 2026 17:04:58 +0000
State-Changed-Why:
The assertion is here:
1232 /*
1233 * busdev now points to the direct descendent of the
1234 * controller ("atabus" or "scsibus"). Get the
1235 * controller's devhandle. Hoist it up one more so
1236 * that busdev points at the controller.
1237 */
1238 busdev = device_parent(busdev);
1239 devhandle = device_handle(busdev);
=> 1240 KASSERT(devhandle_type(devhandle) == DEVHANDLE_TYPE_OF);
1241 ofnode = devhandle_to_of(devhandle);
https://nxr.netbsd.org/xref/src/sys/arch/sparc64/sparc64/autoconf.c?r=1.251#1232
Since pluggable USB devices almost certainly have no associated OF
nodes, this is probably a matter of:
--- src/sys/arch/sparc64/sparc64/autoconf.c
+++ src/sys/arch/sparc64/sparc64/autoconf.c
@@ -1237,7 +1237,8 @@
*/
busdev = device_parent(busdev);
devhandle = device_handle(busdev);
- KASSERT(devhandle_type(devhandle) == DEVHANDLE_TYPE_OF);
+ if (devhandle_type(devhandle) != DEVHANDLE_TYPE_OF)
+ return;
ofnode = devhandle_to_of(devhandle);
From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: thorpej@netbsd.org, port-sparc64-maintainer@netbsd.org,
netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, john@ziaspace.com
Subject: Re: port-sparc64/60428 (NetBSD 11.99.6/sparc64 panics on USB insertion)
Date: Wed, 8 Jul 2026 17:07:30 +0000
> Date: Wed, 8 Jul 2026 17:04:59 +0000 (UTC)
> From: riastradh@NetBSD.org
>
> Since pluggable USB devices almost certainly have no associated OF
> nodes, this is probably a matter of:
>
> --- src/sys/arch/sparc64/sparc64/autoconf.c
> +++ src/sys/arch/sparc64/sparc64/autoconf.c
> @@ -1237,7 +1237,8 @@
> */
> busdev = device_parent(busdev);
> devhandle = device_handle(busdev);
> - KASSERT(devhandle_type(devhandle) == DEVHANDLE_TYPE_OF);
> + if (devhandle_type(devhandle) != DEVHANDLE_TYPE_OF)
> + return;
> ofnode = devhandle_to_of(devhandle);
Or, better:
--- src/sys/arch/sparc64/sparc64/autoconf.c
+++ src/sys/arch/sparc64/sparc64/autoconf.c
@@ -1235,6 +1235,8 @@
* controller's devhandle. Hoist it up one more so
* that busdev points at the controller.
*/
+ if (devhandle_type(devhandle) != DEVHANDLE_TYPE_OF)
+ return;
busdev = device_parent(busdev);
devhandle = device_handle(busdev);
KASSERT(devhandle_type(devhandle) == DEVHANDLE_TYPE_OF);
From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@netbsd.org
Cc: thorpej@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
john@ziaspace.com, riastradh@netbsd.org
Subject: Re: port-sparc64/60428 (NetBSD 11.99.6/sparc64 panics on USB
insertion)
Date: Thu, 9 Jul 2026 07:01:15 +0200
Hi,
> Or, better:
>
> --- src/sys/arch/sparc64/sparc64/autoconf.c
> +++ src/sys/arch/sparc64/sparc64/autoconf.c
> @@ -1235,6 +1235,8 @@
> * controller's devhandle. Hoist it up one more so
> * that busdev points at the controller.
> */
> + if (devhandle_type(devhandle) != DEVHANDLE_TYPE_OF)
> + return;
> busdev = device_parent(busdev);
> devhandle = device_handle(busdev);
> KASSERT(devhandle_type(devhandle) == DEVHANDLE_TYPE_OF);
Before r1.230, we always set ofnode [*], so I wonder if we should continue
to do that.
We also now have the same KASSERT in the wd case on line 1276, so that
needs the same treatment. The one for FC-AL is probably OK, although I
would be tempted to change all 3 to plain return for consistency.
Regards,
Julian
[*] https://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sparc64/sparc64/autoconf.c.diff?r1=1.229;r2=1.230;f=h
--
From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@netbsd.org
Cc: thorpej@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
john@ziaspace.com
Subject: Re: port-sparc64/60428 (NetBSD 11.99.6/sparc64 panics on USB
insertion)
Date: Thu, 9 Jul 2026 07:17:08 +0200
Hi,
> Before r1.230, we always set ofnode [*], so I wonder if we should continue
> to do that.
Looking slightly more deeply [#], devhandle_to_of() has the same KASSERT,
so we must return before we call it.
> We also now have the same KASSERT in the wd case on line 1276, so that
> needs the same treatment. The one for FC-AL is probably OK, although I
> would be tempted to change all 3 to plain return for consistency.
Regards,
Julian
[#] https://nxr.netbsd.org/xref/src/sys/dev/ofw/ofw_subr.c#119
--
From: "Julian Coleman" <jdc@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60428 CVS commit: src/sys/arch/sparc64/sparc64
Date: Thu, 9 Jul 2026 07:47:40 +0000
Module Name: src
Committed By: jdc
Date: Thu Jul 9 07:47:40 UTC 2026
Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c
Log Message:
PR port-sparc64/60428
Just return instead of asserting that devhandle is DEVHANDLE_TYPE_OF.
This happens for USB disks (sd @ scsibus @ umass @ @ uhub @ usb) which
are not enumerated by the firmware.
Original patch from riastradh@ .
Apply the same for wd and fc-al as well.
To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/sys/arch/sparc64/sparc64/autoconf.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: analyzed->feedback
State-Changed-By: jdc@NetBSD.org
State-Changed-When: Thu, 09 Jul 2026 08:11:30 +0000
State-Changed-Why:
Should be fixed with src/sys/arch/sparc64/sparc64/autoconf.c r1.252
From: Julian Coleman <jdc@coris.org.uk>
To: gnats-bugs@netbsd.org
Cc: thorpej@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
john@ziaspace.com
Subject: Re: port-sparc64/60428 (NetBSD 11.99.6/sparc64 panics on USB
insertion)
Date: Thu, 9 Jul 2026 10:13:38 +0200
Hi,
> > We also now have the same KASSERT in the wd case on line 1276, so that
> > needs the same treatment. The one for FC-AL is probably OK, although I
> > would be tempted to change all 3 to plain return for consistency.
This should be fixed now with src/sys/arch/sparc64/sparc64/autoconf.c r1.252.
I tested on my U45 - the panic was there before and gone after this change.
Regards,
Julian
--
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60428 CVS commit: [netbsd-11] src/sys/arch/sparc64/sparc64
Date: Fri, 18 Sep 2026 15:27:32 +0000
Module Name: src
Committed By: martin
Date: Fri Sep 18 15:27:32 UTC 2026
Modified Files:
src/sys/arch/sparc64/sparc64 [netbsd-11]: autoconf.c ofw_patch.c
ofw_patch.h
Log Message:
Pull up following revision(s) (requested by jdc in ticket #465):
sys/arch/sparc64/sparc64/autoconf.c: revision 1.248
sys/arch/sparc64/sparc64/autoconf.c: revision 1.249
sys/arch/sparc64/sparc64/ofw_patch.c: revision 1.11
sys/arch/sparc64/sparc64/ofw_patch.h: revision 1.6
sys/arch/sparc64/sparc64/autoconf.c: revision 1.250
sys/arch/sparc64/sparc64/autoconf.c: revision 1.251
sys/arch/sparc64/sparc64/autoconf.c: revision 1.252
- all via patch
Fix up PROM's where reg is encoded as a 64-bit and a 32-bit value
(e.g. 00000400 0fc62020 00000010), but we want 2 x 64-bit values.
U45 with OBP 4.21.2 has jbus-i2c configured like this.
fix the build.
More corrections...
I was also looking at the build breakage fixed by the previous commit.
I found another issue (non-build breaking) though:
Free the results from prom_getprop() in the newly added code, if a
subsequent malloc() fails (don't lose memory).
Also properly indent a line whose preceding condition shifted right
(existing code from previously, now not always executed).
Feel free to redo these changes some other (non build-breaking) way.
Add OFW patches for U45.
Add OFW patches for U45 (missed in previous).
PR port-sparc64/60428
Just return instead of asserting that devhandle is DEVHANDLE_TYPE_OF.
This happens for USB disks (sd @ scsibus @ umass @ @ uhub @ usb) which
are not enumerated by the firmware.
Original patch from riastradh@ .
Apply the same for wd and fc-al as well.
To generate a diff of this commit:
cvs rdiff -u -r1.243.2.1 -r1.243.2.2 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.7.26.1 -r1.7.26.2 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.4.28.1 -r1.4.28.2 src/sys/arch/sparc64/sparc64/ofw_patch.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.