aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/isci/host.c')
-rw-r--r--drivers/scsi/isci/host.c56
1 files changed, 13 insertions, 43 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 3c7042b8bc0..ae9edae1d24 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -123,34 +123,6 @@
123 ) 123 )
124 124
125/** 125/**
126 * INCREMENT_COMPLETION_QUEUE_GET() -
127 *
128 * This macro will increment the controllers completion queue index value and
129 * possibly toggle the cycle bit if the completion queue index wraps back to 0.
130 */
131#define INCREMENT_COMPLETION_QUEUE_GET(controller, index, cycle) \
132 INCREMENT_QUEUE_GET(\
133 (index), \
134 (cycle), \
135 SCU_MAX_COMPLETION_QUEUE_ENTRIES, \
136 SMU_CQGR_CYCLE_BIT)
137
138/**
139 * INCREMENT_EVENT_QUEUE_GET() -
140 *
141 * This macro will increment the controllers event queue index value and
142 * possibly toggle the event cycle bit if the event queue index wraps back to 0.
143 */
144#define INCREMENT_EVENT_QUEUE_GET(controller, index, cycle) \
145 INCREMENT_QUEUE_GET(\
146 (index), \
147 (cycle), \
148 SCU_MAX_EVENTS, \
149 SMU_CQGR_EVENT_CYCLE_BIT \
150 )
151
152
153/**
154 * NORMALIZE_GET_POINTER() - 126 * NORMALIZE_GET_POINTER() -
155 * 127 *
156 * This macro will normalize the completion queue get pointer so its value can 128 * This macro will normalize the completion queue get pointer so its value can
@@ -528,15 +500,13 @@ static void scic_sds_controller_event_completion(struct scic_sds_controller *sci
528 } 500 }
529} 501}
530 502
531
532
533static void scic_sds_controller_process_completions(struct scic_sds_controller *scic) 503static void scic_sds_controller_process_completions(struct scic_sds_controller *scic)
534{ 504{
535 u32 completion_count = 0; 505 u32 completion_count = 0;
536 u32 completion_entry; 506 u32 completion_entry;
537 u32 get_index; 507 u32 get_index;
538 u32 get_cycle; 508 u32 get_cycle;
539 u32 event_index; 509 u32 event_get;
540 u32 event_cycle; 510 u32 event_cycle;
541 511
542 dev_dbg(scic_to_dev(scic), 512 dev_dbg(scic_to_dev(scic),
@@ -548,7 +518,7 @@ static void scic_sds_controller_process_completions(struct scic_sds_controller *
548 get_index = NORMALIZE_GET_POINTER(scic->completion_queue_get); 518 get_index = NORMALIZE_GET_POINTER(scic->completion_queue_get);
549 get_cycle = SMU_CQGR_CYCLE_BIT & scic->completion_queue_get; 519 get_cycle = SMU_CQGR_CYCLE_BIT & scic->completion_queue_get;
550 520
551 event_index = NORMALIZE_EVENT_POINTER(scic->completion_queue_get); 521 event_get = NORMALIZE_EVENT_POINTER(scic->completion_queue_get);
552 event_cycle = SMU_CQGR_EVENT_CYCLE_BIT & scic->completion_queue_get; 522 event_cycle = SMU_CQGR_EVENT_CYCLE_BIT & scic->completion_queue_get;
553 523
554 while ( 524 while (
@@ -558,7 +528,11 @@ static void scic_sds_controller_process_completions(struct scic_sds_controller *
558 completion_count++; 528 completion_count++;
559 529
560 completion_entry = scic->completion_queue[get_index]; 530 completion_entry = scic->completion_queue[get_index];
561 INCREMENT_COMPLETION_QUEUE_GET(scic, get_index, get_cycle); 531
532 /* increment the get pointer and check for rollover to toggle the cycle bit */
533 get_cycle ^= ((get_index+1) & SCU_MAX_COMPLETION_QUEUE_ENTRIES) <<
534 (SMU_COMPLETION_QUEUE_GET_CYCLE_BIT_SHIFT - SCU_MAX_COMPLETION_QUEUE_SHIFT);
535 get_index = (get_index+1) & (SCU_MAX_COMPLETION_QUEUE_ENTRIES-1);
562 536
563 dev_dbg(scic_to_dev(scic), 537 dev_dbg(scic_to_dev(scic),
564 "%s: completion queue entry:0x%08x\n", 538 "%s: completion queue entry:0x%08x\n",
@@ -579,18 +553,14 @@ static void scic_sds_controller_process_completions(struct scic_sds_controller *
579 break; 553 break;
580 554
581 case SCU_COMPLETION_TYPE_EVENT: 555 case SCU_COMPLETION_TYPE_EVENT:
582 INCREMENT_EVENT_QUEUE_GET(scic, event_index, event_cycle); 556 case SCU_COMPLETION_TYPE_NOTIFY: {
583 scic_sds_controller_event_completion(scic, completion_entry); 557 event_cycle ^= ((event_get+1) & SCU_MAX_EVENTS) <<
584 break; 558 (SMU_COMPLETION_QUEUE_GET_EVENT_CYCLE_BIT_SHIFT - SCU_MAX_EVENTS_SHIFT);
559 event_get = (event_get+1) & (SCU_MAX_EVENTS-1);
585 560
586 case SCU_COMPLETION_TYPE_NOTIFY:
587 /*
588 * Presently we do the same thing with a notify event that we do with the
589 * other event codes. */
590 INCREMENT_EVENT_QUEUE_GET(scic, event_index, event_cycle);
591 scic_sds_controller_event_completion(scic, completion_entry); 561 scic_sds_controller_event_completion(scic, completion_entry);
592 break; 562 break;
593 563 }
594 default: 564 default:
595 dev_warn(scic_to_dev(scic), 565 dev_warn(scic_to_dev(scic),
596 "%s: SCIC Controller received unknown " 566 "%s: SCIC Controller received unknown "
@@ -607,7 +577,7 @@ static void scic_sds_controller_process_completions(struct scic_sds_controller *
607 SMU_CQGR_GEN_BIT(ENABLE) | 577 SMU_CQGR_GEN_BIT(ENABLE) |
608 SMU_CQGR_GEN_BIT(EVENT_ENABLE) | 578 SMU_CQGR_GEN_BIT(EVENT_ENABLE) |
609 event_cycle | 579 event_cycle |
610 SMU_CQGR_GEN_VAL(EVENT_POINTER, event_index) | 580 SMU_CQGR_GEN_VAL(EVENT_POINTER, event_get) |
611 get_cycle | 581 get_cycle |
612 SMU_CQGR_GEN_VAL(POINTER, get_index); 582 SMU_CQGR_GEN_VAL(POINTER, get_index);
613 583