Lines Matching refs:aq

19 static void __ap_flush_queue(struct ap_queue *aq);
30 static int ap_queue_enable_interruption(struct ap_queue *aq, void *ind) in ap_queue_enable_interruption() argument
37 status = ap_aqic(aq->qid, qirqctrl, ind); in ap_queue_enable_interruption()
47 AP_QID_CARD(aq->qid), in ap_queue_enable_interruption()
48 AP_QID_QUEUE(aq->qid)); in ap_queue_enable_interruption()
122 static enum ap_wait ap_sm_nop(struct ap_queue *aq) in ap_sm_nop() argument
134 static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) in ap_sm_recv() argument
139 status = ap_dqap(aq->qid, &aq->reply->psmid, in ap_sm_recv()
140 aq->reply->message, aq->reply->length); in ap_sm_recv()
143 aq->queue_count--; in ap_sm_recv()
144 if (aq->queue_count > 0) in ap_sm_recv()
145 mod_timer(&aq->timeout, in ap_sm_recv()
146 jiffies + aq->request_timeout); in ap_sm_recv()
147 list_for_each_entry(ap_msg, &aq->pendingq, list) { in ap_sm_recv()
148 if (ap_msg->psmid != aq->reply->psmid) in ap_sm_recv()
151 aq->pendingq_count--; in ap_sm_recv()
152 ap_msg->receive(aq, ap_msg, aq->reply); in ap_sm_recv()
157 if (!status.queue_empty || aq->queue_count <= 0) in ap_sm_recv()
160 aq->queue_count = 0; in ap_sm_recv()
161 list_splice_init(&aq->pendingq, &aq->requestq); in ap_sm_recv()
162 aq->requestq_count += aq->pendingq_count; in ap_sm_recv()
163 aq->pendingq_count = 0; in ap_sm_recv()
177 static enum ap_wait ap_sm_read(struct ap_queue *aq) in ap_sm_read() argument
181 if (!aq->reply) in ap_sm_read()
183 status = ap_sm_recv(aq); in ap_sm_read()
186 if (aq->queue_count > 0) { in ap_sm_read()
187 aq->state = AP_STATE_WORKING; in ap_sm_read()
190 aq->state = AP_STATE_IDLE; in ap_sm_read()
193 if (aq->queue_count > 0) in ap_sm_read()
195 aq->state = AP_STATE_IDLE; in ap_sm_read()
198 aq->state = AP_STATE_BORKED; in ap_sm_read()
211 static enum ap_wait ap_sm_suspend_read(struct ap_queue *aq) in ap_sm_suspend_read() argument
215 if (!aq->reply) in ap_sm_suspend_read()
217 status = ap_sm_recv(aq); in ap_sm_suspend_read()
220 if (aq->queue_count > 0) in ap_sm_suspend_read()
234 static enum ap_wait ap_sm_write(struct ap_queue *aq) in ap_sm_write() argument
239 if (aq->requestq_count <= 0) in ap_sm_write()
242 ap_msg = list_entry(aq->requestq.next, struct ap_message, list); in ap_sm_write()
243 status = __ap_send(aq->qid, ap_msg->psmid, in ap_sm_write()
247 aq->queue_count++; in ap_sm_write()
248 if (aq->queue_count == 1) in ap_sm_write()
249 mod_timer(&aq->timeout, jiffies + aq->request_timeout); in ap_sm_write()
250 list_move_tail(&ap_msg->list, &aq->pendingq); in ap_sm_write()
251 aq->requestq_count--; in ap_sm_write()
252 aq->pendingq_count++; in ap_sm_write()
253 if (aq->queue_count < aq->card->queue_depth) { in ap_sm_write()
254 aq->state = AP_STATE_WORKING; in ap_sm_write()
259 aq->state = AP_STATE_QUEUE_FULL; in ap_sm_write()
262 aq->state = AP_STATE_RESET_WAIT; in ap_sm_write()
267 aq->requestq_count--; in ap_sm_write()
269 ap_msg->receive(aq, ap_msg, NULL); in ap_sm_write()
272 aq->state = AP_STATE_BORKED; in ap_sm_write()
283 static enum ap_wait ap_sm_read_write(struct ap_queue *aq) in ap_sm_read_write() argument
285 return min(ap_sm_read(aq), ap_sm_write(aq)); in ap_sm_read_write()
294 static enum ap_wait ap_sm_reset(struct ap_queue *aq) in ap_sm_reset() argument
298 status = ap_rapq(aq->qid); in ap_sm_reset()
302 aq->state = AP_STATE_RESET_WAIT; in ap_sm_reset()
303 aq->interrupt = AP_INTR_DISABLED; in ap_sm_reset()
311 aq->state = AP_STATE_BORKED; in ap_sm_reset()
322 static enum ap_wait ap_sm_reset_wait(struct ap_queue *aq) in ap_sm_reset_wait() argument
327 if (aq->queue_count > 0 && aq->reply) in ap_sm_reset_wait()
329 status = ap_sm_recv(aq); in ap_sm_reset_wait()
332 status = ap_tapq(aq->qid, NULL); in ap_sm_reset_wait()
337 if (lsi_ptr && ap_queue_enable_interruption(aq, lsi_ptr) == 0) in ap_sm_reset_wait()
338 aq->state = AP_STATE_SETIRQ_WAIT; in ap_sm_reset_wait()
340 aq->state = (aq->queue_count > 0) ? in ap_sm_reset_wait()
350 aq->state = AP_STATE_BORKED; in ap_sm_reset_wait()
361 static enum ap_wait ap_sm_setirq_wait(struct ap_queue *aq) in ap_sm_setirq_wait() argument
365 if (aq->queue_count > 0 && aq->reply) in ap_sm_setirq_wait()
367 status = ap_sm_recv(aq); in ap_sm_setirq_wait()
370 status = ap_tapq(aq->qid, NULL); in ap_sm_setirq_wait()
374 aq->interrupt = AP_INTR_ENABLED; in ap_sm_setirq_wait()
375 aq->state = (aq->queue_count > 0) ? in ap_sm_setirq_wait()
381 if (aq->queue_count > 0) in ap_sm_setirq_wait()
387 aq->state = AP_STATE_BORKED; in ap_sm_setirq_wait()
438 enum ap_wait ap_sm_event(struct ap_queue *aq, enum ap_event event) in ap_sm_event() argument
440 return ap_jumptable[aq->state][event](aq); in ap_sm_event()
443 enum ap_wait ap_sm_event_loop(struct ap_queue *aq, enum ap_event event) in ap_sm_event_loop() argument
447 while ((wait = ap_sm_event(aq, event)) == AP_WAIT_AGAIN) in ap_sm_event_loop()
457 struct ap_queue *aq = to_ap_queue(&ap_dev->device); in ap_queue_suspend() local
460 spin_lock_bh(&aq->lock); in ap_queue_suspend()
461 aq->state = AP_STATE_SUSPEND_WAIT; in ap_queue_suspend()
462 while (ap_sm_event(aq, AP_EVENT_POLL) != AP_WAIT_NONE) in ap_queue_suspend()
464 aq->state = AP_STATE_BORKED; in ap_queue_suspend()
465 spin_unlock_bh(&aq->lock); in ap_queue_suspend()
481 struct ap_queue *aq = to_ap_queue(dev); in request_count_show() local
484 spin_lock_bh(&aq->lock); in request_count_show()
485 req_cnt = aq->total_request_count; in request_count_show()
486 spin_unlock_bh(&aq->lock); in request_count_show()
494 struct ap_queue *aq = to_ap_queue(dev); in request_count_store() local
496 spin_lock_bh(&aq->lock); in request_count_store()
497 aq->total_request_count = 0; in request_count_store()
498 spin_unlock_bh(&aq->lock); in request_count_store()
508 struct ap_queue *aq = to_ap_queue(dev); in requestq_count_show() local
511 spin_lock_bh(&aq->lock); in requestq_count_show()
512 reqq_cnt = aq->requestq_count; in requestq_count_show()
513 spin_unlock_bh(&aq->lock); in requestq_count_show()
522 struct ap_queue *aq = to_ap_queue(dev); in pendingq_count_show() local
525 spin_lock_bh(&aq->lock); in pendingq_count_show()
526 penq_cnt = aq->pendingq_count; in pendingq_count_show()
527 spin_unlock_bh(&aq->lock); in pendingq_count_show()
536 struct ap_queue *aq = to_ap_queue(dev); in reset_show() local
539 spin_lock_bh(&aq->lock); in reset_show()
540 switch (aq->state) { in reset_show()
552 spin_unlock_bh(&aq->lock); in reset_show()
560 struct ap_queue *aq = to_ap_queue(dev); in reset_store() local
562 spin_lock_bh(&aq->lock); in reset_store()
563 __ap_flush_queue(aq); in reset_store()
564 aq->state = AP_STATE_RESET_START; in reset_store()
565 ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); in reset_store()
566 spin_unlock_bh(&aq->lock); in reset_store()
569 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in reset_store()
579 struct ap_queue *aq = to_ap_queue(dev); in interrupt_show() local
582 spin_lock_bh(&aq->lock); in interrupt_show()
583 if (aq->state == AP_STATE_SETIRQ_WAIT) in interrupt_show()
585 else if (aq->interrupt == AP_INTR_ENABLED) in interrupt_show()
589 spin_unlock_bh(&aq->lock); in interrupt_show()
620 struct ap_queue *aq = to_ap_queue(dev); in ap_queue_device_release() local
622 if (!list_empty(&aq->list)) { in ap_queue_device_release()
624 list_del_init(&aq->list); in ap_queue_device_release()
627 kfree(aq); in ap_queue_device_release()
632 struct ap_queue *aq; in ap_queue_create() local
634 aq = kzalloc(sizeof(*aq), GFP_KERNEL); in ap_queue_create()
635 if (!aq) in ap_queue_create()
637 aq->ap_dev.device.release = ap_queue_device_release; in ap_queue_create()
638 aq->ap_dev.device.type = &ap_queue_type; in ap_queue_create()
639 aq->ap_dev.device_type = device_type; in ap_queue_create()
640 aq->qid = qid; in ap_queue_create()
641 aq->state = AP_STATE_RESET_START; in ap_queue_create()
642 aq->interrupt = AP_INTR_DISABLED; in ap_queue_create()
643 spin_lock_init(&aq->lock); in ap_queue_create()
644 INIT_LIST_HEAD(&aq->list); in ap_queue_create()
645 INIT_LIST_HEAD(&aq->pendingq); in ap_queue_create()
646 INIT_LIST_HEAD(&aq->requestq); in ap_queue_create()
647 timer_setup(&aq->timeout, ap_request_timeout, 0); in ap_queue_create()
649 return aq; in ap_queue_create()
652 void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *reply) in ap_queue_init_reply() argument
654 aq->reply = reply; in ap_queue_init_reply()
656 spin_lock_bh(&aq->lock); in ap_queue_init_reply()
657 ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); in ap_queue_init_reply()
658 spin_unlock_bh(&aq->lock); in ap_queue_init_reply()
667 void ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_queue_message() argument
674 spin_lock_bh(&aq->lock); in ap_queue_message()
676 list_add_tail(&ap_msg->list, &aq->requestq); in ap_queue_message()
677 aq->requestq_count++; in ap_queue_message()
678 aq->total_request_count++; in ap_queue_message()
679 atomic_inc(&aq->card->total_request_count); in ap_queue_message()
681 ap_wait(ap_sm_event_loop(aq, AP_EVENT_POLL)); in ap_queue_message()
682 spin_unlock_bh(&aq->lock); in ap_queue_message()
696 void ap_cancel_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_cancel_message() argument
700 spin_lock_bh(&aq->lock); in ap_cancel_message()
702 list_for_each_entry(tmp, &aq->pendingq, list) in ap_cancel_message()
704 aq->pendingq_count--; in ap_cancel_message()
707 aq->requestq_count--; in ap_cancel_message()
711 spin_unlock_bh(&aq->lock); in ap_cancel_message()
721 static void __ap_flush_queue(struct ap_queue *aq) in __ap_flush_queue() argument
725 list_for_each_entry_safe(ap_msg, next, &aq->pendingq, list) { in __ap_flush_queue()
727 aq->pendingq_count--; in __ap_flush_queue()
729 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
731 list_for_each_entry_safe(ap_msg, next, &aq->requestq, list) { in __ap_flush_queue()
733 aq->requestq_count--; in __ap_flush_queue()
735 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
737 aq->queue_count = 0; in __ap_flush_queue()
740 void ap_flush_queue(struct ap_queue *aq) in ap_flush_queue() argument
742 spin_lock_bh(&aq->lock); in ap_flush_queue()
743 __ap_flush_queue(aq); in ap_flush_queue()
744 spin_unlock_bh(&aq->lock); in ap_flush_queue()
748 void ap_queue_prepare_remove(struct ap_queue *aq) in ap_queue_prepare_remove() argument
750 spin_lock_bh(&aq->lock); in ap_queue_prepare_remove()
752 __ap_flush_queue(aq); in ap_queue_prepare_remove()
754 aq->state = AP_STATE_REMOVE; in ap_queue_prepare_remove()
755 spin_unlock_bh(&aq->lock); in ap_queue_prepare_remove()
756 del_timer_sync(&aq->timeout); in ap_queue_prepare_remove()
759 void ap_queue_remove(struct ap_queue *aq) in ap_queue_remove() argument
768 spin_lock_bh(&aq->lock); in ap_queue_remove()
769 ap_zapq(aq->qid); in ap_queue_remove()
770 aq->state = AP_STATE_UNBOUND; in ap_queue_remove()
771 spin_unlock_bh(&aq->lock); in ap_queue_remove()
774 void ap_queue_reinit_state(struct ap_queue *aq) in ap_queue_reinit_state() argument
776 spin_lock_bh(&aq->lock); in ap_queue_reinit_state()
777 aq->state = AP_STATE_RESET_START; in ap_queue_reinit_state()
778 ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); in ap_queue_reinit_state()
779 spin_unlock_bh(&aq->lock); in ap_queue_reinit_state()