• 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
151 status = ap_dqap(aq->qid, &aq->reply->psmid, in ap_sm_recv()
152 aq->reply->msg, aq->reply->bufsize, in ap_sm_recv()
159 aq->queue_count = max_t(int, 0, aq->queue_count - 1); in ap_sm_recv()
160 if (!status.queue_empty && !aq->queue_count) in ap_sm_recv()
161 aq->queue_count++; in ap_sm_recv()
162 if (aq->queue_count > 0) in ap_sm_recv()
163 mod_timer(&aq->timeout, in ap_sm_recv()
164 jiffies + aq->request_timeout); in ap_sm_recv()
165 list_for_each_entry(ap_msg, &aq->pendingq, list) { in ap_sm_recv()
166 if (ap_msg->psmid != aq->reply->psmid) in ap_sm_recv()
169 aq->pendingq_count--; in ap_sm_recv()
172 ap_msg->receive(aq, ap_msg, NULL); in ap_sm_recv()
174 ap_msg->receive(aq, ap_msg, aq->reply); in ap_sm_recv()
181 __func__, aq->reply->psmid, in ap_sm_recv()
182 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_recv()
186 if (!status.queue_empty || aq->queue_count <= 0) in ap_sm_recv()
189 aq->queue_count = 0; in ap_sm_recv()
190 list_splice_init(&aq->pendingq, &aq->requestq); in ap_sm_recv()
191 aq->requestq_count += aq->pendingq_count; in ap_sm_recv()
192 aq->pendingq_count = 0; in ap_sm_recv()
206 static enum ap_sm_wait ap_sm_read(struct ap_queue *aq) in ap_sm_read() argument
210 if (!aq->reply) in ap_sm_read()
212 status = ap_sm_recv(aq); in ap_sm_read()
215 if (aq->queue_count > 0) { in ap_sm_read()
216 aq->sm_state = AP_SM_STATE_WORKING; in ap_sm_read()
219 aq->sm_state = AP_SM_STATE_IDLE; in ap_sm_read()
222 if (aq->queue_count > 0) in ap_sm_read()
223 return aq->interrupt ? in ap_sm_read()
225 aq->sm_state = AP_SM_STATE_IDLE; in ap_sm_read()
228 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_read()
229 aq->last_err_rc = status.response_code; in ap_sm_read()
232 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_read()
243 static enum ap_sm_wait ap_sm_write(struct ap_queue *aq) in ap_sm_write() argument
247 ap_qid_t qid = aq->qid; in ap_sm_write()
249 if (aq->requestq_count <= 0) in ap_sm_write()
252 ap_msg = list_entry(aq->requestq.next, struct ap_message, list); in ap_sm_write()
265 aq->queue_count = max_t(int, 1, aq->queue_count + 1); in ap_sm_write()
266 if (aq->queue_count == 1) in ap_sm_write()
267 mod_timer(&aq->timeout, jiffies + aq->request_timeout); in ap_sm_write()
268 list_move_tail(&ap_msg->list, &aq->pendingq); in ap_sm_write()
269 aq->requestq_count--; in ap_sm_write()
270 aq->pendingq_count++; in ap_sm_write()
271 if (aq->queue_count < aq->card->queue_depth) { in ap_sm_write()
272 aq->sm_state = AP_SM_STATE_WORKING; in ap_sm_write()
277 aq->sm_state = AP_SM_STATE_QUEUE_FULL; in ap_sm_write()
278 return aq->interrupt ? in ap_sm_write()
281 aq->sm_state = AP_SM_STATE_RESET_WAIT; in ap_sm_write()
289 aq->requestq_count--; in ap_sm_write()
291 ap_msg->receive(aq, ap_msg, NULL); in ap_sm_write()
294 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_write()
295 aq->last_err_rc = status.response_code; in ap_sm_write()
298 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_write()
309 static enum ap_sm_wait ap_sm_read_write(struct ap_queue *aq) in ap_sm_read_write() argument
311 return min(ap_sm_read(aq), ap_sm_write(aq)); in ap_sm_read_write()
320 static enum ap_sm_wait ap_sm_reset(struct ap_queue *aq) in ap_sm_reset() argument
324 status = ap_rapq(aq->qid); in ap_sm_reset()
328 aq->sm_state = AP_SM_STATE_RESET_WAIT; in ap_sm_reset()
329 aq->interrupt = false; in ap_sm_reset()
332 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_reset()
333 aq->last_err_rc = status.response_code; in ap_sm_reset()
336 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_reset()
347 static enum ap_sm_wait ap_sm_reset_wait(struct ap_queue *aq) in ap_sm_reset_wait() argument
352 if (aq->queue_count > 0 && aq->reply) in ap_sm_reset_wait()
354 status = ap_sm_recv(aq); in ap_sm_reset_wait()
357 status = ap_tapq(aq->qid, NULL); in ap_sm_reset_wait()
362 if (lsi_ptr && ap_queue_enable_irq(aq, lsi_ptr) == 0) in ap_sm_reset_wait()
363 aq->sm_state = AP_SM_STATE_SETIRQ_WAIT; in ap_sm_reset_wait()
365 aq->sm_state = (aq->queue_count > 0) ? in ap_sm_reset_wait()
375 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_reset_wait()
376 aq->last_err_rc = status.response_code; in ap_sm_reset_wait()
379 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_reset_wait()
390 static enum ap_sm_wait ap_sm_setirq_wait(struct ap_queue *aq) in ap_sm_setirq_wait() argument
394 if (aq->queue_count > 0 && aq->reply) in ap_sm_setirq_wait()
396 status = ap_sm_recv(aq); in ap_sm_setirq_wait()
399 status = ap_tapq(aq->qid, NULL); in ap_sm_setirq_wait()
403 aq->interrupt = true; in ap_sm_setirq_wait()
404 aq->sm_state = (aq->queue_count > 0) ? in ap_sm_setirq_wait()
410 if (aq->queue_count > 0) in ap_sm_setirq_wait()
416 aq->dev_state = AP_DEV_STATE_ERROR; in ap_sm_setirq_wait()
417 aq->last_err_rc = status.response_code; in ap_sm_setirq_wait()
420 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in ap_sm_setirq_wait()
455 enum ap_sm_wait ap_sm_event(struct ap_queue *aq, enum ap_sm_event event) in ap_sm_event() argument
457 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in ap_sm_event()
458 return ap_jumptable[aq->sm_state][event](aq); in ap_sm_event()
463 enum ap_sm_wait ap_sm_event_loop(struct ap_queue *aq, enum ap_sm_event event) in ap_sm_event_loop() argument
467 while ((wait = ap_sm_event(aq, event)) == AP_SM_WAIT_AGAIN) in ap_sm_event_loop()
479 struct ap_queue *aq = to_ap_queue(dev); in request_count_show() local
483 spin_lock_bh(&aq->lock); in request_count_show()
484 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) { in request_count_show()
485 req_cnt = aq->total_request_count; in request_count_show()
488 spin_unlock_bh(&aq->lock); in request_count_show()
500 struct ap_queue *aq = to_ap_queue(dev); in request_count_store() local
502 spin_lock_bh(&aq->lock); in request_count_store()
503 aq->total_request_count = 0; in request_count_store()
504 spin_unlock_bh(&aq->lock); in request_count_store()
514 struct ap_queue *aq = to_ap_queue(dev); in requestq_count_show() local
517 spin_lock_bh(&aq->lock); in requestq_count_show()
518 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in requestq_count_show()
519 reqq_cnt = aq->requestq_count; in requestq_count_show()
520 spin_unlock_bh(&aq->lock); in requestq_count_show()
529 struct ap_queue *aq = to_ap_queue(dev); in pendingq_count_show() local
532 spin_lock_bh(&aq->lock); in pendingq_count_show()
533 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in pendingq_count_show()
534 penq_cnt = aq->pendingq_count; in pendingq_count_show()
535 spin_unlock_bh(&aq->lock); in pendingq_count_show()
544 struct ap_queue *aq = to_ap_queue(dev); in reset_show() local
547 spin_lock_bh(&aq->lock); in reset_show()
548 switch (aq->sm_state) { in reset_show()
560 spin_unlock_bh(&aq->lock); in reset_show()
568 struct ap_queue *aq = to_ap_queue(dev); in reset_store() local
570 spin_lock_bh(&aq->lock); in reset_store()
571 __ap_flush_queue(aq); in reset_store()
572 aq->sm_state = AP_SM_STATE_RESET_START; in reset_store()
573 ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); in reset_store()
574 spin_unlock_bh(&aq->lock); in reset_store()
577 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); in reset_store()
587 struct ap_queue *aq = to_ap_queue(dev); in interrupt_show() local
590 spin_lock_bh(&aq->lock); in interrupt_show()
591 if (aq->sm_state == AP_SM_STATE_SETIRQ_WAIT) in interrupt_show()
593 else if (aq->interrupt) in interrupt_show()
597 spin_unlock_bh(&aq->lock); in interrupt_show()
606 struct ap_queue *aq = to_ap_queue(dev); in config_show() local
609 spin_lock_bh(&aq->lock); in config_show()
610 rc = scnprintf(buf, PAGE_SIZE, "%d\n", aq->config ? 1 : 0); in config_show()
611 spin_unlock_bh(&aq->lock); in config_show()
621 struct ap_queue *aq = to_ap_queue(dev); in states_show() local
624 spin_lock_bh(&aq->lock); in states_show()
626 switch (aq->dev_state) { in states_show()
643 if (aq->dev_state) { in states_show()
644 switch (aq->sm_state) { in states_show()
674 spin_unlock_bh(&aq->lock); in states_show()
683 struct ap_queue *aq = to_ap_queue(dev); in last_err_rc_show() local
686 spin_lock_bh(&aq->lock); in last_err_rc_show()
687 rc = aq->last_err_rc; in last_err_rc_show()
688 spin_unlock_bh(&aq->lock); in last_err_rc_show()
754 struct ap_queue *aq = to_ap_queue(dev); in ap_queue_device_release() local
757 hash_del(&aq->hnode); in ap_queue_device_release()
760 kfree(aq); in ap_queue_device_release()
765 struct ap_queue *aq; in ap_queue_create() local
767 aq = kzalloc(sizeof(*aq), GFP_KERNEL); in ap_queue_create()
768 if (!aq) in ap_queue_create()
770 aq->ap_dev.device.release = ap_queue_device_release; in ap_queue_create()
771 aq->ap_dev.device.type = &ap_queue_type; in ap_queue_create()
772 aq->ap_dev.device_type = device_type; in ap_queue_create()
773 aq->qid = qid; in ap_queue_create()
774 aq->interrupt = false; in ap_queue_create()
775 spin_lock_init(&aq->lock); in ap_queue_create()
776 INIT_LIST_HEAD(&aq->pendingq); in ap_queue_create()
777 INIT_LIST_HEAD(&aq->requestq); in ap_queue_create()
778 timer_setup(&aq->timeout, ap_request_timeout, 0); in ap_queue_create()
780 return aq; in ap_queue_create()
783 void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *reply) in ap_queue_init_reply() argument
785 aq->reply = reply; in ap_queue_init_reply()
787 spin_lock_bh(&aq->lock); in ap_queue_init_reply()
788 ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); in ap_queue_init_reply()
789 spin_unlock_bh(&aq->lock); in ap_queue_init_reply()
798 int ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_queue_message() argument
805 spin_lock_bh(&aq->lock); in ap_queue_message()
808 if (aq->dev_state == AP_DEV_STATE_OPERATING) { in ap_queue_message()
809 list_add_tail(&ap_msg->list, &aq->requestq); in ap_queue_message()
810 aq->requestq_count++; in ap_queue_message()
811 aq->total_request_count++; in ap_queue_message()
812 atomic64_inc(&aq->card->total_request_count); in ap_queue_message()
817 ap_wait(ap_sm_event_loop(aq, AP_SM_EVENT_POLL)); in ap_queue_message()
819 spin_unlock_bh(&aq->lock); in ap_queue_message()
835 void ap_cancel_message(struct ap_queue *aq, struct ap_message *ap_msg) in ap_cancel_message() argument
839 spin_lock_bh(&aq->lock); in ap_cancel_message()
841 list_for_each_entry(tmp, &aq->pendingq, list) in ap_cancel_message()
843 aq->pendingq_count--; in ap_cancel_message()
846 aq->requestq_count--; in ap_cancel_message()
850 spin_unlock_bh(&aq->lock); in ap_cancel_message()
860 static void __ap_flush_queue(struct ap_queue *aq) in __ap_flush_queue() argument
864 list_for_each_entry_safe(ap_msg, next, &aq->pendingq, list) { in __ap_flush_queue()
866 aq->pendingq_count--; in __ap_flush_queue()
868 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
870 list_for_each_entry_safe(ap_msg, next, &aq->requestq, list) { in __ap_flush_queue()
872 aq->requestq_count--; in __ap_flush_queue()
874 ap_msg->receive(aq, ap_msg, NULL); in __ap_flush_queue()
876 aq->queue_count = 0; in __ap_flush_queue()
879 void ap_flush_queue(struct ap_queue *aq) in ap_flush_queue() argument
881 spin_lock_bh(&aq->lock); in ap_flush_queue()
882 __ap_flush_queue(aq); in ap_flush_queue()
883 spin_unlock_bh(&aq->lock); in ap_flush_queue()
887 void ap_queue_prepare_remove(struct ap_queue *aq) in ap_queue_prepare_remove() argument
889 spin_lock_bh(&aq->lock); in ap_queue_prepare_remove()
891 __ap_flush_queue(aq); in ap_queue_prepare_remove()
893 aq->dev_state = AP_DEV_STATE_SHUTDOWN; in ap_queue_prepare_remove()
894 spin_unlock_bh(&aq->lock); in ap_queue_prepare_remove()
895 del_timer_sync(&aq->timeout); in ap_queue_prepare_remove()
898 void ap_queue_remove(struct ap_queue *aq) in ap_queue_remove() argument
906 spin_lock_bh(&aq->lock); in ap_queue_remove()
907 ap_zapq(aq->qid); in ap_queue_remove()
908 aq->dev_state = AP_DEV_STATE_UNINITIATED; in ap_queue_remove()
909 spin_unlock_bh(&aq->lock); in ap_queue_remove()
912 void ap_queue_init_state(struct ap_queue *aq) in ap_queue_init_state() argument
914 spin_lock_bh(&aq->lock); in ap_queue_init_state()
915 aq->dev_state = AP_DEV_STATE_OPERATING; in ap_queue_init_state()
916 aq->sm_state = AP_SM_STATE_RESET_START; in ap_queue_init_state()
917 ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); in ap_queue_init_state()
918 spin_unlock_bh(&aq->lock); in ap_queue_init_state()