From 3fba53d78015ba205d3c0d290e158889204d94f9 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 21 Jan 2026 12:04:15 +0100 Subject: [PATCH] ahci: Don't try to tell the XPT about resets if the periph is already gone Prevents: (kgdb) where #0 __curthread () at /usr/src/sys/amd64/include/pcpu_aux.h:57 #1 doadump (textdump=textdump@entry=1) at /usr/src/sys/kern/kern_shutdown.c:405 #2 0xffffffff80a20210 in kern_reboot (howto=260) at /usr/src/sys/kern/kern_shutdown.c:523 #3 0xffffffff80a20719 in vpanic (fmt=0xffffffff80f82397 "%s", ap=ap@entry=0xfffffe00a2c40af0) at /usr/src/sys/kern/kern_shutdown.c:967 #4 0xffffffff80a20553 in panic (fmt=) at /usr/src/sys/kern/kern_shutdown.c:891 #5 0xffffffff80ec27c0 in trap_fatal (frame=, eva=) at /usr/src/sys/amd64/amd64/trap.c:1000 #6 0xffffffff80ec27c0 in trap_pfault (frame=0xfffffe00a2c40b70, usermode=false, signo=, ucode=) #7 #8 0xffffffff80369a76 in xpt_async (async_code=1, path=0xfffff8000606ef40, async_arg=0x0) at /usr/src/sys/cam/cam_xpt.c:4321 #9 0xffffffff804bb529 in ahci_reset (ch=ch@entry=0xfffffe0013f5e000) at /usr/src/sys/dev/ahci/ahci.c:2512 #10 0xffffffff804b957a in ahciaction (sim=, ccb=0xfffff80003997000) at /usr/src/sys/dev/ahci/ahci.c:2846 #11 0xffffffff80367d38 in xpt_action_default (start_ccb=0xfffff80003997000) at /usr/src/sys/cam/cam_xpt.c:2689 #12 0xffffffff80374cc3 in ata_scan_bus (periph=, request_ccb=0xfffff80014905000) at /usr/src/sys/cam/ata/ata_xpt.c:1424 #13 0xffffffff8036ebb1 in xpt_action (start_ccb=) at /usr/src/sys/cam/cam_xpt.c:2526 #14 xpt_scanner_thread (dummy=) at /usr/src/sys/cam/cam_xpt.c:823 #15 0xffffffff809d7371 in fork_exit (callout=0xffffffff8036ea50 , arg=0x0, frame=0xfffffe00a2c40f40) at /usr/src/sys/kern/kern_fork.c:1153 #16 (kgdb) f 9 #9 0xffffffff804bb529 in ahci_reset (ch=ch@entry=0xfffffe0013f5e000) at /usr/src/sys/dev/ahci/ahci.c:2512 2512 xpt_async(AC_BUS_RESET, ch->path, NULL); (kgdb) p *ch->path $8 = {periph = 0x0, bus = 0x0, target = 0x0, device = 0x0} Obtained from: ElectroBSD --- sys/dev/ahci/ahci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 6b5ddef2e3be..30cd6b0b44de 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -2508,8 +2508,11 @@ ahci_reset(struct ahci_channel *ch) ch->toslots = 0; ch->wrongccs = 0; ch->fatalerr = 0; - /* Tell the XPT about the event */ - xpt_async(AC_BUS_RESET, ch->path, NULL); + /* Tell the XPT about the event if we still can. */ + if (xpt_path_periph(ch->path) != NULL) + xpt_async(AC_BUS_RESET, ch->path, NULL); + else + device_printf(ch->dev, "AHCI reset: periph already gone.\n"); /* Disable port interrupts */ ATA_OUTL(ch->r_mem, AHCI_P_IE, 0); /* Reset and reconnect PHY, */ -- 2.52.0