Author: bz
Date: Thu Nov  5 11:37:14 2020
New Revision: 367370
URL: https://svnweb.freebsd.org/changeset/base/367370

Log:
  MFC r365335:
  
    umass: enhance debugging
  
    Investigating a hang I found having some more error information
    available would be helpful, so be more verbose and also tell cam/xpt
    status in case of error/panic.

Modified:
  stable/12/sys/dev/usb/storage/umass.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/usb/storage/umass.c
==============================================================================
--- stable/12/sys/dev/usb/storage/umass.c       Thu Nov  5 11:33:23 2020        
(r367369)
+++ stable/12/sys/dev/usb/storage/umass.c       Thu Nov  5 11:37:14 2020        
(r367370)
@@ -2074,6 +2074,7 @@ static int
 umass_cam_attach_sim(struct umass_softc *sc)
 {
        struct cam_devq *devq;          /* Per device Queue */
+       cam_status status;
 
        /*
         * A HBA is attached to the CAM layer.
@@ -2102,11 +2103,12 @@ umass_cam_attach_sim(struct umass_softc *sc)
        }
 
        mtx_lock(&sc->sc_mtx);
-
-       if (xpt_bus_register(sc->sc_sim, sc->sc_dev,
-           sc->sc_unit) != CAM_SUCCESS) {
+       status = xpt_bus_register(sc->sc_sim, sc->sc_dev, sc->sc_unit);
+       if (status != CAM_SUCCESS) {
                cam_sim_free(sc->sc_sim, /* free_devq */ TRUE);
                mtx_unlock(&sc->sc_mtx);
+               printf("%s: xpt_bus_register failed with status %#x\n",
+                   __func__, status);
                return (ENOMEM);
        }
        mtx_unlock(&sc->sc_mtx);
@@ -2132,14 +2134,22 @@ umass_cam_attach(struct umass_softc *sc)
 static void
 umass_cam_detach_sim(struct umass_softc *sc)
 {
+       cam_status status;
+
        if (sc->sc_sim != NULL) {
-               if (xpt_bus_deregister(cam_sim_path(sc->sc_sim))) {
+               status = xpt_bus_deregister(cam_sim_path(sc->sc_sim));
+               if (status == CAM_REQ_CMP) {
                        /* accessing the softc is not possible after this */
                        sc->sc_sim->softc = NULL;
+                       DPRINTF(sc, UDMASS_SCSI, "%s: %s:%d:%d caling "
+                           "cam_sim_free sim %p refc %u mtx %p\n",
+                           __func__, sc->sc_name, cam_sim_path(sc->sc_sim),
+                           sc->sc_unit, sc->sc_sim,
+                           sc->sc_sim->refcount, sc->sc_sim->mtx);
                        cam_sim_free(sc->sc_sim, /* free_devq */ TRUE);
                } else {
-                       panic("%s: CAM layer is busy\n",
-                           sc->sc_name);
+                       panic("%s: %s: CAM layer is busy: %#x\n",
+                           __func__, sc->sc_name, status);
                }
                sc->sc_sim = NULL;
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to