svn commit: r248918 - in projects/camlock/sys/cam: . scsi
Alexander Motin
mav at FreeBSD.org
Fri Mar 29 21:23:49 UTC 2013
Author: mav
Date: Fri Mar 29 21:23:47 2013
New Revision: 248918
URL: http://svnweb.freebsd.org/changeset/base/248918
Log:
Wipe out support for multilevel freezing.
Sponsored by:
Modified:
projects/camlock/sys/cam/cam.h
projects/camlock/sys/cam/cam_ccb.h
projects/camlock/sys/cam/cam_periph.c
projects/camlock/sys/cam/cam_periph.h
projects/camlock/sys/cam/cam_queue.h
projects/camlock/sys/cam/cam_xpt.c
projects/camlock/sys/cam/cam_xpt_sim.h
projects/camlock/sys/cam/scsi/scsi_cd.c
projects/camlock/sys/cam/scsi/scsi_pass.c
Modified: projects/camlock/sys/cam/cam.h
==============================================================================
--- projects/camlock/sys/cam/cam.h Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam.h Fri Mar 29 21:23:47 2013 (r248918)
@@ -83,8 +83,6 @@ typedef struct {
#define CAM_PRIORITY_OOB (CAM_RL_DEV << 8)
#define CAM_PRIORITY_NORMAL ((CAM_RL_NORMAL << 8) + 0x80)
#define CAM_PRIORITY_NONE (u_int32_t)-1
-#define CAM_PRIORITY_TO_RL(x) ((x) >> 8)
-#define CAM_RL_TO_PRIORITY(x) ((x) << 8)
u_int32_t generation;
int index;
#define CAM_UNQUEUED_INDEX -1
Modified: projects/camlock/sys/cam/cam_ccb.h
==============================================================================
--- projects/camlock/sys/cam/cam_ccb.h Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam_ccb.h Fri Mar 29 21:23:47 2013 (r248918)
@@ -145,8 +145,6 @@ typedef enum {
/* Path statistics (error counts, etc.) */
XPT_GDEV_STATS = 0x0c,
/* Device statistics (error counts, etc.) */
- XPT_FREEZE_QUEUE = 0x0d,
- /* Freeze device queue */
XPT_DEV_ADVINFO = 0x0e,
/* Get/Set Device advanced information */
/* SCSI Control Functions: 0x10->0x1F */
@@ -749,7 +747,6 @@ struct ccb_relsim {
#define RELSIM_RELEASE_AFTER_TIMEOUT 0x02
#define RELSIM_RELEASE_AFTER_CMDCMPLT 0x04
#define RELSIM_RELEASE_AFTER_QEMPTY 0x08
-#define RELSIM_RELEASE_RUNLEVEL 0x10
u_int32_t openings;
u_int32_t release_timeout; /* Abstract argument. */
u_int32_t qfrozen_cnt;
Modified: projects/camlock/sys/cam/cam_periph.c
==============================================================================
--- projects/camlock/sys/cam/cam_periph.c Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam_periph.c Fri Mar 29 21:23:47 2013 (r248918)
@@ -1118,21 +1118,12 @@ cam_periph_runccb(union ccb *ccb,
void
cam_freeze_devq(struct cam_path *path)
{
+ struct ccb_hdr ccb_h;
- cam_freeze_devq_arg(path, 0, 0);
-}
-
-void
-cam_freeze_devq_arg(struct cam_path *path, uint32_t flags, uint32_t arg)
-{
- struct ccb_relsim crs;
-
- xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NONE);
- crs.ccb_h.func_code = XPT_FREEZE_QUEUE;
- crs.release_flags = flags;
- crs.openings = arg;
- crs.release_timeout = arg;
- xpt_action((union ccb *)&crs);
+ xpt_setup_ccb(&ccb_h, path, /*priority*/1);
+ ccb_h.func_code = XPT_NOOP;
+ ccb_h.flags = CAM_DEV_QFREEZE;
+ xpt_action((union ccb *)&ccb_h);
}
u_int32_t
Modified: projects/camlock/sys/cam/cam_periph.h
==============================================================================
--- projects/camlock/sys/cam/cam_periph.h Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam_periph.h Fri Mar 29 21:23:47 2013 (r248918)
@@ -171,8 +171,6 @@ int cam_periph_ioctl(struct cam_periph
cam_flags camflags,
u_int32_t sense_flags));
void cam_freeze_devq(struct cam_path *path);
-void cam_freeze_devq_arg(struct cam_path *path, u_int32_t flags,
- uint32_t arg);
u_int32_t cam_release_devq(struct cam_path *path, u_int32_t relsim_flags,
u_int32_t opening_reduction, u_int32_t arg,
int getcount_only);
Modified: projects/camlock/sys/cam/cam_queue.h
==============================================================================
--- projects/camlock/sys/cam/cam_queue.h Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam_queue.h Fri Mar 29 21:23:47 2013 (r248918)
@@ -48,7 +48,7 @@ struct camq {
int array_size;
int entries;
u_int32_t generation;
- u_int32_t qfrozen_cnt[CAM_RL_VALUES];
+ u_int32_t qfrozen_cnt;
};
TAILQ_HEAD(ccb_hdr_tailq, ccb_hdr);
@@ -192,8 +192,7 @@ cam_ccbq_insert_ccb(struct cam_ccbq *ccb
{
ccbq->held--;
camq_insert(&ccbq->queue, &new_ccb->ccb_h.pinfo);
- if (ccbq->queue.qfrozen_cnt[CAM_PRIORITY_TO_RL(
- new_ccb->ccb_h.pinfo.priority)] > 0) {
+ if (ccbq->queue.qfrozen_cnt > 0) {
ccbq->devq_openings++;
ccbq->held++;
return (1);
@@ -205,8 +204,7 @@ static __inline int
cam_ccbq_remove_ccb(struct cam_ccbq *ccbq, union ccb *ccb)
{
camq_remove(&ccbq->queue, ccb->ccb_h.pinfo.index);
- if (ccbq->queue.qfrozen_cnt[CAM_PRIORITY_TO_RL(
- ccb->ccb_h.pinfo.priority)] > 0) {
+ if (ccbq->queue.qfrozen_cnt > 0) {
ccbq->devq_openings--;
ccbq->held--;
return (1);
@@ -245,80 +243,11 @@ cam_ccbq_release_opening(struct cam_ccbq
ccbq->devq_openings++;
}
-static __inline int
-cam_ccbq_freeze(struct cam_ccbq *ccbq, cam_rl rl, u_int32_t cnt)
-{
- int i, frozen = 0;
- cam_rl p, n;
-
- /* Find pevious run level. */
- for (p = 0; p < CAM_RL_VALUES && ccbq->queue.qfrozen_cnt[p] == 0; p++);
- /* Find new run level. */
- n = min(rl, p);
- /* Apply new run level. */
- for (i = rl; i < CAM_RL_VALUES; i++)
- ccbq->queue.qfrozen_cnt[i] += cnt;
- /* Update ccbq statistics. */
- if (n == p)
- return (0);
- for (i = CAMQ_HEAD; i <= ccbq->queue.entries; i++) {
- cam_rl rrl =
- CAM_PRIORITY_TO_RL(ccbq->queue.queue_array[i]->priority);
- if (rrl < n)
- continue;
- if (rrl >= p)
- break;
- ccbq->devq_openings++;
- ccbq->held++;
- frozen++;
- }
- return (frozen);
-}
-
-static __inline int
-cam_ccbq_release(struct cam_ccbq *ccbq, cam_rl rl, u_int32_t cnt)
-{
- int i, released = 0;
- cam_rl p, n;
-
- /* Apply new run level. */
- for (i = rl; i < CAM_RL_VALUES; i++)
- ccbq->queue.qfrozen_cnt[i] -= cnt;
- /* Find new run level. */
- for (n = 0; n < CAM_RL_VALUES && ccbq->queue.qfrozen_cnt[n] == 0; n++);
- /* Find previous run level. */
- p = min(rl, n);
- /* Update ccbq statistics. */
- if (n == p)
- return (0);
- for (i = CAMQ_HEAD; i <= ccbq->queue.entries; i++) {
- cam_rl rrl =
- CAM_PRIORITY_TO_RL(ccbq->queue.queue_array[i]->priority);
- if (rrl < p)
- continue;
- if (rrl >= n)
- break;
- ccbq->devq_openings--;
- ccbq->held--;
- released++;
- }
- return (released);
-}
-
static __inline u_int32_t
-cam_ccbq_frozen(struct cam_ccbq *ccbq, cam_rl rl)
+cam_ccbq_frozen(struct cam_ccbq *ccbq)
{
-
- return (ccbq->queue.qfrozen_cnt[rl]);
-}
-static __inline u_int32_t
-cam_ccbq_frozen_top(struct cam_ccbq *ccbq)
-{
- cam_rl rl;
-
- rl = CAM_PRIORITY_TO_RL(CAMQ_GET_PRIO(&ccbq->queue));
- return (ccbq->queue.qfrozen_cnt[rl]);
+ return (ccbq->queue.qfrozen_cnt);
}
#endif /* _KERNEL */
Modified: projects/camlock/sys/cam/cam_xpt.c
==============================================================================
--- projects/camlock/sys/cam/cam_xpt.c Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam_xpt.c Fri Mar 29 21:23:47 2013 (r248918)
@@ -228,8 +228,8 @@ static void xpt_run_dev_sendq(struct ca
static timeout_t xpt_release_devq_timeout;
static void xpt_release_simq_timeout(void *arg) __unused;
static void xpt_release_bus(struct cam_eb *bus);
-static void xpt_release_devq_device(struct cam_ed *dev, cam_rl rl,
- u_int count, int run_queue);
+static void xpt_release_devq_device(struct cam_ed *dev, u_int count,
+ int run_queue);
static struct cam_et*
xpt_alloc_target(struct cam_eb *bus, target_id_t target_id);
static void xpt_release_target(struct cam_et *target);
@@ -306,7 +306,7 @@ xpt_schedule_dev_sendq(struct cam_eb *bu
if ((dev->ccbq.queue.entries > 0) &&
(dev->ccbq.dev_openings > 0) &&
- (cam_ccbq_frozen_top(&dev->ccbq) == 0)) {
+ (cam_ccbq_frozen(&dev->ccbq) == 0)) {
/*
* The priority of a device waiting for controller
* resources is that of the highest priority CCB
@@ -2938,13 +2938,9 @@ xpt_action_default(union ccb *start_ccb)
}
}
- if ((start_ccb->ccb_h.flags & CAM_DEV_QFREEZE) == 0) {
- xpt_release_devq_rl(path, /*runlevel*/
- (crs->release_flags & RELSIM_RELEASE_RUNLEVEL) ?
- crs->release_timeout : 0,
- /*count*/1, /*run_queue*/TRUE);
- }
- start_ccb->crs.qfrozen_cnt = dev->ccbq.queue.qfrozen_cnt[0];
+ if ((start_ccb->ccb_h.flags & CAM_DEV_QFREEZE) == 0)
+ xpt_release_devq(path, /*count*/1, /*run_queue*/TRUE);
+ start_ccb->crs.qfrozen_cnt = dev->ccbq.queue.qfrozen_cnt;
start_ccb->ccb_h.status = CAM_REQ_CMP;
break;
}
@@ -2987,16 +2983,6 @@ xpt_action_default(union ccb *start_ccb)
start_ccb->ccb_h.status = CAM_REQ_CMP;
break;
}
- case XPT_FREEZE_QUEUE:
- {
- struct ccb_relsim *crs = &start_ccb->crs;
-
- xpt_freeze_devq_rl(path, /*runlevel*/
- (crs->release_flags & RELSIM_RELEASE_RUNLEVEL) ?
- crs->release_timeout : 0, /*count*/1);
- start_ccb->ccb_h.status = CAM_REQ_CMP;
- break;
- }
case XPT_NOOP:
if ((start_ccb->ccb_h.flags & CAM_DEV_QFREEZE) != 0)
xpt_freeze_devq(path, 1);
@@ -3181,8 +3167,7 @@ xpt_run_dev_allocq(struct cam_ed *device
while ((drvq->entries > 0) &&
(device->ccbq.devq_openings > 0 ||
CAMQ_GET_PRIO(drvq) <= CAM_PRIORITY_OOB) &&
- (cam_ccbq_frozen(&device->ccbq, CAM_PRIORITY_TO_RL(
- CAMQ_GET_PRIO(drvq))) == 0)) {
+ (cam_ccbq_frozen(&device->ccbq) == 0)) {
union ccb *work_ccb;
struct cam_periph *drv;
@@ -3220,10 +3205,10 @@ xpt_run_dev_sendq(struct cam_eb *bus)
devq = bus->sim->devq;
- devq->send_queue.qfrozen_cnt[0]++;
+ devq->send_queue.qfrozen_cnt++;
while ((devq->send_queue.entries > 0)
&& (devq->send_openings > 0)
- && (devq->send_queue.qfrozen_cnt[0] <= 1)) {
+ && (devq->send_queue.qfrozen_cnt <= 1)) {
struct cam_ed_qinfo *qinfo;
struct cam_ed *device;
union ccb *work_ccb;
@@ -3305,7 +3290,7 @@ xpt_run_dev_sendq(struct cam_eb *bus)
sim = work_ccb->ccb_h.path->bus->sim;
(*(sim->sim_action))(sim, work_ccb);
}
- devq->send_queue.qfrozen_cnt[0]--;
+ devq->send_queue.qfrozen_cnt--;
}
/*
@@ -4115,26 +4100,18 @@ xpt_dev_async_default(u_int32_t async_co
}
u_int32_t
-xpt_freeze_devq_rl(struct cam_path *path, cam_rl rl, u_int count)
+xpt_freeze_devq(struct cam_path *path, u_int count)
{
struct cam_ed *dev = path->device;
mtx_assert(path->bus->sim->mtx, MA_OWNED);
- cam_ccbq_freeze(&dev->ccbq, rl, count);
+ dev->ccbq.queue.qfrozen_cnt += count;
/* Remove frozen device from sendq. */
- if (device_is_send_queued(dev) &&
- cam_ccbq_frozen_top(&dev->ccbq)) {
+ if (device_is_send_queued(dev)) {
camq_remove(&dev->sim->devq->send_queue,
dev->send_ccb_entry.pinfo.index);
}
- return (dev->ccbq.queue.qfrozen_cnt[rl]);
-}
-
-u_int32_t
-xpt_freeze_devq(struct cam_path *path, u_int count)
-{
-
- return (xpt_freeze_devq_rl(path, 0, count));
+ return (dev->ccbq.queue.qfrozen_cnt);
}
u_int32_t
@@ -4142,8 +4119,8 @@ xpt_freeze_simq(struct cam_sim *sim, u_i
{
mtx_assert(sim->mtx, MA_OWNED);
- sim->devq->send_queue.qfrozen_cnt[0] += count;
- return (sim->devq->send_queue.qfrozen_cnt[0]);
+ sim->devq->send_queue.qfrozen_cnt += count;
+ return (sim->devq->send_queue.qfrozen_cnt);
}
static void
@@ -4152,42 +4129,32 @@ xpt_release_devq_timeout(void *arg)
struct cam_ed *device;
device = (struct cam_ed *)arg;
-
- xpt_release_devq_device(device, /*rl*/0, /*count*/1, /*run_queue*/TRUE);
+ xpt_release_devq_device(device, /*count*/1, /*run_queue*/TRUE);
}
void
xpt_release_devq(struct cam_path *path, u_int count, int run_queue)
{
- mtx_assert(path->bus->sim->mtx, MA_OWNED);
-
- xpt_release_devq_device(path->device, /*rl*/0, count, run_queue);
-}
-void
-xpt_release_devq_rl(struct cam_path *path, cam_rl rl, u_int count, int run_queue)
-{
mtx_assert(path->bus->sim->mtx, MA_OWNED);
-
- xpt_release_devq_device(path->device, rl, count, run_queue);
+ xpt_release_devq_device(path->device, count, run_queue);
}
-static void
-xpt_release_devq_device(struct cam_ed *dev, cam_rl rl, u_int count, int run_queue)
+void
+xpt_release_devq_device(struct cam_ed *dev, u_int count, int run_queue)
{
- if (count > dev->ccbq.queue.qfrozen_cnt[rl]) {
+ if (count > dev->ccbq.queue.qfrozen_cnt) {
#ifdef INVARIANTS
- printf("xpt_release_devq(%d): requested %u > present %u\n",
- rl, count, dev->ccbq.queue.qfrozen_cnt[rl]);
+ printf("xpt_release_devq(): requested %u > present %u\n",
+ count, dev->ccbq.queue.qfrozen_cnt);
#endif
- count = dev->ccbq.queue.qfrozen_cnt[rl];
+ count = dev->ccbq.queue.qfrozen_cnt;
}
- cam_ccbq_release(&dev->ccbq, rl, count);
- if (cam_ccbq_frozen(&dev->ccbq, CAM_PRIORITY_TO_RL(
- CAMQ_GET_PRIO(&dev->drvq))) == 0)
+ dev->ccbq.queue.qfrozen_cnt -= count;
+ if (cam_ccbq_frozen(&dev->ccbq) == 0)
xpt_run_dev_allocq(dev);
- if (cam_ccbq_frozen_top(&dev->ccbq) == 0) {
+ if (cam_ccbq_frozen(&dev->ccbq) == 0) {
/*
* No longer need to wait for a successful
* command completion.
@@ -4220,14 +4187,14 @@ xpt_release_simq(struct cam_sim *sim, in
mtx_assert(sim->mtx, MA_OWNED);
sendq = &(sim->devq->send_queue);
- if (sendq->qfrozen_cnt[0] <= 0) {
+ if (sendq->qfrozen_cnt <= 0) {
#ifdef INVARIANTS
printf("xpt_release_simq: requested 1 > present %u\n",
- sendq->qfrozen_cnt[0]);
+ sendq->qfrozen_cnt);
#endif
} else
- sendq->qfrozen_cnt[0]--;
- if (sendq->qfrozen_cnt[0] == 0) {
+ sendq->qfrozen_cnt--;
+ if (sendq->qfrozen_cnt == 0) {
/*
* If there is a timeout scheduled to release this
* sim queue, remove it. The queue frozen count is
Modified: projects/camlock/sys/cam/cam_xpt_sim.h
==============================================================================
--- projects/camlock/sys/cam/cam_xpt_sim.h Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/cam_xpt_sim.h Fri Mar 29 21:23:47 2013 (r248918)
@@ -43,12 +43,8 @@ int32_t xpt_bus_deregister(path_id_t pa
u_int32_t xpt_freeze_simq(struct cam_sim *sim, u_int count);
void xpt_release_simq(struct cam_sim *sim, int run_queue);
u_int32_t xpt_freeze_devq(struct cam_path *path, u_int count);
-u_int32_t xpt_freeze_devq_rl(struct cam_path *path, cam_rl rl,
- u_int count);
void xpt_release_devq(struct cam_path *path,
u_int count, int run_queue);
-void xpt_release_devq_rl(struct cam_path *path, cam_rl rl,
- u_int count, int run_queue);
int xpt_sim_opened(struct cam_sim *sim);
void xpt_done(union ccb *done_ccb);
void xpt_batch_start(struct cam_sim *sim);
Modified: projects/camlock/sys/cam/scsi/scsi_cd.c
==============================================================================
--- projects/camlock/sys/cam/scsi/scsi_cd.c Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/scsi/scsi_cd.c Fri Mar 29 21:23:47 2013 (r248918)
@@ -465,7 +465,7 @@ cdcleanup(struct cam_periph *periph)
callout_stop(&softc->changer->short_handle);
softc->changer->flags &= ~CHANGER_SHORT_TMOUT_SCHED;
}
- softc->changer->devq.qfrozen_cnt[0]--;
+ softc->changer->devq.qfrozen_cnt--;
softc->changer->flags |= CHANGER_MANUAL_CALL;
cdrunchangerqueue(softc->changer);
}
@@ -1256,13 +1256,13 @@ cdrunchangerqueue(void *arg)
* If the changer queue is frozen, that means we have an active
* device.
*/
- if (changer->devq.qfrozen_cnt[0] > 0) {
+ if (changer->devq.qfrozen_cnt > 0) {
/*
* We always need to reset the frozen count and clear the
* active flag.
*/
- changer->devq.qfrozen_cnt[0]--;
+ changer->devq.qfrozen_cnt--;
changer->cur_device->flags &= ~CD_FLAG_ACTIVE;
changer->cur_device->flags &= ~CD_FLAG_SCHED_ON_COMP;
@@ -1297,7 +1297,7 @@ cdrunchangerqueue(void *arg)
changer->cur_device = softc;
- changer->devq.qfrozen_cnt[0]++;
+ changer->devq.qfrozen_cnt++;
softc->flags |= CD_FLAG_ACTIVE;
/* Just in case this device is waiting */
Modified: projects/camlock/sys/cam/scsi/scsi_pass.c
==============================================================================
--- projects/camlock/sys/cam/scsi/scsi_pass.c Fri Mar 29 21:21:25 2013 (r248917)
+++ projects/camlock/sys/cam/scsi/scsi_pass.c Fri Mar 29 21:23:47 2013 (r248918)
@@ -613,8 +613,8 @@ passioctl(struct cdev *dev, u_long cmd,
/* Compatibility for RL/priority-unaware code. */
priority = inccb->ccb_h.pinfo.priority;
- if (priority < CAM_RL_TO_PRIORITY(CAM_RL_NORMAL))
- priority += CAM_RL_TO_PRIORITY(CAM_RL_NORMAL);
+ if (priority <= CAM_PRIORITY_OOB)
+ priority += CAM_PRIORITY_OOB + 1;
/*
* Non-immediate CCBs need a CCB from the per-device pool
More information about the svn-src-projects
mailing list