Author: mav
Date: Sun Sep  1 17:37:19 2013
New Revision: 255126
URL: http://svnweb.freebsd.org/changeset/base/255126

Log:
  Add debug trace points for freeze/release device queue.

Modified:
  head/sys/cam/cam_debug.h
  head/sys/cam/cam_periph.c
  head/sys/cam/cam_xpt.c
  head/sys/cam/cam_xpt.h

Modified: head/sys/cam/cam_debug.h
==============================================================================
--- head/sys/cam/cam_debug.h    Sun Sep  1 17:06:14 2013        (r255125)
+++ head/sys/cam/cam_debug.h    Sun Sep  1 17:37:19 2013        (r255126)
@@ -99,6 +99,17 @@ extern u_int32_t cam_debug_delay;
                        DELAY(cam_debug_delay);         \
        }
 
+#define        CAM_DEBUG_DEV(dev, flag, printfargs)            \
+       if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags) \
+        && (cam_dpath != NULL)                         \
+        && (xpt_path_comp_dev(cam_dpath, dev) >= 0)    \
+        && (xpt_path_comp_dev(cam_dpath, dev) < 2)) {  \
+               xpt_print_device(dev);                  \
+               printf printfargs;                      \
+               if (cam_debug_delay != 0)               \
+                       DELAY(cam_debug_delay);         \
+       }
+
 #define        CAM_DEBUG_PRINT(flag, printfargs)               \
        if (((flag) & (CAM_DEBUG_COMPILE) & cam_dflags)) {      \
                printf("cam_debug: ");                  \

Modified: head/sys/cam/cam_periph.c
==============================================================================
--- head/sys/cam/cam_periph.c   Sun Sep  1 17:06:14 2013        (r255125)
+++ head/sys/cam/cam_periph.c   Sun Sep  1 17:37:19 2013        (r255126)
@@ -1115,6 +1115,7 @@ cam_freeze_devq(struct cam_path *path)
 {
        struct ccb_hdr ccb_h;
 
+       CAM_DEBUG(path, CAM_DEBUG_TRACE, ("cam_freeze_devq\n"));
        xpt_setup_ccb(&ccb_h, path, /*priority*/1);
        ccb_h.func_code = XPT_NOOP;
        ccb_h.flags = CAM_DEV_QFREEZE;
@@ -1128,6 +1129,8 @@ cam_release_devq(struct cam_path *path, 
 {
        struct ccb_relsim crs;
 
+       CAM_DEBUG(path, CAM_DEBUG_TRACE, ("cam_release_devq(%u, %u, %u, %d)\n",
+           relsim_flags, openings, arg, getcount_only));
        xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL);
        crs.ccb_h.func_code = XPT_REL_SIMQ;
        crs.ccb_h.flags = getcount_only ? CAM_DEV_QFREEZE : 0;

Modified: head/sys/cam/cam_xpt.c
==============================================================================
--- head/sys/cam/cam_xpt.c      Sun Sep  1 17:06:14 2013        (r255125)
+++ head/sys/cam/cam_xpt.c      Sun Sep  1 17:37:19 2013        (r255126)
@@ -3561,6 +3561,40 @@ xpt_path_comp(struct cam_path *path1, st
        return (retval);
 }
 
+int
+xpt_path_comp_dev(struct cam_path *path, struct cam_ed *dev)
+{
+       int retval = 0;
+
+       if (path->bus != dev->target->bus) {
+               if (path->bus->path_id == CAM_BUS_WILDCARD)
+                       retval = 1;
+               else if (dev->target->bus->path_id == CAM_BUS_WILDCARD)
+                       retval = 2;
+               else
+                       return (-1);
+       }
+       if (path->target != dev->target) {
+               if (path->target->target_id == CAM_TARGET_WILDCARD) {
+                       if (retval == 0)
+                               retval = 1;
+               } else if (dev->target->target_id == CAM_TARGET_WILDCARD)
+                       retval = 2;
+               else
+                       return (-1);
+       }
+       if (path->device != dev) {
+               if (path->device->lun_id == CAM_LUN_WILDCARD) {
+                       if (retval == 0)
+                               retval = 1;
+               } else if (dev->lun_id == CAM_LUN_WILDCARD)
+                       retval = 2;
+               else
+                       return (-1);
+       }
+       return (retval);
+}
+
 void
 xpt_print_path(struct cam_path *path)
 {
@@ -3594,6 +3628,21 @@ xpt_print_path(struct cam_path *path)
 }
 
 void
+xpt_print_device(struct cam_ed *device)
+{
+
+       if (device == NULL)
+               printf("(nopath): ");
+       else {
+               printf("(noperiph:%s%d:%d:%d:%d): ", device->sim->sim_name,
+                      device->sim->unit_number,
+                      device->sim->bus_id,
+                      device->target->target_id,
+                      device->lun_id);
+       }
+}
+
+void
 xpt_print(struct cam_path *path, const char *fmt, ...)
 {
        va_list ap;
@@ -4114,6 +4163,8 @@ xpt_freeze_devq(struct cam_path *path, u
        struct cam_ed *dev = path->device;
 
        mtx_assert(path->bus->sim->mtx, MA_OWNED);
+       CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_freeze_devq() %u->%u\n",
+           dev->ccbq.queue.qfrozen_cnt, dev->ccbq.queue.qfrozen_cnt + count));
        dev->ccbq.queue.qfrozen_cnt += count;
        /* Remove frozen device from sendq. */
        if (device_is_queued(dev)) {
@@ -4138,6 +4189,7 @@ xpt_release_devq_timeout(void *arg)
        struct cam_ed *device;
 
        device = (struct cam_ed *)arg;
+       CAM_DEBUG_DEV(device, CAM_DEBUG_TRACE, ("xpt_release_devq_timeout\n"));
        xpt_release_devq_device(device, /*count*/1, /*run_queue*/TRUE);
 }
 
@@ -4146,6 +4198,8 @@ xpt_release_devq(struct cam_path *path, 
 {
 
        mtx_assert(path->bus->sim->mtx, MA_OWNED);
+       CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_release_devq(%d, %d)\n",
+           count, run_queue));
        xpt_release_devq_device(path->device, count, run_queue);
 }
 
@@ -4153,6 +4207,9 @@ void
 xpt_release_devq_device(struct cam_ed *dev, u_int count, int run_queue)
 {
 
+       CAM_DEBUG_DEV(dev, CAM_DEBUG_TRACE,
+           ("xpt_release_devq_device(%d, %d) %u->%u\n", count, run_queue,
+           dev->ccbq.queue.qfrozen_cnt, dev->ccbq.queue.qfrozen_cnt - count));
        if (count > dev->ccbq.queue.qfrozen_cnt) {
 #ifdef INVARIANTS
                printf("xpt_release_devq(): requested %u > present %u\n",

Modified: head/sys/cam/cam_xpt.h
==============================================================================
--- head/sys/cam/cam_xpt.h      Sun Sep  1 17:06:14 2013        (r255125)
+++ head/sys/cam/cam_xpt.h      Sun Sep  1 17:37:19 2013        (r255126)
@@ -35,6 +35,7 @@
 /* Forward Declarations */
 union ccb;
 struct cam_periph;
+struct cam_ed;
 struct cam_sim;
 
 /*
@@ -89,7 +90,10 @@ void                 xpt_path_counts(struct cam_path *
                                        uint32_t *device_ref);
 int                    xpt_path_comp(struct cam_path *path1,
                                      struct cam_path *path2);
+int                    xpt_path_comp_dev(struct cam_path *path,
+                                         struct cam_ed *dev);
 void                   xpt_print_path(struct cam_path *path);
+void                   xpt_print_device(struct cam_ed *device);
 void                   xpt_print(struct cam_path *path, const char *fmt, ...);
 int                    xpt_path_string(struct cam_path *path, char *str,
                                        size_t str_len);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to