PERFORCE change 97225 for review
Scott Long
scottl at FreeBSD.org
Tue May 16 01:02:22 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=97225
Change 97225 by scottl at scottl-x64 on 2006/05/16 01:01:11
Move ownership of the free CCB pool to the SIM. Limits and counts
are now per-SIM instead of global. Need to play with this in the
future, also need to look into migrating CCBs between pools when
needed.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.c#7 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#6 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#25 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_sim.c#7 (text+ko) ====
@@ -94,6 +94,8 @@
callout_init(&sim->callout, 1);
}
+ SLIST_INIT(&sim->ccb_freeq);
+
return (sim);
}
==== //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#6 (text+ko) ====
@@ -103,6 +103,17 @@
#define CAM_SIM_MPSAFE 0x02
struct callout callout;
struct cam_devq *devq; /* Device Queue to use for this SIM */
+
+ /* "Pool" of inactive ccbs managed by xpt_alloc_ccb and xpt_free_ccb */
+ SLIST_HEAD(,ccb_hdr) ccb_freeq;
+ /*
+ * Maximum size of ccb pool. Modified as devices are added/removed
+ * or have their * opening counts changed.
+ */
+ u_int max_ccbs;
+ /* Current count of allocated ccbs */
+ u_int ccb_count;
+
};
static __inline u_int32_t
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#25 (text+ko) ====
@@ -115,6 +115,7 @@
struct cam_ed_qinfo alloc_ccb_entry;
struct cam_ed_qinfo send_ccb_entry;
struct cam_et *target;
+ struct cam_sim *sim;
lun_id_t lun_id;
struct camq drvq; /*
* Queue of type drivers wanting to do
@@ -636,15 +637,6 @@
static cam_isrq_t cam_bioq;
static struct mtx cam_bioq_lock;
-/* "Pool" of inactive ccbs managed by xpt_alloc_ccb and xpt_free_ccb */
-static SLIST_HEAD(,ccb_hdr) ccb_freeq;
-static u_int xpt_max_ccbs; /*
- * Maximum size of ccb pool. Modified as
- * devices are added/removed or have their
- * opening counts changed.
- */
-static u_int xpt_ccb_count; /* Current count of allocated ccbs */
-
struct cam_periph *xpt_periph;
static periph_init_t xpt_periph_init;
@@ -1414,7 +1406,6 @@
TAILQ_INIT(&xpt_busses);
TAILQ_INIT(&cam_bioq);
- SLIST_INIT(&ccb_freeq);
STAILQ_INIT(&highpowerq);
mtx_init(&cam_bioq_lock, "CAM BIOQ lock", NULL, MTX_DEF);
@@ -1436,7 +1427,7 @@
/*max_dev_transactions*/0,
/*max_tagged_dev_transactions*/0,
devq);
- xpt_max_ccbs = 16;
+ xpt_sim->max_ccbs = 16;
xpt_bus_register(xpt_sim, /*bus #*/0);
@@ -4362,34 +4353,38 @@
struct cam_path *path;
struct cam_ed *device;
struct cam_eb *bus;
-
- GIANT_REQUIRED;
+ struct cam_sim *sim;
CAM_DEBUG_PRINT(CAM_DEBUG_XPT, ("xpt_release_ccb\n"));
path = free_ccb->ccb_h.path;
device = path->device;
bus = path->bus;
+ sim = bus->sim;
s = splsoftcam();
+
+ mtx_assert(sim->mtx, MA_OWNED);
+
cam_ccbq_release_opening(&device->ccbq);
- if (xpt_ccb_count > xpt_max_ccbs) {
+ if (sim->ccb_count > sim->max_ccbs) {
xpt_free_ccb(free_ccb);
- xpt_ccb_count--;
+ sim->ccb_count--;
} else {
- SLIST_INSERT_HEAD(&ccb_freeq, &free_ccb->ccb_h, xpt_links.sle);
+ SLIST_INSERT_HEAD(&sim->ccb_freeq, &free_ccb->ccb_h,
+ xpt_links.sle);
}
- if (bus->sim->devq == NULL) {
+ if (sim->devq == NULL) {
splx(s);
return;
}
- bus->sim->devq->alloc_openings++;
- bus->sim->devq->alloc_active--;
+ sim->devq->alloc_openings++;
+ sim->devq->alloc_active--;
/* XXX Turn this into an inline function - xpt_run_device?? */
if ((device_is_alloc_queued(device) == 0)
&& (device->drvq.entries > 0)) {
xpt_schedule_dev_allocq(bus, device);
}
splx(s);
- if (dev_allocq_is_runnable(bus->sim->devq))
+ if (dev_allocq_is_runnable(sim->devq))
xpt_run_dev_allocq(bus);
}
@@ -5015,22 +5010,24 @@
xpt_get_ccb(struct cam_ed *device)
{
union ccb *new_ccb;
+ struct cam_sim *sim;
int s;
s = splsoftcam();
- if ((new_ccb = (union ccb *)SLIST_FIRST(&ccb_freeq)) == NULL) {
+ sim = device->sim;
+ if ((new_ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) == NULL) {
new_ccb = xpt_alloc_ccb_nowait();
if (new_ccb == NULL) {
splx(s);
return (NULL);
}
callout_handle_init(&new_ccb->ccb_h.timeout_ch);
- SLIST_INSERT_HEAD(&ccb_freeq, &new_ccb->ccb_h,
+ SLIST_INSERT_HEAD(&sim->ccb_freeq, &new_ccb->ccb_h,
xpt_links.sle);
- xpt_ccb_count++;
+ sim->ccb_count++;
}
cam_ccbq_take_opening(&device->ccbq);
- SLIST_REMOVE_HEAD(&ccb_freeq, xpt_links.sle);
+ SLIST_REMOVE_HEAD(&sim->ccb_freeq, xpt_links.sle);
splx(s);
return (new_ccb);
}
@@ -5137,6 +5134,7 @@
device->send_ccb_entry.device = device;
device->target = target;
device->lun_id = lun_id;
+ device->sim = bus->sim;
/* Initialize our queues */
if (camq_init(&device->drvq, 0) != 0) {
free(device, M_CAMXPT);
@@ -5182,7 +5180,7 @@
* XXX should be limited by number of CCBs this bus can
* do.
*/
- xpt_max_ccbs += device->ccbq.devq_openings;
+ bus->sim->max_ccbs += device->ccbq.devq_openings;
/* Insertion sort into our target's device list */
cur_device = TAILQ_FIRST(&target->ed_entries);
while (cur_device != NULL && cur_device->lun_id < lun_id)
@@ -5228,7 +5226,7 @@
TAILQ_REMOVE(&target->ed_entries, device,links);
target->generation++;
- xpt_max_ccbs -= device->ccbq.devq_openings;
+ bus->sim->max_ccbs -= device->ccbq.devq_openings;
if (!SIM_DEAD(bus->sim)) {
/* Release our slot in the devq */
devq = bus->sim->devq;
@@ -5263,7 +5261,7 @@
|| (dev->inq_flags & SID_CmdQue) != 0)
dev->tag_saved_openings = newopenings;
/* Adjust the global limit */
- xpt_max_ccbs += diff;
+ dev->sim->max_ccbs += diff;
splx(s);
return (result);
}
More information about the p4-projects
mailing list