• Home
  • Raw
  • Download

Lines Matching refs:aq

19 static void __ap_flush_queue(struct ap_queue *aq);
30 static int ap_queue_enable_irq(struct ap_queue *aq, void *ind) in ap_queue_enable_irq() argument
37 status = ap_aqic(aq->qid, qirqctrl, ind); in ap_queue_enable_irq()
47 AP_QID_CARD(aq->qid), in ap_queue_enable_irq()
48 AP_QID_QUEUE(aq->qid)); in ap_queue_enable_irq()
122 static enum ap_sm_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
140 status = ap_dqap(aq->qid, &aq->reply->psmid, in ap_sm_recv()
141 aq->reply->msg, aq->reply->len); in ap_sm_recv()
144 aq->queue_count = max_t(int, 0, aq->queue_count - 1); in ap_sm_recv()
145 if (!status.queue_empty && !aq->queue_count) in ap_sm_recv()
146 aq->queue_count++; in ap_sm_recv()
147 if (aq->queue_count > 0) in ap_sm_recv()
148 mod_timer(&aq->timeout, in ap_sm_recv()
149 jiffies + aq->request_timeout); in ap_sm_recv()
150 list_for_each_entry(ap_msg, &aq->pendingq, list) { in ap_sm_recv()
151 if (ap_msg->psmid != aq->reply->psmid) in ap_sm_recv()
154 aq->pendingq_count--; in ap_sm_recv()
155 ap_msg->receive(aq, ap_msg, aq->reply); in ap_sm_recv()
161 __func__, aq->reply->psmid, in ap_sm_recv()
162 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_recv()
166 if (!status.queue_empty || aq->queue_count <= 0) in ap_sm_recv()
169 aq->queue_count = 0; in ap_sm_recv()
170 list_splice_init(&aq->pendingq, &aq->requestq); in ap_sm_recv()
171 aq->requestq_count += aq->pendingq_count; in ap_sm_recv()
172 aq->pendingq_count = 0; in ap_sm_recv()
186 static enum ap_sm_wait ap_sm_read(struct ap_queue *aq) in ap_sm_read() argument
190 if (!aq->reply) in ap_sm_read()
192 status = ap_sm_recv(aq); in ap_sm_read()
195 if (aq->queue_count > 0) { in ap_sm_read()
196 aq->sm_state = AP_SM_STATE_WORKING; in ap_sm_read()
199 aq->sm_state = AP_SM_STATE_IDLE; in ap_sm_read()
202 if (aq->queue_count > 0) in ap_sm_read()
203 return aq->interrupt ? in ap_sm_read()
205 aq->sm_state = AP_SM_STATE_IDLE; in ap_sm_read()
208 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_read()
209 aq->last_err_rc = status.response_code; in ap_sm_read()
212 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_read()
223 static enum ap_sm_wait ap_sm_write(struct ap_queue *aq) in ap_sm_write() argument
227 ap_qid_t qid = aq->qid; in ap_sm_write()
229 if (aq->requestq_count <= 0) in ap_sm_write()
232 ap_msg = list_entry(aq->requestq.next, struct ap_message, list); in ap_sm_write()
245 aq->queue_count = max_t(int, 1, aq->queue_count + 1); in ap_sm_write()
246 if (aq->queue_count == 1) in ap_sm_write()
247 mod_timer(&aq->timeout, jiffies + aq->request_timeout); in ap_sm_write()
248 list_move_tail(&ap_msg->list, &aq->pendingq); in ap_sm_write()
249 aq->requestq_count--; in ap_sm_write()
250 aq->pendingq_count++; in ap_sm_write()
251 if (aq->queue_count < aq->card->queue_depth) { in ap_sm_write()
252 aq->sm_state = AP_SM_STATE_WORKING; in ap_sm_write()
257 aq->sm_state = AP_SM_STATE_QUEUE_FULL; in ap_sm_write()
258 return aq->interrupt ? in ap_sm_write()
261 aq->sm_state = AP_SM_STATE_RESET_WAIT; in ap_sm_write()
269 aq->requestq_count--; in ap_sm_write()
271 ap_msg->receive(aq, ap_msg, NULL); in ap_sm_write()
274 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_write()
275 aq->last_err_rc = status.response_code; in ap_sm_write()
278 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_write()
289 static enum ap_sm_wait ap_sm_read_write(struct ap_queue *aq) in ap_sm_read_write() argument
291 return min(ap_sm_read(aq), ap_sm_write(aq)); in ap_sm_read_write()
300 static enum ap_sm_wait ap_sm_reset(struct ap_queue *aq) in ap_sm_reset() argument
304 status = ap_rapq(aq->qid); in ap_sm_reset()
308 aq->sm_state = AP_SM_STATE_RESET_WAIT; in ap_sm_reset()
309 aq->interrupt = false; in ap_sm_reset()
312 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_reset()
313 aq->last_err_rc = status.response_code; in ap_sm_reset()
316 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_reset()
327 static enum ap_sm_wait ap_sm_reset_wait(struct ap_queue *aq) in ap_sm_reset_wait() argument
332 if (aq->queue_count > 0 && aq->reply) in ap_sm_reset_wait()
334 status = ap_sm_recv(aq); in ap_sm_reset_wait()
337 status = ap_tapq(aq->qid, NULL); in ap_sm_reset_wait()
342 if (lsi_ptr && ap_queue_enable_irq(aq, lsi_ptr) == 0) in ap_sm_reset_wait()
343 aq->sm_state = AP_SM_STATE_SETIRQ_WAIT; in ap_sm_reset_wait()
345 aq->sm_state = (aq->queue_count > 0) ? in ap_sm_reset_wait()
355 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_reset_wait()
356 aq->last_err_rc = status.response_code; in ap_sm_reset_wait()
359 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_reset_wait()
370 static enum ap_sm_wait ap_sm_setirq_wait(struct ap_queue *aq) in ap_sm_setirq_wait() argument
374 if (aq->queue_count > 0 && aq->reply) in ap_sm_setirq_wait()
376 status = ap_sm_recv(aq); in ap_sm_setirq_wait()
379 status = ap_tapq(aq->qid, NULL); in ap_sm_setirq_wait()
383 aq->interrupt = true; in ap_sm_setirq_wait()
384 aq->sm_state = (aq->queue_count > 0) ? in ap_sm_setirq_wait()
390 if (aq->queue_count > 0) in ap_sm_setirq_wait()
396 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_setirq_wait()
397 aq->last_err_rc = status.response_code; in ap_sm_setirq_wait()
400 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_setirq_wait()
435 enum ap_sm_wait ap_sm_event(struct ap_queue *aq, enum ap_sm_event event) in ap_sm_event() argument
437 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in ap_sm_event()
438 return ap_jumptable[aq->sm_state][event](aq); in ap_sm_event()
443 enum ap_sm_wait ap_sm_event_loop(struct ap_queue *aq, enum ap_sm_event event) in ap_sm_event_loop() argument
447 while ((wait = ap_sm_event(aq, event)) == AP_SM_WAIT_AGAIN) in ap_sm_event_loop()
459 struct ap_queue *aq = to_ap_queue(dev); in request_count_show() local
463 spin_lock_bh(&aq->lock); in request_count_show()
464 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) { in request_count_show()
465 req_cnt = aq->total_request_count; in request_count_show()
468 spin_unlock_bh(&aq->lock); in request_count_show()
480 struct ap_queue *aq = to_ap_queue(dev); in request_count_store() local
482 spin_lock_bh(&aq->lock); in request_count_store()
483 aq->total_request_count = 0; in request_count_store()
484 spin_unlock_bh(&aq->lock); in request_count_store()
494 struct ap_queue *aq = to_ap_queue(dev); in requestq_count_show() local
497 spin_lock_bh(&aq->lock); in requestq_count_show()
498 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in requestq_count_show()
499 reqq_cnt = aq->requestq_count; in requestq_count_show()
500 spin_unlock_bh(&aq->lock); in requestq_count_show()
509 struct ap_queue *aq = to_ap_queue(dev); in pendingq_count_show() local
512 spin_lock_bh(&aq->lock); in pendingq_count_show()
513 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in pendingq_count_show()
514 penq_cnt = aq->pendingq_count; in pendingq_count_show()
515 spin_unlock_bh(&aq->lock); in pendingq_count_show()
524 struct ap_queue *aq = to_ap_queue(dev); in reset_show() local
527 spin_lock_bh(&aq->lock); in reset_show()
528 switch (aq->sm_state) { in reset_show()
540 spin_unlock_bh(&aq->lock); in reset_show()
548 struct ap_queue *aq = to_ap_queue(dev); in reset_store() local
550 spin_lock_bh(&aq->lock); in reset_store()
551 __ap_flush_queue(aq); in reset_store()
552 aq->sm_state = AP_SM_STATE_RESET_START; in reset_store()
553 ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); in reset_store()
554 spin_unlock_bh(&aq->lock); in reset_store()
557 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in reset_store()
567 struct ap_queue *aq = to_ap_queue(dev); in interrupt_show() local
570 spin_lock_bh(&aq->lock); in interrupt_show()
571 if (aq->sm_state == AP_SM_STATE_SETIRQ_WAIT) in interrupt_show()
573 else if (aq->interrupt) in interrupt_show()
577 spin_unlock_bh(&aq->lock); in interrupt_show()
586 struct ap_queue *aq = to_ap_queue(dev); in config_show() local
589 spin_lock_bh(&aq->lock); in config_show()
590 rc = scnprintf(buf, PAGE_SIZE, "%d\n", aq->config ? 1 : 0); in config_show()
591 spin_unlock_bh(&aq->lock); in config_show()
601 struct ap_queue *aq = to_ap_queue(dev); in states_show() local
604 spin_lock_bh(&aq->lock); in states_show()
606 switch (aq->dev_state) { in states_show()
623 if (aq->dev_state) { in states_show()
624 switch (aq->sm_state) { in states_show()
654 spin_unlock_bh(&aq->lock); in states_show()
663 struct ap_queue *aq = to_ap_queue(dev); in last_err_rc_show() local
666 spin_lock_bh(&aq->lock); in last_err_rc_show()
667 rc = aq->last_err_rc; in last_err_rc_show()
668 spin_unlock_bh(&aq->lock); in last_err_rc_show()
734 struct ap_queue *aq = to_ap_queue(dev); in ap_queue_device_release() local
737 hash_del(&aq->hnode); in ap_queue_device_release()
740 kfree(aq); in ap_queue_device_release()
745 struct ap_queue *aq; in ap_queue_create() local
747 aq = kzalloc(sizeof(*aq), GFP_KERNEL); in ap_queue_create()
748 if (!aq) in ap_queue_create()
750 aq->ap_dev.device.release = ap_queue_device_release; in ap_queue_create()
751 aq->ap_dev.device.type = &ap_queue_type; in ap_queue_create()
752 aq->ap_dev.device_type = device_type; in ap_queue_create()
753 aq->qid = qid; in ap_queue_create()
754 aq->interrupt = false; in ap_queue_create()
755 spin_lock_init(&aq->lock); in ap_queue_create()
756 INIT_LIST_HEAD(&aq->pendingq); in ap_queue_create()
757 INIT_LIST_HEAD(&aq->requestq); in ap_queue_create()
758 timer_setup(&aq->timeout, ap_request_timeout, 0); in ap_queue_create()
760 return aq; in ap_queue_create()
763 void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *reply) in ap_queue_init_reply() argument
765 aq->reply = reply; in ap_queue_init_reply()
767 spin_lock_bh(&aq->lock); in ap_queue_init_reply()
768 ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); in ap_queue_init_reply()
769 spin_unlock_bh(&aq->lock); in ap_queue_init_reply()
778 int ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_queue_message() argument
785 spin_lock_bh(&aq->lock); in ap_queue_message()
788 if (aq->dev_state == AP_DEV_STATE_OPERATING) { in ap_queue_message()
789 list_add_tail(&ap_msg->list, &aq->requestq); in ap_queue_message()
790 aq->requestq_count++; in ap_queue_message()
791 aq->total_request_count++; in ap_queue_message()
792 atomic64_inc(&aq->card->total_request_count); in ap_queue_message()
797 ap_wait(ap_sm_event_loop(aq, AP_SM_EVENT_POLL)); in ap_queue_message()
799 spin_unlock_bh(&aq->lock); in ap_queue_message()
815 void ap_cancel_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_cancel_message() argument
819 spin_lock_bh(&aq->lock); in ap_cancel_message()
821 list_for_each_entry(tmp, &aq->pendingq, list) in ap_cancel_message()
823 aq->pendingq_count--; in ap_cancel_message()
826 aq->requestq_count--; in ap_cancel_message()
830 spin_unlock_bh(&aq->lock); in ap_cancel_message()
840 static void __ap_flush_queue(struct ap_queue *aq) in __ap_flush_queue() argument
844 list_for_each_entry_safe(ap_msg, next, &aq->pendingq, list) { in __ap_flush_queue()
846 aq->pendingq_count--; in __ap_flush_queue()
848 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
850 list_for_each_entry_safe(ap_msg, next, &aq->requestq, list) { in __ap_flush_queue()
852 aq->requestq_count--; in __ap_flush_queue()
854 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
856 aq->queue_count = 0; in __ap_flush_queue()
859 void ap_flush_queue(struct ap_queue *aq) in ap_flush_queue() argument
861 spin_lock_bh(&aq->lock); in ap_flush_queue()
862 __ap_flush_queue(aq); in ap_flush_queue()
863 spin_unlock_bh(&aq->lock); in ap_flush_queue()
867 void ap_queue_prepare_remove(struct ap_queue *aq) in ap_queue_prepare_remove() argument
869 spin_lock_bh(&aq->lock); in ap_queue_prepare_remove()
871 __ap_flush_queue(aq); in ap_queue_prepare_remove()
873 aq->dev_state = AP_DEV_STATE_SHUTDOWN; in ap_queue_prepare_remove()
874 spin_unlock_bh(&aq->lock); in ap_queue_prepare_remove()
875 del_timer_sync(&aq->timeout); in ap_queue_prepare_remove()
878 void ap_queue_remove(struct ap_queue *aq) in ap_queue_remove() argument
886 spin_lock_bh(&aq->lock); in ap_queue_remove()
887 ap_zapq(aq->qid); in ap_queue_remove()
888 aq->dev_state = AP_DEV_STATE_UNINITIATED; in ap_queue_remove()
889 spin_unlock_bh(&aq->lock); in ap_queue_remove()
892 void ap_queue_init_state(struct ap_queue *aq) in ap_queue_init_state() argument
894 spin_lock_bh(&aq->lock); in ap_queue_init_state()
895 aq->dev_state = AP_DEV_STATE_OPERATING; in ap_queue_init_state()
896 aq->sm_state = AP_SM_STATE_RESET_START; in ap_queue_init_state()
897 ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); in ap_queue_init_state()
898 spin_unlock_bh(&aq->lock); in ap_queue_init_state()