summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/unsolicited_frame_control.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-06-09 16:04:28 -0700
committerDan Williams <dan.j.williams@intel.com>2011-07-03 04:04:51 -0700
commit994a9303d33f8238d57f58c26067b6d4ac9af222 (patch)
tree8a7a1f680761ee3cfb2a258c2784194eea69b703 /drivers/scsi/isci/unsolicited_frame_control.c
parentdd047c8e2bca22856050dbe0378a37cf44eecc97 (diff)
downloadblackbird-op-linux-994a9303d33f8238d57f58c26067b6d4ac9af222.tar.gz
blackbird-op-linux-994a9303d33f8238d57f58c26067b6d4ac9af222.zip
isci: cleanup/optimize queue increment macros
Every single i/o or event completion incurs a test and branch to see if the cycle bit changed. For power-of-2 queue sizes the cycle bit can be read directly from the rollover of the queue pointer. Likely premature optimization, but the hidden if() and hidden assignments / side-effects in the macros were already asking to be cleaned up. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/unsolicited_frame_control.c')
-rw-r--r--drivers/scsi/isci/unsolicited_frame_control.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/drivers/scsi/isci/unsolicited_frame_control.c b/drivers/scsi/isci/unsolicited_frame_control.c
index d89570700ffd..680582d8cde5 100644
--- a/drivers/scsi/isci/unsolicited_frame_control.c
+++ b/drivers/scsi/isci/unsolicited_frame_control.c
@@ -209,7 +209,8 @@ bool scic_sds_unsolicited_frame_control_release_frame(
/*
* In the event there are NULL entries in the UF table, we need to
* advance the get pointer in order to find out if this frame should
- * be released (i.e. update the get pointer). */
+ * be released (i.e. update the get pointer)
+ */
while (lower_32_bits(uf_control->address_table.array[frame_get]) == 0 &&
upper_32_bits(uf_control->address_table.array[frame_get]) == 0 &&
frame_get < SCU_MAX_UNSOLICITED_FRAMES)
@@ -217,40 +218,37 @@ bool scic_sds_unsolicited_frame_control_release_frame(
/*
* The table has a NULL entry as it's last element. This is
- * illegal. */
+ * illegal.
+ */
BUG_ON(frame_get >= SCU_MAX_UNSOLICITED_FRAMES);
+ if (frame_index >= SCU_MAX_UNSOLICITED_FRAMES)
+ return false;
- if (frame_index < SCU_MAX_UNSOLICITED_FRAMES) {
- uf_control->buffers.array[frame_index].state = UNSOLICITED_FRAME_RELEASED;
+ uf_control->buffers.array[frame_index].state = UNSOLICITED_FRAME_RELEASED;
+ if (frame_get != frame_index) {
/*
- * The frame index is equal to the current get pointer so we
- * can now free up all of the frame entries that */
- if (frame_get == frame_index) {
- while (
- uf_control->buffers.array[frame_get].state
- == UNSOLICITED_FRAME_RELEASED
- ) {
- uf_control->buffers.array[frame_get].state = UNSOLICITED_FRAME_EMPTY;
-
- INCREMENT_QUEUE_GET(
- frame_get,
- frame_cycle,
- SCU_MAX_UNSOLICITED_FRAMES - 1,
- SCU_MAX_UNSOLICITED_FRAMES);
- }
-
- uf_control->get =
- (SCU_UFQGP_GEN_BIT(ENABLE_BIT) | frame_cycle | frame_get);
+ * Frames remain in use until we advance the get pointer
+ * so there is nothing we can do here
+ */
+ return false;
+ }
- return true;
- } else {
- /*
- * Frames remain in use until we advance the get pointer
- * so there is nothing we can do here */
- }
+ /*
+ * The frame index is equal to the current get pointer so we
+ * can now free up all of the frame entries that
+ */
+ while (uf_control->buffers.array[frame_get].state == UNSOLICITED_FRAME_RELEASED) {
+ uf_control->buffers.array[frame_get].state = UNSOLICITED_FRAME_EMPTY;
+
+ if (frame_get+1 == SCU_MAX_UNSOLICITED_FRAMES-1) {
+ frame_cycle ^= SCU_MAX_UNSOLICITED_FRAMES;
+ frame_get = 0;
+ } else
+ frame_get++;
}
- return false;
-}
+ uf_control->get = SCU_UFQGP_GEN_BIT(ENABLE_BIT) | frame_cycle | frame_get;
+ return true;
+}
OpenPOWER on IntegriCloud