svn commit: r248890 - in projects/camlock/sys/cam: . ctl
Alexander Motin
mav at FreeBSD.org
Fri Mar 29 14:48:45 UTC 2013
Author: mav
Date: Fri Mar 29 14:48:43 2013
New Revision: 248890
URL: http://svnweb.freebsd.org/changeset/base/248890
Log:
Remove request allocation queue on the SIM level. Now device can allocate
CCBs on itself, not looking on SIM queue state.
Modified:
projects/camlock/sys/cam/cam_queue.c
projects/camlock/sys/cam/cam_queue.h
projects/camlock/sys/cam/cam_xpt.c
projects/camlock/sys/cam/ctl/scsi_ctl.c
Modified: projects/camlock/sys/cam/cam_queue.c
==============================================================================
--- projects/camlock/sys/cam/cam_queue.c Fri Mar 29 14:18:56 2013 (r248889)
+++ projects/camlock/sys/cam/cam_queue.c Fri Mar 29 14:48:43 2013 (r248890)
@@ -230,15 +230,8 @@ int
cam_devq_init(struct cam_devq *devq, int devices, int openings)
{
bzero(devq, sizeof(*devq));
- if (camq_init(&devq->alloc_queue, devices) != 0) {
+ if (camq_init(&devq->send_queue, devices) != 0)
return (1);
- }
- if (camq_init(&devq->send_queue, devices) != 0) {
- camq_fini(&devq->alloc_queue);
- return (1);
- }
- devq->alloc_openings = openings;
- devq->alloc_active = 0;
devq->send_openings = openings;
devq->send_active = 0;
return (0);
@@ -247,7 +240,6 @@ cam_devq_init(struct cam_devq *devq, int
void
cam_devq_free(struct cam_devq *devq)
{
- camq_fini(&devq->alloc_queue);
camq_fini(&devq->send_queue);
free(devq, M_CAMDEVQ);
}
@@ -257,11 +249,7 @@ cam_devq_resize(struct cam_devq *camq, i
{
u_int32_t retval;
- retval = camq_resize(&camq->alloc_queue, devices);
-
- if (retval == CAM_REQ_CMP)
- retval = camq_resize(&camq->send_queue, devices);
-
+ retval = camq_resize(&camq->send_queue, devices);
return (retval);
}
@@ -328,11 +316,10 @@ int
cam_ccbq_init(struct cam_ccbq *ccbq, int openings)
{
bzero(ccbq, sizeof(*ccbq));
- if (camq_init(&ccbq->queue, openings + (CAM_RL_VALUES - 1)) != 0) {
+ if (camq_init(&ccbq->queue, openings + (CAM_RL_VALUES - 1)) != 0)
return (1);
- }
ccbq->devq_openings = openings;
- ccbq->dev_openings = openings;
+ ccbq->dev_openings = openings;
return (0);
}
Modified: projects/camlock/sys/cam/cam_queue.h
==============================================================================
--- projects/camlock/sys/cam/cam_queue.h Fri Mar 29 14:18:56 2013 (r248889)
+++ projects/camlock/sys/cam/cam_queue.h Fri Mar 29 14:48:43 2013 (r248890)
@@ -58,7 +58,8 @@ SLIST_HEAD(ccb_hdr_slist, ccb_hdr);
struct cam_ccbq {
struct camq queue;
int devq_openings;
- int dev_openings;
+ int devq_allocating;
+ int dev_openings;
int dev_active;
int held;
};
@@ -66,11 +67,7 @@ struct cam_ccbq {
struct cam_ed;
struct cam_devq {
- struct camq alloc_queue;
struct camq send_queue;
- struct cam_ed *active_dev;
- int alloc_openings;
- int alloc_active;
int send_openings;
int send_active;
};
Modified: projects/camlock/sys/cam/cam_xpt.c
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.c Fri Mar 29 14:18:56 2013 (r248889)
+++ projects/camlock/sys/cam/cam_xpt.c Fri Mar 29 14:48:43 2013 (r248890)
@@ -223,7 +223,7 @@ static void xpt_async_bcast(struct asyn
static path_id_t xptnextfreepathid(void);
static path_id_t xptpathid(const char *sim_name, int sim_unit, int sim_bus);
static union ccb *xpt_get_ccb(struct cam_ed *device);
-static void xpt_run_dev_allocq(struct cam_eb *bus);
+static void xpt_run_dev_allocq(struct cam_ed *device);
static void xpt_run_dev_sendq(struct cam_eb *bus);
static timeout_t xpt_release_devq_timeout;
static void xpt_release_simq_timeout(void *arg) __unused;
@@ -300,30 +300,6 @@ static __inline int device_is_alloc_queu
static __inline int device_is_send_queued(struct cam_ed *device);
static __inline int
-xpt_schedule_dev_allocq(struct cam_eb *bus, struct cam_ed *dev)
-{
- int retval;
-
- if ((dev->drvq.entries > 0) &&
- (dev->ccbq.devq_openings > 0) &&
- (cam_ccbq_frozen(&dev->ccbq, CAM_PRIORITY_TO_RL(
- CAMQ_GET_PRIO(&dev->drvq))) == 0)) {
- /*
- * The priority of a device waiting for CCB resources
- * is that of the highest priority peripheral driver
- * enqueued.
- */
- retval = xpt_schedule_dev(&bus->sim->devq->alloc_queue,
- &dev->alloc_ccb_entry.pinfo,
- CAMQ_GET_PRIO(&dev->drvq));
- } else {
- retval = 0;
- }
-
- return (retval);
-}
-
-static __inline int
xpt_schedule_dev_sendq(struct cam_eb *bus, struct cam_ed *dev)
{
int retval;
@@ -2527,9 +2503,8 @@ xpt_action_default(union ccb *start_ccb)
int frozen;
frozen = cam_ccbq_insert_ccb(&path->device->ccbq, start_ccb);
- path->device->sim->devq->alloc_openings += frozen;
if (frozen > 0)
- xpt_run_dev_allocq(path->bus);
+ xpt_run_dev_allocq(path->device);
if (xpt_schedule_dev_sendq(path->bus, path->device))
xpt_run_dev_sendq(path->bus);
break;
@@ -2582,8 +2557,7 @@ xpt_action_default(union ccb *start_ccb)
device = abort_ccb->ccb_h.path->device;
ccbq = &device->ccbq;
- device->sim->devq->alloc_openings -=
- cam_ccbq_remove_ccb(ccbq, abort_ccb);
+ cam_ccbq_remove_ccb(ccbq, abort_ccb);
abort_ccb->ccb_h.status =
CAM_REQ_ABORTED|CAM_DEV_QFRZN;
xpt_freeze_devq(abort_ccb->ccb_h.path, 1);
@@ -3128,7 +3102,7 @@ xpt_schedule(struct cam_periph *perph, u
camq_change_priority(&device->drvq,
perph->pinfo.index,
new_priority);
- runq = xpt_schedule_dev_allocq(perph->path->bus, device);
+ runq = 1;
}
} else {
/* New entry on the queue */
@@ -3137,12 +3111,12 @@ xpt_schedule(struct cam_periph *perph, u
perph->pinfo.priority = new_priority;
perph->pinfo.generation = ++device->drvq.generation;
camq_insert(&device->drvq, &perph->pinfo);
- runq = xpt_schedule_dev_allocq(perph->path->bus, device);
+ runq = 1;
}
if (runq != 0) {
CAM_DEBUG(perph->path, CAM_DEBUG_SUBTRACE,
- (" calling xpt_run_devq\n"));
- xpt_run_dev_allocq(perph->path->bus);
+ (" calling xpt_run_dev_allocq\n"));
+ xpt_run_dev_allocq(device);
}
}
@@ -3195,43 +3169,25 @@ xpt_schedule_dev(struct camq *queue, cam
}
static void
-xpt_run_dev_allocq(struct cam_eb *bus)
+xpt_run_dev_allocq(struct cam_ed *device)
{
- struct cam_devq *devq;
+ struct camq *drvq;
- CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_dev_allocq\n"));
- devq = bus->sim->devq;
-
- CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
- (" qfrozen_cnt == 0x%x, entries == %d, "
- "openings == %d, active == %d\n",
- devq->alloc_queue.qfrozen_cnt[0],
- devq->alloc_queue.entries,
- devq->alloc_openings,
- devq->alloc_active));
-
- devq->alloc_queue.qfrozen_cnt[0]++;
- while ((devq->alloc_queue.entries > 0)
- && (devq->alloc_openings > 0)
- && (devq->alloc_queue.qfrozen_cnt[0] <= 1)) {
- struct cam_ed_qinfo *qinfo;
- struct cam_ed *device;
+ if (device->ccbq.devq_allocating)
+ return;
+ device->ccbq.devq_allocating = 1;
+ CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_run_dev_allocq(%p)\n", device));
+ drvq = &device->drvq;
+ while ((drvq->entries > 0) &&
+ (device->ccbq.devq_openings > 0) &&
+ (cam_ccbq_frozen(&device->ccbq, CAM_PRIORITY_TO_RL(
+ CAMQ_GET_PRIO(drvq))) == 0)) {
union ccb *work_ccb;
struct cam_periph *drv;
- struct camq *drvq;
- qinfo = (struct cam_ed_qinfo *)camq_remove(&devq->alloc_queue,
- CAMQ_HEAD);
- device = qinfo->device;
- CAM_DEBUG_PRINT(CAM_DEBUG_XPT,
- ("running device %p\n", device));
-
- drvq = &device->drvq;
KASSERT(drvq->entries > 0, ("xpt_run_dev_allocq: "
"Device on queue without any work to do"));
if ((work_ccb = xpt_get_ccb(device)) != NULL) {
- devq->alloc_openings--;
- devq->alloc_active++;
drv = (struct cam_periph*)camq_remove(drvq, CAMQ_HEAD);
xpt_setup_ccb(&work_ccb->ccb_h, drv->path,
drv->pinfo.priority);
@@ -3250,11 +3206,8 @@ xpt_run_dev_allocq(struct cam_eb *bus)
*/
break;
}
-
- /* We may have more work. Attempt to reschedule. */
- xpt_schedule_dev_allocq(bus, device);
}
- devq->alloc_queue.qfrozen_cnt[0]--;
+ device->ccbq.devq_allocating = 0;
}
static void
@@ -3814,14 +3767,7 @@ xpt_release_ccb(union ccb *free_ccb)
SLIST_INSERT_HEAD(&sim->ccb_freeq, &free_ccb->ccb_h,
xpt_links.sle);
}
- if (sim->devq == NULL) {
- return;
- }
- sim->devq->alloc_openings++;
- sim->devq->alloc_active--;
- if (device_is_alloc_queued(device) == 0)
- xpt_schedule_dev_allocq(bus, device);
- xpt_run_dev_allocq(bus);
+ xpt_run_dev_allocq(device);
}
/* Functions accessed by SIM drivers */
@@ -4173,15 +4119,7 @@ xpt_freeze_devq_rl(struct cam_path *path
struct cam_ed *dev = path->device;
mtx_assert(path->bus->sim->mtx, MA_OWNED);
- 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);
- }
+ cam_ccbq_freeze(&dev->ccbq, rl, count);
/* Remove frozen device from sendq. */
if (device_is_send_queued(dev) &&
cam_ccbq_frozen_top(&dev->ccbq)) {
@@ -4244,13 +4182,10 @@ xpt_release_devq_device(struct cam_ed *d
#endif
count = dev->ccbq.queue.qfrozen_cnt[rl];
}
- dev->sim->devq->alloc_openings -=
- cam_ccbq_release(&dev->ccbq, rl, count);
+ cam_ccbq_release(&dev->ccbq, rl, count);
if (cam_ccbq_frozen(&dev->ccbq, CAM_PRIORITY_TO_RL(
- CAMQ_GET_PRIO(&dev->drvq))) == 0) {
- if (xpt_schedule_dev_allocq(dev->target->bus, dev))
- xpt_run_dev_allocq(dev->target->bus);
- }
+ CAMQ_GET_PRIO(&dev->drvq))) == 0)
+ xpt_run_dev_allocq(dev);
if (cam_ccbq_frozen_top(&dev->ccbq) == 0) {
/*
* No longer need to wait for a successful
@@ -4541,7 +4476,7 @@ xpt_alloc_device(struct cam_eb *bus, str
/* Make space for us in the device queue on our bus */
devq = bus->sim->devq;
- status = cam_devq_resize(devq, devq->alloc_queue.array_size + 1);
+ status = cam_devq_resize(devq, devq->send_queue.array_size + 1);
if (status != CAM_REQ_CMP) {
device = NULL;
@@ -4615,7 +4550,7 @@ xpt_release_device(struct cam_ed *device
device->target->bus->sim->max_ccbs -= device->ccbq.devq_openings;
/* Release our slot in the devq */
devq = device->target->bus->sim->devq;
- cam_devq_resize(devq, devq->alloc_queue.array_size - 1);
+ cam_devq_resize(devq, devq->send_queue.array_size - 1);
camq_fini(&device->drvq);
cam_ccbq_fini(&device->ccbq);
/*
Modified: projects/camlock/sys/cam/ctl/scsi_ctl.c
==============================================================================
--- projects/camlock/sys/cam/ctl/scsi_ctl.c Fri Mar 29 14:18:56 2013 (r248889)
+++ projects/camlock/sys/cam/ctl/scsi_ctl.c Fri Mar 29 14:48:43 2013 (r248890)
@@ -2059,7 +2059,6 @@ ctlfe_lun_disable(void *arg, struct ctl_
static void
ctlfe_dump_sim(struct cam_sim *sim)
{
- int i;
printf("%s%d: max tagged openings: %d, max dev openings: %d\n",
sim->sim_name, sim->unit_number,
@@ -2070,14 +2069,6 @@ ctlfe_dump_sim(struct cam_sim *sim)
printf("%s%d: ccb_freeq is %sempty\n",
sim->sim_name, sim->unit_number,
(SLIST_FIRST(&sim->ccb_freeq) == NULL) ? "" : "NOT ");
- printf("%s%d: alloc_queue.entries %d, alloc_openings %d\n",
- sim->sim_name, sim->unit_number,
- sim->devq->alloc_queue.entries, sim->devq->alloc_openings);
- printf("%s%d: qfrozen_cnt:", sim->sim_name, sim->unit_number);
- for (i = 0; i < CAM_RL_VALUES; i++) {
- printf("%s%u", (i != 0) ? ":" : "",
- sim->devq->alloc_queue.qfrozen_cnt[i]);
- }
printf("\n");
}
More information about the svn-src-projects
mailing list