Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jan 2010 21:19:10 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 173593 for review
Message-ID:  <201001232119.o0NLJAoR024722@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=173593

Change 173593 by mav@mav_mavtest on 2010/01/23 21:18:38

	More fixes to freeze/scheduling code.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#144 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#144 (text+ko) ====

@@ -3202,8 +3202,9 @@
 			CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 					("changed priority to %d\n",
 					 new_priority));
-		}
-		retval = 0;
+			retval = 1;
+		} else
+			retval = 0;
 	} else {
 		/* New entry on the queue */
 		if (new_priority < old_priority)
@@ -3247,15 +3248,6 @@
 		qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->alloc_queue,
 							   CAMQ_HEAD);
 		device = qinfo->device;
-
-		/*
-		 * If the device has been "frozen", don't attempt
-		 * to run it.
-		 */
-		if (cam_ccbq_frozen(&device->ccbq,
-		    CAM_PRIORITY_TO_RL(qinfo->pinfo.priority)) > 0)
-			continue;
-
 		CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 				("running device %p\n", device));
 
@@ -3316,14 +3308,6 @@
 		qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->send_queue,
 							   CAMQ_HEAD);
 		device = qinfo->device;
-
-		/*
-		 * If the device has been "frozen", don't attempt
-		 * to run it.
-		 */
-		if (cam_ccbq_frozen_top(&device->ccbq) > 0)
-			continue;
-
 		CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
 				("running device %p\n", device));
 
@@ -4134,11 +4118,25 @@
 u_int32_t
 xpt_freeze_devq_rl(struct cam_path *path, cam_rl rl, u_int count)
 {
+	struct cam_ed *dev = path->device;
 
 	mtx_assert(path->bus->sim->mtx, MA_OWNED);
-	path->device->sim->devq->alloc_openings +=
-	    cam_ccbq_freeze(&path->device->ccbq, rl, count);
-	return (path->device->ccbq.queue.qfrozen_cnt[rl]);
+	dev->sim->devq->alloc_openings +=
+	    cam_ccbq_freeze(&dev->ccbq, rl, count);
+	/* Remove frozen device from allocq. */
+	if (device_is_alloc_queued(dev) &&
+	    cam_ccbq_frozen(&dev->ccbq, CAM_PRIORITY_TO_RL(
+	     CAMQ_GET_PRIO(&dev->drvq)))) {
+		camq_remove(&dev->sim->devq->alloc_queue,
+		    dev->alloc_ccb_entry.pinfo.index);
+	}
+	/* Remove frozen device from sendq. */
+	if (device_is_send_queued(dev) &&
+	    cam_ccbq_frozen_top(&dev->ccbq)) {
+		camq_remove(&dev->sim->devq->send_queue,
+		    dev->send_ccb_entry.pinfo.index);
+	}
+	return (dev->ccbq.queue.qfrozen_cnt[rl]);
 }
 
 u_int32_t
@@ -4196,8 +4194,8 @@
 	    cam_ccbq_release(&dev->ccbq, rl, count);
 	if (cam_ccbq_frozen(&dev->ccbq, CAM_PRIORITY_TO_RL(
 	    CAMQ_GET_PRIO(&dev->drvq))) == 0) {
-		xpt_schedule_dev_allocq(dev->target->bus, dev);
-		xpt_run_dev_allocq(dev->target->bus);
+		if (xpt_schedule_dev_allocq(dev->target->bus, dev))
+			xpt_run_dev_allocq(dev->target->bus);
 	}
 	if (cam_ccbq_frozen_top(&dev->ccbq) == 0) {
 		/*
@@ -4960,21 +4958,19 @@
 			cam_ccbq_ccb_done(&dev->ccbq, (union ccb *)ccb_h);
 			ccb_h->path->bus->sim->devq->send_active--;
 			ccb_h->path->bus->sim->devq->send_openings++;
+			runq = TRUE;
 
 			if (((dev->flags & CAM_DEV_REL_ON_COMPLETE) != 0
 			  && (ccb_h->status&CAM_STATUS_MASK) != CAM_REQUEUE_REQ)
 			 || ((dev->flags & CAM_DEV_REL_ON_QUEUE_EMPTY) != 0
 			  && (dev->ccbq.dev_active == 0))) {
-
 				xpt_release_devq(ccb_h->path, /*count*/1,
-						 /*run_queue*/TRUE);
+						 /*run_queue*/FALSE);
 			}
 
 			if ((dev->flags & CAM_DEV_TAG_AFTER_COUNT) != 0
 			 && (--dev->tag_delay_count == 0))
 				xpt_start_tags(ccb_h->path);
-
-			runq = xpt_schedule_dev_sendq(ccb_h->path->bus, dev);
 		}
 
 		if (ccb_h->status & CAM_RELEASE_SIMQ) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001232119.o0NLJAoR024722>