From owner-svn-src-projects@FreeBSD.ORG Mon Sep 2 22:45:50 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 50176777; Mon, 2 Sep 2013 22:45:50 +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 2E9162DCD; Mon, 2 Sep 2013 22:45:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r82Mjo94003652; Mon, 2 Sep 2013 22:45:50 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r82Mjnda003650; Mon, 2 Sep 2013 22:45:49 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201309022245.r82Mjnda003650@svn.freebsd.org> From: Alexander Motin Date: Mon, 2 Sep 2013 22:45:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r255159 - 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 22:45:50 -0000 Author: mav Date: Mon Sep 2 22:45:49 2013 New Revision: 255159 URL: http://svnweb.freebsd.org/changeset/base/255159 Log: - Since we no longer have allocation queue, make send queue include devices without additional indirection. - Avoid grabbing device lock inside xpt_done_process() when possible. Modified: projects/camlock/sys/cam/cam_xpt.c projects/camlock/sys/cam/cam_xpt_internal.h Modified: projects/camlock/sys/cam/cam_xpt.c ============================================================================== --- projects/camlock/sys/cam/cam_xpt.c Mon Sep 2 22:22:56 2013 (r255158) +++ projects/camlock/sys/cam/cam_xpt.c Mon Sep 2 22:45:49 2013 (r255159) @@ -327,7 +327,7 @@ xpt_schedule_devq(struct cam_devq *devq, */ retval = xpt_schedule_dev(&devq->send_queue, - &dev->devq_entry.pinfo, + &dev->devq_entry, CAMQ_GET_PRIO(&dev->ccbq.queue)); } else { retval = 0; @@ -338,7 +338,7 @@ xpt_schedule_devq(struct cam_devq *devq, static __inline int device_is_queued(struct cam_ed *device) { - return (device->devq_entry.pinfo.index != CAM_UNQUEUED_INDEX); + return (device->devq_entry.index != CAM_UNQUEUED_INDEX); } static void @@ -3183,14 +3183,12 @@ xpt_run_devq(struct cam_devq *devq) while ((devq->send_queue.entries > 0) && (devq->send_openings > 0) && (devq->send_queue.qfrozen_cnt <= 1)) { - struct cam_ed_qinfo *qinfo; struct cam_ed *device; union ccb *work_ccb; struct cam_sim *sim; - qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->send_queue, + device = (struct cam_ed *)camq_remove(&devq->send_queue, CAMQ_HEAD); - device = qinfo->device; CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("running device %p\n", device)); @@ -4279,7 +4277,7 @@ xpt_freeze_devq(struct cam_path *path, u freeze = (dev->ccbq.queue.qfrozen_cnt += count); /* Remove frozen device from sendq. */ if (device_is_queued(dev)) - camq_remove(&devq->send_queue, dev->devq_entry.pinfo.index); + camq_remove(&devq->send_queue, dev->devq_entry.index); mtx_unlock(&devq->send_mtx); return (freeze); } @@ -4709,8 +4707,7 @@ xpt_alloc_device(struct cam_eb *bus, str if (device == NULL) return (NULL); - cam_init_pinfo(&device->devq_entry.pinfo); - device->devq_entry.device = device; + cam_init_pinfo(&device->devq_entry); device->target = target; device->lun_id = lun_id; device->sim = bus->sim; @@ -4780,7 +4777,7 @@ xpt_release_device(struct cam_ed *device KASSERT(SLIST_EMPTY(&device->periphs), ("destroying device, but periphs list is not empty")); - KASSERT(device->devq_entry.pinfo.index == CAM_UNQUEUED_INDEX, + KASSERT(device->devq_entry.index == CAM_UNQUEUED_INDEX, ("destroying device while still queued for ccbs")); if ((device->flags & CAM_DEV_REL_TIMEOUT_PENDING) != 0) @@ -5209,13 +5206,11 @@ xpt_done_process(struct ccb_hdr *ccb_h) devq = sim->devq; if ((ccb_h->func_code & XPT_FC_USER_CCB) == 0) { - struct cam_ed *dev; + struct cam_ed *dev = ccb_h->path->device; 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); if (((dev->flags & CAM_DEV_REL_ON_QUEUE_EMPTY) != 0 @@ -5236,20 +5231,26 @@ xpt_done_process(struct ccb_hdr *ccb_h) (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) { + 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 ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0 + && (--dev->tag_delay_count == 0)) + xpt_start_tags(ccb_h->path); + } + } - if ((ccb_h->flags & CAM_UNLOCKED) != 0) { + if ((ccb_h->flags & CAM_UNLOCKED) == 0) { + if (mtx == NULL) { + mtx = xpt_path_mtx(ccb_h->path); + mtx_lock(mtx); + } + } else { + if (mtx != NULL) { 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 */ Modified: projects/camlock/sys/cam/cam_xpt_internal.h ============================================================================== --- projects/camlock/sys/cam/cam_xpt_internal.h Mon Sep 2 22:22:56 2013 (r255158) +++ projects/camlock/sys/cam/cam_xpt_internal.h Mon Sep 2 22:45:49 2013 (r255159) @@ -57,23 +57,13 @@ struct xpt_xport { }; /* - * Structure for queueing a device in a run queue. - * There is one run queue for allocating new ccbs, - * and another for sending ccbs to the controller. - */ -struct cam_ed_qinfo { - cam_pinfo pinfo; - struct cam_ed *device; -}; - -/* * The CAM EDT (Existing Device Table) contains the device information for * all devices for all busses in the system. The table contains a * cam_ed structure for each device on the bus. */ struct cam_ed { + cam_pinfo devq_entry; TAILQ_ENTRY(cam_ed) links; - struct cam_ed_qinfo devq_entry; struct cam_et *target; struct cam_sim *sim; lun_id_t lun_id;