aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/cam_xpt.c
diff options
context:
space:
mode:
authorJustin T. Gibbs <gibbs@FreeBSD.org>1999-04-19 21:26:08 +0000
committerJustin T. Gibbs <gibbs@FreeBSD.org>1999-04-19 21:26:08 +0000
commit5a526431f84768cc809e654ae2f3e9b66d0066bd (patch)
tree09452c96d1ae6ed1890faabc9258f2a2599f8480 /sys/cam/cam_xpt.c
parentbd43a21c1406b61d61a12f806b0d2387f6874baf (diff)
downloadsrc-5a526431f84768cc809e654ae2f3e9b66d0066bd.tar.gz
src-5a526431f84768cc809e654ae2f3e9b66d0066bd.zip
cam_periph.c:
Move handling of CAM_AUTOSENSE_FAIL into block dealing with all other scsi status errors. cam_queue.c: cam_queue.h: Fix 'off by one' heap bug in a more efficient manner. Since heap algorithms like to deal with indexes started from 1, offset our heap array pointer at allocation time to make this so for a C environment. This makes the implementation of the algorithm a bit more efficient. cam_xpt.c: Use macros for accessing the head of the heap so that code is isolated from implementation details of the heap.
Notes
Notes: svn path=/head/; revision=45844
Diffstat (limited to 'sys/cam/cam_xpt.c')
-rw-r--r--sys/cam/cam_xpt.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 3f1f97e29fd1..52428e03625e 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cam_xpt.c,v 1.50 1999/04/07 22:57:48 gibbs Exp $
+ * $Id: cam_xpt.c,v 1.51 1999/04/17 08:36:03 peter Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
@@ -755,9 +755,14 @@ xpt_schedule_dev_allocq(struct cam_eb *bus, struct cam_ed *dev)
+ dev->ccbq.dev_active);
dev->flags &= ~CAM_DEV_RESIZE_QUEUE_NEEDED;
}
+ /*
+ * The priority of a device waiting for CCB resources
+ * is that of the the highest priority peripheral driver
+ * enqueued.
+ */
retval = xpt_schedule_dev(&bus->sim->devq->alloc_queue,
&dev->alloc_ccb_entry.pinfo,
- dev->drvq.queue_array[0]->priority);
+ CAMQ_GET_HEAD(&dev->drvq)->priority);
} else {
retval = 0;
}
@@ -771,9 +776,15 @@ xpt_schedule_dev_sendq(struct cam_eb *bus, struct cam_ed *dev)
int retval;
if (dev->ccbq.dev_openings > 0) {
- retval = xpt_schedule_dev(&bus->sim->devq->send_queue,
- &dev->send_ccb_entry.pinfo,
- dev->ccbq.queue.queue_array[0]->priority);
+ /*
+ * The priority of a device waiting for controller
+ * resources is that of the the highest priority CCB
+ * enqueued.
+ */
+ retval =
+ xpt_schedule_dev(&bus->sim->devq->send_queue,
+ &dev->send_ccb_entry.pinfo,
+ CAMQ_GET_HEAD(&dev->ccbq.queue)->priority);
} else {
retval = 0;
}
@@ -2334,7 +2345,7 @@ xptperiphlistmatch(struct ccb_dev_match *cdm)
if ((cdm->pos.position_type & CAM_DEV_POS_PDPTR)
&& (cdm->pos.cookie.pdrv != NULL))
ret = xptpdrvtraverse(
- (struct periph_driver **)cdm->pos.cookie.pdrv,
+ (struct periph_driver **)cdm->pos.cookie.pdrv,
xptplistpdrvfunc, cdm);
else
ret = xptpdrvtraverse(NULL, xptplistpdrvfunc, cdm);
@@ -3382,7 +3393,7 @@ xpt_run_dev_allocq(struct cam_eb *bus)
struct camq *drvq;
qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->alloc_queue,
- /*position*/0);
+ CAMQ_HEAD);
device = qinfo->device;
CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
@@ -3399,14 +3410,7 @@ xpt_run_dev_allocq(struct cam_eb *bus)
if ((work_ccb = xpt_get_ccb(device)) != NULL) {
devq->alloc_openings--;
devq->alloc_active++;
- drv = (struct cam_periph*)camq_remove(drvq,
- /*pos*/0);
- /* Update priority */
- if (drvq->entries > 0) {
- qinfo->pinfo.priority = drvq->queue_array[0]->priority;
- } else {
- qinfo->pinfo.priority = CAM_PRIORITY_NONE;
- }
+ drv = (struct cam_periph*)camq_remove(drvq, CAMQ_HEAD);
splx(s);
xpt_setup_ccb(&work_ccb->ccb_h, drv->path,
drv->pinfo.priority);
@@ -3467,7 +3471,7 @@ xpt_run_dev_sendq(struct cam_eb *bus)
}
qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->send_queue,
- /*position*/0);
+ CAMQ_HEAD);
device = qinfo->device;
/*
@@ -3482,7 +3486,7 @@ xpt_run_dev_sendq(struct cam_eb *bus)
CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
("running device %p\n", device));
- work_ccb = cam_ccbq_peek_ccb(&device->ccbq, 0);
+ work_ccb = cam_ccbq_peek_ccb(&device->ccbq, CAMQ_HEAD);
if (work_ccb == NULL) {
printf("device on run queue with no ccbs???");
splx(ospl);
@@ -3522,13 +3526,8 @@ xpt_run_dev_sendq(struct cam_eb *bus)
devq->send_openings--;
devq->send_active++;
- if (device->ccbq.queue.entries > 0) {
- qinfo->pinfo.priority =
- device->ccbq.queue.queue_array[0]->priority;
+ if (device->ccbq.queue.entries > 0)
xpt_schedule_dev_sendq(bus, device);
- } else {
- qinfo->pinfo.priority = CAM_PRIORITY_NONE;
- }
if (work_ccb && (work_ccb->ccb_h.flags & CAM_DEV_QFREEZE) != 0){
/*