From owner-svn-src-projects@FreeBSD.ORG Mon Sep 2 16:20:11 2013 Return-Path: Delivered-To: svn-src-projects@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 B134DFE5; Mon, 2 Sep 2013 16:20:11 +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 8E81F2F20; Mon, 2 Sep 2013 16:20:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r82GKB4I069307; Mon, 2 Sep 2013 16:20:11 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r82GKBAj069306; Mon, 2 Sep 2013 16:20:11 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201309021620.r82GKBAj069306@svn.freebsd.org> From: Alexander Motin Date: Mon, 2 Sep 2013 16:20:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r255150 - projects/camlock/sys/cam X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Sep 2013 16:20:11 -0000 Author: mav Date: Mon Sep 2 16:20:10 2013 New Revision: 255150 URL: http://svnweb.freebsd.org/changeset/base/255150 Log: - Add missing locking around cam_ccbq_resize() call. - Reshuffle xpt_done_process() to reduce device lock scope. Modified: projects/camlock/sys/cam/cam_xpt.c Modified: projects/camlock/sys/cam/cam_xpt.c ============================================================================== --- projects/camlock/sys/cam/cam_xpt.c Mon Sep 2 15:52:48 2013 (r255149) +++ projects/camlock/sys/cam/cam_xpt.c Mon Sep 2 16:20:10 2013 (r255150) @@ -4809,7 +4809,9 @@ xpt_dev_ccbq_resize(struct cam_path *pat struct cam_ed *dev; dev = path->device; + mtx_lock(&dev->sim->devq->send_mtx); result = cam_ccbq_resize(&dev->ccbq, newopenings); + mtx_unlock(&dev->sim->devq->send_mtx); if ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0 || (dev->inq_flags & SID_CmdQue) != 0) dev->tag_saved_openings = newopenings; @@ -5158,7 +5160,8 @@ static void xpt_done_process(struct ccb_hdr *ccb_h) { struct cam_sim *sim; - struct mtx *mtx; + struct cam_devq *devq; + struct mtx *mtx = NULL; if (ccb_h->flags & CAM_HIGH_POWER) { struct highpowerlist *hphead; @@ -5191,15 +5194,26 @@ xpt_done_process(struct ccb_hdr *ccb_h) } sim = ccb_h->path->bus->sim; - mtx = xpt_path_mtx(ccb_h->path); - mtx_lock(mtx); + if (ccb_h->status & CAM_RELEASE_SIMQ) { + xpt_release_simq(sim, /*run_queue*/FALSE); + ccb_h->status &= ~CAM_RELEASE_SIMQ; + } + + if ((ccb_h->flags & CAM_DEV_QFRZDIS) + && (ccb_h->status & CAM_DEV_QFRZN)) { + xpt_release_devq(ccb_h->path, /*count*/1, + /*run_queue*/FALSE); + ccb_h->status &= ~CAM_DEV_QFRZN; + } + + devq = sim->devq; if ((ccb_h->func_code & XPT_FC_USER_CCB) == 0) { struct cam_ed *dev; - mtx_lock(&sim->devq->send_mtx); - sim->devq->send_active--; - sim->devq->send_openings++; + mtx_lock(&devq->send_mtx); + devq->send_active--; + devq->send_openings++; dev = ccb_h->path->device; cam_ccbq_ccb_done(&dev->ccbq, (union ccb *)ccb_h); @@ -5219,29 +5233,23 @@ xpt_done_process(struct ccb_hdr *ccb_h) } if (!device_is_queued(dev)) - (void)xpt_schedule_devq(sim->devq, dev); - mtx_unlock(&sim->devq->send_mtx); + (void)xpt_schedule_devq(devq, dev); + mtx_unlock(&devq->send_mtx); + + mtx = xpt_path_mtx(ccb_h->path); + mtx_lock(mtx); if ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0 && (--dev->tag_delay_count == 0)) xpt_start_tags(ccb_h->path); - } - if (ccb_h->status & CAM_RELEASE_SIMQ) { - xpt_release_simq(sim, /*run_queue*/FALSE); - ccb_h->status &= ~CAM_RELEASE_SIMQ; - } - - if ((ccb_h->flags & CAM_DEV_QFRZDIS) - && (ccb_h->status & CAM_DEV_QFRZN)) { - xpt_release_devq(ccb_h->path, /*count*/1, - /*run_queue*/FALSE); - ccb_h->status &= ~CAM_DEV_QFRZN; - } - - if (ccb_h->flags & CAM_UNLOCKED) { - mtx_unlock(mtx); - mtx = NULL; + if ((ccb_h->flags & CAM_UNLOCKED) != 0) { + mtx_unlock(mtx); + mtx = NULL; + } + } else if ((ccb_h->flags & CAM_UNLOCKED) == 0) { + mtx = xpt_path_mtx(ccb_h->path); + mtx_lock(mtx); } /* Call the peripheral driver's callback */ @@ -5249,9 +5257,9 @@ xpt_done_process(struct ccb_hdr *ccb_h) if (mtx != NULL) mtx_unlock(mtx); - mtx_lock(&sim->devq->send_mtx); - xpt_run_devq(sim->devq); - mtx_unlock(&sim->devq->send_mtx); + mtx_lock(&devq->send_mtx); + xpt_run_devq(devq); + mtx_unlock(&devq->send_mtx); } void