Index: sys/cam/ata/ata_da.c =================================================================== --- sys/cam/ata/ata_da.c +++ sys/cam/ata/ata_da.c @@ -1321,6 +1321,7 @@ * this device and start the probe * process. */ + xpt_print(path, "FOUND DEVICE\n"); status = cam_periph_alloc(adaregister, adaoninvalidate, adacleanup, adastart, "ada", CAM_PERIPH_BIO, Index: sys/cam/ata/ata_xpt.c =================================================================== --- sys/cam/ata/ata_xpt.c +++ sys/cam/ata/ata_xpt.c @@ -63,6 +63,8 @@ #include /* for xpt_print below */ #include "opt_cam.h" +#include + struct ata_quirk_entry { struct scsi_inquiry_pattern inq_pat; u_int8_t quirks; @@ -844,8 +846,12 @@ * already marked unconfigured, notify the peripheral * drivers that this device is no more. */ -device_fail: if ((path->device->flags & CAM_DEV_UNCONFIGURED) == 0) +device_fail: + if ((path->device->flags & CAM_DEV_UNCONFIGURED) == 0) { + xpt_print(path, "Unconfigured not set, losing device 1\n"); + kdb_backtrace(); xpt_async(AC_LOST_DEVICE, path, NULL); + } PROBE_SET_ACTION(softc, PROBE_INVALID); found = 0; goto done; @@ -936,14 +942,20 @@ sizeof(ident_buf->serial))) { /* The device was replaced. */ changed = 2; + xpt_print(periph->path, "Device Replaced 1\n"); + kdb_backtrace(); xpt_async(AC_LOST_DEVICE, path, NULL); } else if (bcmp(&softc->ident_data, ident_buf, sizeof(*ident_buf))) { /* The device is the same, but has changed. */ changed = 1; + xpt_print(periph->path, "Same but changed\n"); + kdb_backtrace(); } else { /* Nothing has changed. */ changed = 0; + xpt_print(periph->path, "not changed\n"); + kdb_backtrace(); } } else { /* This is a new device. */ @@ -1153,6 +1165,8 @@ if (periph->path->device->flags & CAM_DEV_UNCONFIGURED) { path->device->flags &= ~CAM_DEV_UNCONFIGURED; xpt_acquire_device(path->device); + xpt_print(periph->path, "Clearing unconfigured and sending FOUND_DEVICE 1\n"); + kdb_backtrace(); done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); xpt_async(AC_FOUND_DEVICE, path, done_ccb); @@ -1196,6 +1210,8 @@ if (periph->path->device->flags & CAM_DEV_UNCONFIGURED) { path->device->flags &= ~CAM_DEV_UNCONFIGURED; xpt_acquire_device(path->device); + xpt_print(periph->path, "Clearing unconfigured and sending FOUND_DEVICE 2\n"); + kdb_backtrace(); done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); xpt_async(AC_FOUND_DEVICE, path, done_ccb); @@ -1268,6 +1284,8 @@ softc->caps = caps; if (periph->path->device->flags & CAM_DEV_UNCONFIGURED) { path->device->flags &= ~CAM_DEV_UNCONFIGURED; + xpt_print(periph->path, "Clearing unconfigured and sending FOUND_DEVICE 3\n"); + kdb_backtrace(); xpt_acquire_device(path->device); done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); @@ -1287,9 +1305,13 @@ /* Check that it is the same device. */ if (bcmp(&softc->ident_data, ident_buf, 53)) { /* Device changed. */ + xpt_print(periph->path, "Device changed 2, sending lost device\n"); + kdb_backtrace(); changed = 2; xpt_async(AC_LOST_DEVICE, path, NULL); } else { + xpt_print(periph->path, "Not changed, replacing\n"); + kdb_backtrace(); bcopy(&softc->ident_data, ident_buf, sizeof(struct ata_params)); changed = 0; } @@ -1321,6 +1343,8 @@ if (periph->path->device->flags & CAM_DEV_UNCONFIGURED) { path->device->flags &= ~CAM_DEV_UNCONFIGURED; + xpt_print(periph->path, "Clearing unconfigured and sending FOUND_DEVICE 4\n"); + kdb_backtrace(); xpt_acquire_device(path->device); done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); @@ -2083,6 +2107,8 @@ } else if (async_code == AC_LOST_DEVICE && (device->flags & CAM_DEV_UNCONFIGURED) == 0) { device->flags |= CAM_DEV_UNCONFIGURED; + printf("Setting unconfigured and sending LOST_DEVICE\n"); + kdb_backtrace(); xpt_release_device(device); } else if (async_code == AC_TRANSFER_NEG) { struct ccb_trans_settings *settings; Index: sys/cam/cam_periph.c =================================================================== --- sys/cam/cam_periph.c +++ sys/cam/cam_periph.c @@ -63,6 +63,8 @@ #include #include +#include + static u_int camperiphnextunit(struct periph_driver *p_drv, u_int newunit, bool wired, path_id_t pathid, target_id_t target, @@ -221,6 +223,8 @@ if ((periph = cam_periph_find(path, name)) != NULL) { if ((periph->flags & CAM_PERIPH_INVALID) != 0 && (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) == 0) { + xpt_print(periph->path, "Hit the hot plug path with ac = %#x\n", code); + kdb_backtrace(); periph->flags |= CAM_PERIPH_NEW_DEV_FOUND; periph->deferred_callback = ac_callback; periph->deferred_ac = code; @@ -660,10 +664,15 @@ * We only tear down the device the first time a peripheral is * invalidated. */ - if ((periph->flags & CAM_PERIPH_INVALID) != 0) + if ((periph->flags & CAM_PERIPH_INVALID) != 0) { + xpt_print(periph->path, "Periph invalidated again\n"); + kdb_backtrace(); return; + } CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n")); + xpt_print(periph->path, "Periph invalidated\n"); + kdb_backtrace(); if ((periph->flags & CAM_PERIPH_ANNOUNCED) && !rebooting) { struct sbuf sb; char buffer[160]; @@ -758,6 +767,8 @@ union ccb ccb; void *arg; + xpt_print(periph->path, "Somebody set us up the new periph flag\n"); + kdb_backtrace(); memset(&ccb, 0, sizeof(ccb)); switch (periph->deferred_ac) { case AC_FOUND_DEVICE: @@ -1473,6 +1484,7 @@ { switch (code) { case AC_LOST_DEVICE: + xpt_print(path, "AC LOST cam_periph_async zapping it\n"); cam_periph_invalidate(periph); break; default: @@ -1938,6 +1950,7 @@ case CAM_DEV_NOT_THERE: error = ENXIO; action = SSQ_LOST; + xpt_print(ccb->ccb_h.path, "Setting SSQ_LOST on CAM_DEV_NOT_THERE\n"); break; case CAM_REQ_INVALID: case CAM_PATH_INVALID: @@ -2054,6 +2067,7 @@ * Let peripheral drivers know that this * device has gone away. */ + xpt_print(newpath, "sending LOST DEVICE\n"); xpt_async(AC_LOST_DEVICE, newpath, NULL); xpt_free_path(newpath); } Index: sys/cam/cam_xpt.c =================================================================== --- sys/cam/cam_xpt.c +++ sys/cam/cam_xpt.c @@ -75,6 +75,8 @@ #include "opt_cam.h" +#include + /* Wild guess based on not wanting to grow the stack too much */ #define XPT_PRINT_MAXLEN 512 #ifdef PRINTF_BUFR_SIZE