Lines Matching refs:aq
27 static int ap_queue_enable_interruption(struct ap_queue *aq, void *ind) in ap_queue_enable_interruption() argument
34 status = ap_aqic(aq->qid, qirqctrl, ind); in ap_queue_enable_interruption()
44 AP_QID_CARD(aq->qid), in ap_queue_enable_interruption()
45 AP_QID_QUEUE(aq->qid)); in ap_queue_enable_interruption()
119 static enum ap_wait ap_sm_nop(struct ap_queue *aq) in ap_sm_nop() argument
131 static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) in ap_sm_recv() argument
136 status = ap_dqap(aq->qid, &aq->reply->psmid, in ap_sm_recv()
137 aq->reply->message, aq->reply->length); in ap_sm_recv()
140 aq->queue_count--; in ap_sm_recv()
141 if (aq->queue_count > 0) in ap_sm_recv()
142 mod_timer(&aq->timeout, in ap_sm_recv()
143 jiffies + aq->request_timeout); in ap_sm_recv()
144 list_for_each_entry(ap_msg, &aq->pendingq, list) { in ap_sm_recv()
145 if (ap_msg->psmid != aq->reply->psmid) in ap_sm_recv()
148 aq->pendingq_count--; in ap_sm_recv()
149 ap_msg->receive(aq, ap_msg, aq->reply); in ap_sm_recv()
153 if (!status.queue_empty || aq->queue_count <= 0) in ap_sm_recv()
156 aq->queue_count = 0; in ap_sm_recv()
157 list_splice_init(&aq->pendingq, &aq->requestq); in ap_sm_recv()
158 aq->requestq_count += aq->pendingq_count; in ap_sm_recv()
159 aq->pendingq_count = 0; in ap_sm_recv()
173 static enum ap_wait ap_sm_read(struct ap_queue *aq) in ap_sm_read() argument
177 if (!aq->reply) in ap_sm_read()
179 status = ap_sm_recv(aq); in ap_sm_read()
182 if (aq->queue_count > 0) { in ap_sm_read()
183 aq->state = AP_STATE_WORKING; in ap_sm_read()
186 aq->state = AP_STATE_IDLE; in ap_sm_read()
189 if (aq->queue_count > 0) in ap_sm_read()
191 aq->state = AP_STATE_IDLE; in ap_sm_read()
194 aq->state = AP_STATE_BORKED; in ap_sm_read()
207 static enum ap_wait ap_sm_suspend_read(struct ap_queue *aq) in ap_sm_suspend_read() argument
211 if (!aq->reply) in ap_sm_suspend_read()
213 status = ap_sm_recv(aq); in ap_sm_suspend_read()
216 if (aq->queue_count > 0) in ap_sm_suspend_read()
230 static enum ap_wait ap_sm_write(struct ap_queue *aq) in ap_sm_write() argument
235 if (aq->requestq_count <= 0) in ap_sm_write()
238 ap_msg = list_entry(aq->requestq.next, struct ap_message, list); in ap_sm_write()
239 status = __ap_send(aq->qid, ap_msg->psmid, in ap_sm_write()
243 aq->queue_count++; in ap_sm_write()
244 if (aq->queue_count == 1) in ap_sm_write()
245 mod_timer(&aq->timeout, jiffies + aq->request_timeout); in ap_sm_write()
246 list_move_tail(&ap_msg->list, &aq->pendingq); in ap_sm_write()
247 aq->requestq_count--; in ap_sm_write()
248 aq->pendingq_count++; in ap_sm_write()
249 if (aq->queue_count < aq->card->queue_depth) { in ap_sm_write()
250 aq->state = AP_STATE_WORKING; in ap_sm_write()
255 aq->state = AP_STATE_QUEUE_FULL; in ap_sm_write()
258 aq->state = AP_STATE_RESET_WAIT; in ap_sm_write()
263 aq->requestq_count--; in ap_sm_write()
265 ap_msg->receive(aq, ap_msg, NULL); in ap_sm_write()
268 aq->state = AP_STATE_BORKED; in ap_sm_write()
279 static enum ap_wait ap_sm_read_write(struct ap_queue *aq) in ap_sm_read_write() argument
281 return min(ap_sm_read(aq), ap_sm_write(aq)); in ap_sm_read_write()
290 static enum ap_wait ap_sm_reset(struct ap_queue *aq) in ap_sm_reset() argument
294 status = ap_rapq(aq->qid); in ap_sm_reset()
298 aq->state = AP_STATE_RESET_WAIT; in ap_sm_reset()
299 aq->interrupt = AP_INTR_DISABLED; in ap_sm_reset()
307 aq->state = AP_STATE_BORKED; in ap_sm_reset()
318 static enum ap_wait ap_sm_reset_wait(struct ap_queue *aq) in ap_sm_reset_wait() argument
323 if (aq->queue_count > 0 && aq->reply) in ap_sm_reset_wait()
325 status = ap_sm_recv(aq); in ap_sm_reset_wait()
328 status = ap_tapq(aq->qid, NULL); in ap_sm_reset_wait()
333 if (lsi_ptr && ap_queue_enable_interruption(aq, lsi_ptr) == 0) in ap_sm_reset_wait()
334 aq->state = AP_STATE_SETIRQ_WAIT; in ap_sm_reset_wait()
336 aq->state = (aq->queue_count > 0) ? in ap_sm_reset_wait()
346 aq->state = AP_STATE_BORKED; in ap_sm_reset_wait()
357 static enum ap_wait ap_sm_setirq_wait(struct ap_queue *aq) in ap_sm_setirq_wait() argument
361 if (aq->queue_count > 0 && aq->reply) in ap_sm_setirq_wait()
363 status = ap_sm_recv(aq); in ap_sm_setirq_wait()
366 status = ap_tapq(aq->qid, NULL); in ap_sm_setirq_wait()
370 aq->interrupt = AP_INTR_ENABLED; in ap_sm_setirq_wait()
371 aq->state = (aq->queue_count > 0) ? in ap_sm_setirq_wait()
377 if (aq->queue_count > 0) in ap_sm_setirq_wait()
383 aq->state = AP_STATE_BORKED; in ap_sm_setirq_wait()
426 enum ap_wait ap_sm_event(struct ap_queue *aq, enum ap_event event) in ap_sm_event() argument
428 return ap_jumptable[aq->state][event](aq); in ap_sm_event()
431 enum ap_wait ap_sm_event_loop(struct ap_queue *aq, enum ap_event event) in ap_sm_event_loop() argument
435 while ((wait = ap_sm_event(aq, event)) == AP_WAIT_AGAIN) in ap_sm_event_loop()
445 struct ap_queue *aq = to_ap_queue(&ap_dev->device); in ap_queue_suspend() local
448 spin_lock_bh(&aq->lock); in ap_queue_suspend()
449 aq->state = AP_STATE_SUSPEND_WAIT; in ap_queue_suspend()
450 while (ap_sm_event(aq, AP_EVENT_POLL) != AP_WAIT_NONE) in ap_queue_suspend()
452 aq->state = AP_STATE_BORKED; in ap_queue_suspend()
453 spin_unlock_bh(&aq->lock); in ap_queue_suspend()
469 struct ap_queue *aq = to_ap_queue(dev); in request_count_show() local
472 spin_lock_bh(&aq->lock); in request_count_show()
473 req_cnt = aq->total_request_count; in request_count_show()
474 spin_unlock_bh(&aq->lock); in request_count_show()
482 struct ap_queue *aq = to_ap_queue(dev); in request_count_store() local
484 spin_lock_bh(&aq->lock); in request_count_store()
485 aq->total_request_count = 0; in request_count_store()
486 spin_unlock_bh(&aq->lock); in request_count_store()
496 struct ap_queue *aq = to_ap_queue(dev); in requestq_count_show() local
499 spin_lock_bh(&aq->lock); in requestq_count_show()
500 reqq_cnt = aq->requestq_count; in requestq_count_show()
501 spin_unlock_bh(&aq->lock); in requestq_count_show()
510 struct ap_queue *aq = to_ap_queue(dev); in pendingq_count_show() local
513 spin_lock_bh(&aq->lock); 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->state) { in reset_show()
540 spin_unlock_bh(&aq->lock); in reset_show()
549 struct ap_queue *aq = to_ap_queue(dev); in interrupt_show() local
552 spin_lock_bh(&aq->lock); in interrupt_show()
553 if (aq->state == AP_STATE_SETIRQ_WAIT) in interrupt_show()
555 else if (aq->interrupt == AP_INTR_ENABLED) in interrupt_show()
559 spin_unlock_bh(&aq->lock); in interrupt_show()
590 struct ap_queue *aq = to_ap_queue(dev); in ap_queue_device_release() local
592 if (!list_empty(&aq->list)) { in ap_queue_device_release()
594 list_del_init(&aq->list); in ap_queue_device_release()
597 kfree(aq); in ap_queue_device_release()
602 struct ap_queue *aq; in ap_queue_create() local
604 aq = kzalloc(sizeof(*aq), GFP_KERNEL); in ap_queue_create()
605 if (!aq) in ap_queue_create()
607 aq->ap_dev.device.release = ap_queue_device_release; in ap_queue_create()
608 aq->ap_dev.device.type = &ap_queue_type; in ap_queue_create()
609 aq->ap_dev.device_type = device_type; in ap_queue_create()
610 aq->qid = qid; in ap_queue_create()
611 aq->state = AP_STATE_RESET_START; in ap_queue_create()
612 aq->interrupt = AP_INTR_DISABLED; in ap_queue_create()
613 spin_lock_init(&aq->lock); in ap_queue_create()
614 INIT_LIST_HEAD(&aq->list); in ap_queue_create()
615 INIT_LIST_HEAD(&aq->pendingq); in ap_queue_create()
616 INIT_LIST_HEAD(&aq->requestq); in ap_queue_create()
617 timer_setup(&aq->timeout, ap_request_timeout, 0); in ap_queue_create()
619 return aq; in ap_queue_create()
622 void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *reply) in ap_queue_init_reply() argument
624 aq->reply = reply; in ap_queue_init_reply()
626 spin_lock_bh(&aq->lock); in ap_queue_init_reply()
627 ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); in ap_queue_init_reply()
628 spin_unlock_bh(&aq->lock); in ap_queue_init_reply()
637 void ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_queue_message() argument
644 spin_lock_bh(&aq->lock); in ap_queue_message()
646 list_add_tail(&ap_msg->list, &aq->requestq); in ap_queue_message()
647 aq->requestq_count++; in ap_queue_message()
648 aq->total_request_count++; in ap_queue_message()
649 atomic_inc(&aq->card->total_request_count); in ap_queue_message()
651 ap_wait(ap_sm_event_loop(aq, AP_EVENT_POLL)); in ap_queue_message()
652 spin_unlock_bh(&aq->lock); in ap_queue_message()
666 void ap_cancel_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_cancel_message() argument
670 spin_lock_bh(&aq->lock); in ap_cancel_message()
672 list_for_each_entry(tmp, &aq->pendingq, list) in ap_cancel_message()
674 aq->pendingq_count--; in ap_cancel_message()
677 aq->requestq_count--; in ap_cancel_message()
681 spin_unlock_bh(&aq->lock); in ap_cancel_message()
691 static void __ap_flush_queue(struct ap_queue *aq) in __ap_flush_queue() argument
695 list_for_each_entry_safe(ap_msg, next, &aq->pendingq, list) { in __ap_flush_queue()
697 aq->pendingq_count--; in __ap_flush_queue()
699 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
701 list_for_each_entry_safe(ap_msg, next, &aq->requestq, list) { in __ap_flush_queue()
703 aq->requestq_count--; in __ap_flush_queue()
705 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
709 void ap_flush_queue(struct ap_queue *aq) in ap_flush_queue() argument
711 spin_lock_bh(&aq->lock); in ap_flush_queue()
712 __ap_flush_queue(aq); in ap_flush_queue()
713 spin_unlock_bh(&aq->lock); in ap_flush_queue()
717 void ap_queue_remove(struct ap_queue *aq) in ap_queue_remove() argument
719 ap_flush_queue(aq); in ap_queue_remove()
720 del_timer_sync(&aq->timeout); in ap_queue_remove()