From owner-svn-src-stable-9@FreeBSD.ORG Wed Oct 9 19:25:23 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D3DE09AB; Wed, 9 Oct 2013 19:25:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B20722F2C; Wed, 9 Oct 2013 19:25:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r99JPNGd076057; Wed, 9 Oct 2013 19:25:23 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r99JPM5e076034; Wed, 9 Oct 2013 19:25:22 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201310091925.r99JPM5e076034@svn.freebsd.org> From: Alexander Motin Date: Wed, 9 Oct 2013 19:25:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r256225 - stable/9/sys/cam X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2013 19:25:24 -0000 Author: mav Date: Wed Oct 9 19:25:22 2013 New Revision: 256225 URL: http://svnweb.freebsd.org/changeset/base/256225 Log: MFC r255126: Add debug trace points for freeze/release device queue. Modified: stable/9/sys/cam/cam_debug.h stable/9/sys/cam/cam_periph.c stable/9/sys/cam/cam_xpt.c stable/9/sys/cam/cam_xpt.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_debug.h ============================================================================== --- stable/9/sys/cam/cam_debug.h Wed Oct 9 19:23:12 2013 (r256224) +++ stable/9/sys/cam/cam_debug.h Wed Oct 9 19:25:22 2013 (r256225) @@ -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: stable/9/sys/cam/cam_periph.c ============================================================================== --- stable/9/sys/cam/cam_periph.c Wed Oct 9 19:23:12 2013 (r256224) +++ stable/9/sys/cam/cam_periph.c Wed Oct 9 19:25:22 2013 (r256225) @@ -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: stable/9/sys/cam/cam_xpt.c ============================================================================== --- stable/9/sys/cam/cam_xpt.c Wed Oct 9 19:23:12 2013 (r256224) +++ stable/9/sys/cam/cam_xpt.c Wed Oct 9 19:25:22 2013 (r256225) @@ -3594,6 +3594,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) { @@ -3627,6 +3661,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; @@ -4147,6 +4196,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)) { @@ -4171,6 +4222,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); } @@ -4179,6 +4231,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); } @@ -4186,6 +4240,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: stable/9/sys/cam/cam_xpt.h ============================================================================== --- stable/9/sys/cam/cam_xpt.h Wed Oct 9 19:23:12 2013 (r256224) +++ stable/9/sys/cam/cam_xpt.h Wed Oct 9 19:25:22 2013 (r256225) @@ -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);