2 * Copyright IBM Corp. 2016
3 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 * Adjunct processor bus, queue related code.
8 #define KMSG_COMPONENT "ap"
9 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 #include <linux/init.h>
12 #include <linux/slab.h>
13 #include <asm/facility.h>
19 * ap_queue_irq_ctrl(): Control interruption on a AP queue.
20 * @qirqctrl: struct ap_qirq_ctrl (64 bit value)
21 * @ind: The notification indicator byte
23 * Returns AP queue status.
25 * Control interruption on the given AP queue.
26 * Just a simple wrapper function for the low level PQAP(AQIC)
27 * instruction available for other kernel modules.
29 struct ap_queue_status
ap_queue_irq_ctrl(ap_qid_t qid
,
30 struct ap_qirq_ctrl qirqctrl
,
33 return ap_aqic(qid
, qirqctrl
, ind
);
35 EXPORT_SYMBOL(ap_queue_irq_ctrl
);
38 * ap_queue_enable_interruption(): Enable interruption on an AP queue.
39 * @qid: The AP queue number
40 * @ind: the notification indicator byte
42 * Enables interruption on AP queue via ap_aqic(). Based on the return
43 * value it waits a while and tests the AP queue if interrupts
44 * have been switched on using ap_test_queue().
46 static int ap_queue_enable_interruption(struct ap_queue
*aq
, void *ind
)
48 struct ap_queue_status status
;
49 struct ap_qirq_ctrl qirqctrl
= { 0 };
52 qirqctrl
.isc
= AP_ISC
;
53 status
= ap_aqic(aq
->qid
, qirqctrl
, ind
);
54 switch (status
.response_code
) {
55 case AP_RESPONSE_NORMAL
:
56 case AP_RESPONSE_OTHERWISE_CHANGED
:
58 case AP_RESPONSE_Q_NOT_AVAIL
:
59 case AP_RESPONSE_DECONFIGURED
:
60 case AP_RESPONSE_CHECKSTOPPED
:
61 case AP_RESPONSE_INVALID_ADDRESS
:
62 pr_err("Registering adapter interrupts for AP device %02x.%04x failed\n",
64 AP_QID_QUEUE(aq
->qid
));
66 case AP_RESPONSE_RESET_IN_PROGRESS
:
67 case AP_RESPONSE_BUSY
:
74 * __ap_send(): Send message to adjunct processor queue.
75 * @qid: The AP queue number
76 * @psmid: The program supplied message identifier
77 * @msg: The message text
78 * @length: The message length
79 * @special: Special Bit
81 * Returns AP queue status structure.
82 * Condition code 1 on NQAP can't happen because the L bit is 1.
83 * Condition code 2 on NQAP also means the send is incomplete,
84 * because a segment boundary was reached. The NQAP is repeated.
86 static inline struct ap_queue_status
87 __ap_send(ap_qid_t qid
, unsigned long long psmid
, void *msg
, size_t length
,
92 return ap_nqap(qid
, psmid
, msg
, length
);
95 int ap_send(ap_qid_t qid
, unsigned long long psmid
, void *msg
, size_t length
)
97 struct ap_queue_status status
;
99 status
= __ap_send(qid
, psmid
, msg
, length
, 0);
100 switch (status
.response_code
) {
101 case AP_RESPONSE_NORMAL
:
103 case AP_RESPONSE_Q_FULL
:
104 case AP_RESPONSE_RESET_IN_PROGRESS
:
106 case AP_RESPONSE_REQ_FAC_NOT_INST
:
108 default: /* Device is gone. */
112 EXPORT_SYMBOL(ap_send
);
114 int ap_recv(ap_qid_t qid
, unsigned long long *psmid
, void *msg
, size_t length
)
116 struct ap_queue_status status
;
120 status
= ap_dqap(qid
, psmid
, msg
, length
);
121 switch (status
.response_code
) {
122 case AP_RESPONSE_NORMAL
:
124 case AP_RESPONSE_NO_PENDING_REPLY
:
125 if (status
.queue_empty
)
128 case AP_RESPONSE_RESET_IN_PROGRESS
:
134 EXPORT_SYMBOL(ap_recv
);
136 /* State machine definitions and helpers */
138 static enum ap_wait
ap_sm_nop(struct ap_queue
*aq
)
144 * ap_sm_recv(): Receive pending reply messages from an AP queue but do
145 * not change the state of the device.
146 * @aq: pointer to the AP queue
148 * Returns AP_WAIT_NONE, AP_WAIT_AGAIN, or AP_WAIT_INTERRUPT
150 static struct ap_queue_status
ap_sm_recv(struct ap_queue
*aq
)
152 struct ap_queue_status status
;
153 struct ap_message
*ap_msg
;
155 status
= ap_dqap(aq
->qid
, &aq
->reply
->psmid
,
156 aq
->reply
->message
, aq
->reply
->length
);
157 switch (status
.response_code
) {
158 case AP_RESPONSE_NORMAL
:
160 if (aq
->queue_count
> 0)
161 mod_timer(&aq
->timeout
,
162 jiffies
+ aq
->request_timeout
);
163 list_for_each_entry(ap_msg
, &aq
->pendingq
, list
) {
164 if (ap_msg
->psmid
!= aq
->reply
->psmid
)
166 list_del_init(&ap_msg
->list
);
167 aq
->pendingq_count
--;
168 ap_msg
->receive(aq
, ap_msg
, aq
->reply
);
171 case AP_RESPONSE_NO_PENDING_REPLY
:
172 if (!status
.queue_empty
|| aq
->queue_count
<= 0)
174 /* The card shouldn't forget requests but who knows. */
176 list_splice_init(&aq
->pendingq
, &aq
->requestq
);
177 aq
->requestq_count
+= aq
->pendingq_count
;
178 aq
->pendingq_count
= 0;
187 * ap_sm_read(): Receive pending reply messages from an AP queue.
188 * @aq: pointer to the AP queue
190 * Returns AP_WAIT_NONE, AP_WAIT_AGAIN, or AP_WAIT_INTERRUPT
192 static enum ap_wait
ap_sm_read(struct ap_queue
*aq
)
194 struct ap_queue_status status
;
198 status
= ap_sm_recv(aq
);
199 switch (status
.response_code
) {
200 case AP_RESPONSE_NORMAL
:
201 if (aq
->queue_count
> 0) {
202 aq
->state
= AP_STATE_WORKING
;
203 return AP_WAIT_AGAIN
;
205 aq
->state
= AP_STATE_IDLE
;
207 case AP_RESPONSE_NO_PENDING_REPLY
:
208 if (aq
->queue_count
> 0)
209 return AP_WAIT_INTERRUPT
;
210 aq
->state
= AP_STATE_IDLE
;
213 aq
->state
= AP_STATE_BORKED
;
219 * ap_sm_suspend_read(): Receive pending reply messages from an AP queue
220 * without changing the device state in between. In suspend mode we don't
221 * allow sending new requests, therefore just fetch pending replies.
222 * @aq: pointer to the AP queue
224 * Returns AP_WAIT_NONE or AP_WAIT_AGAIN
226 static enum ap_wait
ap_sm_suspend_read(struct ap_queue
*aq
)
228 struct ap_queue_status status
;
232 status
= ap_sm_recv(aq
);
233 switch (status
.response_code
) {
234 case AP_RESPONSE_NORMAL
:
235 if (aq
->queue_count
> 0)
236 return AP_WAIT_AGAIN
;
244 * ap_sm_write(): Send messages from the request queue to an AP queue.
245 * @aq: pointer to the AP queue
247 * Returns AP_WAIT_NONE, AP_WAIT_AGAIN, or AP_WAIT_INTERRUPT
249 static enum ap_wait
ap_sm_write(struct ap_queue
*aq
)
251 struct ap_queue_status status
;
252 struct ap_message
*ap_msg
;
254 if (aq
->requestq_count
<= 0)
256 /* Start the next request on the queue. */
257 ap_msg
= list_entry(aq
->requestq
.next
, struct ap_message
, list
);
258 status
= __ap_send(aq
->qid
, ap_msg
->psmid
,
259 ap_msg
->message
, ap_msg
->length
, ap_msg
->special
);
260 switch (status
.response_code
) {
261 case AP_RESPONSE_NORMAL
:
263 if (aq
->queue_count
== 1)
264 mod_timer(&aq
->timeout
, jiffies
+ aq
->request_timeout
);
265 list_move_tail(&ap_msg
->list
, &aq
->pendingq
);
266 aq
->requestq_count
--;
267 aq
->pendingq_count
++;
268 if (aq
->queue_count
< aq
->card
->queue_depth
) {
269 aq
->state
= AP_STATE_WORKING
;
270 return AP_WAIT_AGAIN
;
273 case AP_RESPONSE_Q_FULL
:
274 aq
->state
= AP_STATE_QUEUE_FULL
;
275 return AP_WAIT_INTERRUPT
;
276 case AP_RESPONSE_RESET_IN_PROGRESS
:
277 aq
->state
= AP_STATE_RESET_WAIT
;
278 return AP_WAIT_TIMEOUT
;
279 case AP_RESPONSE_MESSAGE_TOO_BIG
:
280 case AP_RESPONSE_REQ_FAC_NOT_INST
:
281 list_del_init(&ap_msg
->list
);
282 aq
->requestq_count
--;
283 ap_msg
->rc
= -EINVAL
;
284 ap_msg
->receive(aq
, ap_msg
, NULL
);
285 return AP_WAIT_AGAIN
;
287 aq
->state
= AP_STATE_BORKED
;
293 * ap_sm_read_write(): Send and receive messages to/from an AP queue.
294 * @aq: pointer to the AP queue
296 * Returns AP_WAIT_NONE, AP_WAIT_AGAIN, or AP_WAIT_INTERRUPT
298 static enum ap_wait
ap_sm_read_write(struct ap_queue
*aq
)
300 return min(ap_sm_read(aq
), ap_sm_write(aq
));
304 * ap_sm_reset(): Reset an AP queue.
305 * @qid: The AP queue number
307 * Submit the Reset command to an AP queue.
309 static enum ap_wait
ap_sm_reset(struct ap_queue
*aq
)
311 struct ap_queue_status status
;
313 status
= ap_rapq(aq
->qid
);
314 switch (status
.response_code
) {
315 case AP_RESPONSE_NORMAL
:
316 case AP_RESPONSE_RESET_IN_PROGRESS
:
317 aq
->state
= AP_STATE_RESET_WAIT
;
318 aq
->interrupt
= AP_INTR_DISABLED
;
319 return AP_WAIT_TIMEOUT
;
320 case AP_RESPONSE_BUSY
:
321 return AP_WAIT_TIMEOUT
;
322 case AP_RESPONSE_Q_NOT_AVAIL
:
323 case AP_RESPONSE_DECONFIGURED
:
324 case AP_RESPONSE_CHECKSTOPPED
:
326 aq
->state
= AP_STATE_BORKED
;
332 * ap_sm_reset_wait(): Test queue for completion of the reset operation
333 * @aq: pointer to the AP queue
335 * Returns AP_POLL_IMMEDIATELY, AP_POLL_AFTER_TIMEROUT or 0.
337 static enum ap_wait
ap_sm_reset_wait(struct ap_queue
*aq
)
339 struct ap_queue_status status
;
342 if (aq
->queue_count
> 0 && aq
->reply
)
343 /* Try to read a completed message and get the status */
344 status
= ap_sm_recv(aq
);
346 /* Get the status with TAPQ */
347 status
= ap_tapq(aq
->qid
, NULL
);
349 switch (status
.response_code
) {
350 case AP_RESPONSE_NORMAL
:
351 lsi_ptr
= ap_airq_ptr();
352 if (lsi_ptr
&& ap_queue_enable_interruption(aq
, lsi_ptr
) == 0)
353 aq
->state
= AP_STATE_SETIRQ_WAIT
;
355 aq
->state
= (aq
->queue_count
> 0) ?
356 AP_STATE_WORKING
: AP_STATE_IDLE
;
357 return AP_WAIT_AGAIN
;
358 case AP_RESPONSE_BUSY
:
359 case AP_RESPONSE_RESET_IN_PROGRESS
:
360 return AP_WAIT_TIMEOUT
;
361 case AP_RESPONSE_Q_NOT_AVAIL
:
362 case AP_RESPONSE_DECONFIGURED
:
363 case AP_RESPONSE_CHECKSTOPPED
:
365 aq
->state
= AP_STATE_BORKED
;
371 * ap_sm_setirq_wait(): Test queue for completion of the irq enablement
372 * @aq: pointer to the AP queue
374 * Returns AP_POLL_IMMEDIATELY, AP_POLL_AFTER_TIMEROUT or 0.
376 static enum ap_wait
ap_sm_setirq_wait(struct ap_queue
*aq
)
378 struct ap_queue_status status
;
380 if (aq
->queue_count
> 0 && aq
->reply
)
381 /* Try to read a completed message and get the status */
382 status
= ap_sm_recv(aq
);
384 /* Get the status with TAPQ */
385 status
= ap_tapq(aq
->qid
, NULL
);
387 if (status
.irq_enabled
== 1) {
388 /* Irqs are now enabled */
389 aq
->interrupt
= AP_INTR_ENABLED
;
390 aq
->state
= (aq
->queue_count
> 0) ?
391 AP_STATE_WORKING
: AP_STATE_IDLE
;
394 switch (status
.response_code
) {
395 case AP_RESPONSE_NORMAL
:
396 if (aq
->queue_count
> 0)
397 return AP_WAIT_AGAIN
;
399 case AP_RESPONSE_NO_PENDING_REPLY
:
400 return AP_WAIT_TIMEOUT
;
402 aq
->state
= AP_STATE_BORKED
;
408 * AP state machine jump table
410 static ap_func_t
*ap_jumptable
[NR_AP_STATES
][NR_AP_EVENTS
] = {
411 [AP_STATE_RESET_START
] = {
412 [AP_EVENT_POLL
] = ap_sm_reset
,
413 [AP_EVENT_TIMEOUT
] = ap_sm_nop
,
415 [AP_STATE_RESET_WAIT
] = {
416 [AP_EVENT_POLL
] = ap_sm_reset_wait
,
417 [AP_EVENT_TIMEOUT
] = ap_sm_nop
,
419 [AP_STATE_SETIRQ_WAIT
] = {
420 [AP_EVENT_POLL
] = ap_sm_setirq_wait
,
421 [AP_EVENT_TIMEOUT
] = ap_sm_nop
,
424 [AP_EVENT_POLL
] = ap_sm_write
,
425 [AP_EVENT_TIMEOUT
] = ap_sm_nop
,
427 [AP_STATE_WORKING
] = {
428 [AP_EVENT_POLL
] = ap_sm_read_write
,
429 [AP_EVENT_TIMEOUT
] = ap_sm_reset
,
431 [AP_STATE_QUEUE_FULL
] = {
432 [AP_EVENT_POLL
] = ap_sm_read
,
433 [AP_EVENT_TIMEOUT
] = ap_sm_reset
,
435 [AP_STATE_SUSPEND_WAIT
] = {
436 [AP_EVENT_POLL
] = ap_sm_suspend_read
,
437 [AP_EVENT_TIMEOUT
] = ap_sm_nop
,
439 [AP_STATE_BORKED
] = {
440 [AP_EVENT_POLL
] = ap_sm_nop
,
441 [AP_EVENT_TIMEOUT
] = ap_sm_nop
,
445 enum ap_wait
ap_sm_event(struct ap_queue
*aq
, enum ap_event event
)
447 return ap_jumptable
[aq
->state
][event
](aq
);
450 enum ap_wait
ap_sm_event_loop(struct ap_queue
*aq
, enum ap_event event
)
454 while ((wait
= ap_sm_event(aq
, event
)) == AP_WAIT_AGAIN
)
460 * Power management for queue devices
462 void ap_queue_suspend(struct ap_device
*ap_dev
)
464 struct ap_queue
*aq
= to_ap_queue(&ap_dev
->device
);
466 /* Poll on the device until all requests are finished. */
467 spin_lock_bh(&aq
->lock
);
468 aq
->state
= AP_STATE_SUSPEND_WAIT
;
469 while (ap_sm_event(aq
, AP_EVENT_POLL
) != AP_WAIT_NONE
)
471 aq
->state
= AP_STATE_BORKED
;
472 spin_unlock_bh(&aq
->lock
);
474 EXPORT_SYMBOL(ap_queue_suspend
);
476 void ap_queue_resume(struct ap_device
*ap_dev
)
479 EXPORT_SYMBOL(ap_queue_resume
);
482 * AP queue related attributes.
484 static ssize_t
ap_req_count_show(struct device
*dev
,
485 struct device_attribute
*attr
,
488 struct ap_queue
*aq
= to_ap_queue(dev
);
489 unsigned int req_cnt
;
491 spin_lock_bh(&aq
->lock
);
492 req_cnt
= aq
->total_request_count
;
493 spin_unlock_bh(&aq
->lock
);
494 return snprintf(buf
, PAGE_SIZE
, "%d\n", req_cnt
);
497 static ssize_t
ap_req_count_store(struct device
*dev
,
498 struct device_attribute
*attr
,
499 const char *buf
, size_t count
)
501 struct ap_queue
*aq
= to_ap_queue(dev
);
503 spin_lock_bh(&aq
->lock
);
504 aq
->total_request_count
= 0;
505 spin_unlock_bh(&aq
->lock
);
510 static DEVICE_ATTR(request_count
, 0644, ap_req_count_show
, ap_req_count_store
);
512 static ssize_t
ap_requestq_count_show(struct device
*dev
,
513 struct device_attribute
*attr
, char *buf
)
515 struct ap_queue
*aq
= to_ap_queue(dev
);
516 unsigned int reqq_cnt
= 0;
518 spin_lock_bh(&aq
->lock
);
519 reqq_cnt
= aq
->requestq_count
;
520 spin_unlock_bh(&aq
->lock
);
521 return snprintf(buf
, PAGE_SIZE
, "%d\n", reqq_cnt
);
524 static DEVICE_ATTR(requestq_count
, 0444, ap_requestq_count_show
, NULL
);
526 static ssize_t
ap_pendingq_count_show(struct device
*dev
,
527 struct device_attribute
*attr
, char *buf
)
529 struct ap_queue
*aq
= to_ap_queue(dev
);
530 unsigned int penq_cnt
= 0;
532 spin_lock_bh(&aq
->lock
);
533 penq_cnt
= aq
->pendingq_count
;
534 spin_unlock_bh(&aq
->lock
);
535 return snprintf(buf
, PAGE_SIZE
, "%d\n", penq_cnt
);
538 static DEVICE_ATTR(pendingq_count
, 0444, ap_pendingq_count_show
, NULL
);
540 static ssize_t
ap_reset_show(struct device
*dev
,
541 struct device_attribute
*attr
, char *buf
)
543 struct ap_queue
*aq
= to_ap_queue(dev
);
546 spin_lock_bh(&aq
->lock
);
548 case AP_STATE_RESET_START
:
549 case AP_STATE_RESET_WAIT
:
550 rc
= snprintf(buf
, PAGE_SIZE
, "Reset in progress.\n");
552 case AP_STATE_WORKING
:
553 case AP_STATE_QUEUE_FULL
:
554 rc
= snprintf(buf
, PAGE_SIZE
, "Reset Timer armed.\n");
557 rc
= snprintf(buf
, PAGE_SIZE
, "No Reset Timer set.\n");
559 spin_unlock_bh(&aq
->lock
);
563 static DEVICE_ATTR(reset
, 0444, ap_reset_show
, NULL
);
565 static ssize_t
ap_interrupt_show(struct device
*dev
,
566 struct device_attribute
*attr
, char *buf
)
568 struct ap_queue
*aq
= to_ap_queue(dev
);
571 spin_lock_bh(&aq
->lock
);
572 if (aq
->state
== AP_STATE_SETIRQ_WAIT
)
573 rc
= snprintf(buf
, PAGE_SIZE
, "Enable Interrupt pending.\n");
574 else if (aq
->interrupt
== AP_INTR_ENABLED
)
575 rc
= snprintf(buf
, PAGE_SIZE
, "Interrupts enabled.\n");
577 rc
= snprintf(buf
, PAGE_SIZE
, "Interrupts disabled.\n");
578 spin_unlock_bh(&aq
->lock
);
582 static DEVICE_ATTR(interrupt
, 0444, ap_interrupt_show
, NULL
);
584 static struct attribute
*ap_queue_dev_attrs
[] = {
585 &dev_attr_request_count
.attr
,
586 &dev_attr_requestq_count
.attr
,
587 &dev_attr_pendingq_count
.attr
,
588 &dev_attr_reset
.attr
,
589 &dev_attr_interrupt
.attr
,
593 static struct attribute_group ap_queue_dev_attr_group
= {
594 .attrs
= ap_queue_dev_attrs
597 static const struct attribute_group
*ap_queue_dev_attr_groups
[] = {
598 &ap_queue_dev_attr_group
,
602 static struct device_type ap_queue_type
= {
604 .groups
= ap_queue_dev_attr_groups
,
607 static void ap_queue_device_release(struct device
*dev
)
609 struct ap_queue
*aq
= to_ap_queue(dev
);
611 if (!list_empty(&aq
->list
)) {
612 spin_lock_bh(&ap_list_lock
);
613 list_del_init(&aq
->list
);
614 spin_unlock_bh(&ap_list_lock
);
619 struct ap_queue
*ap_queue_create(ap_qid_t qid
, int device_type
)
623 aq
= kzalloc(sizeof(*aq
), GFP_KERNEL
);
626 aq
->ap_dev
.device
.release
= ap_queue_device_release
;
627 aq
->ap_dev
.device
.type
= &ap_queue_type
;
628 aq
->ap_dev
.device_type
= device_type
;
629 /* CEX6 toleration: map to CEX5 */
630 if (device_type
== AP_DEVICE_TYPE_CEX6
)
631 aq
->ap_dev
.device_type
= AP_DEVICE_TYPE_CEX5
;
633 aq
->state
= AP_STATE_RESET_START
;
634 aq
->interrupt
= AP_INTR_DISABLED
;
635 spin_lock_init(&aq
->lock
);
636 INIT_LIST_HEAD(&aq
->pendingq
);
637 INIT_LIST_HEAD(&aq
->requestq
);
638 setup_timer(&aq
->timeout
, ap_request_timeout
, (unsigned long) aq
);
643 void ap_queue_init_reply(struct ap_queue
*aq
, struct ap_message
*reply
)
647 spin_lock_bh(&aq
->lock
);
648 ap_wait(ap_sm_event(aq
, AP_EVENT_POLL
));
649 spin_unlock_bh(&aq
->lock
);
651 EXPORT_SYMBOL(ap_queue_init_reply
);
654 * ap_queue_message(): Queue a request to an AP device.
655 * @aq: The AP device to queue the message to
656 * @ap_msg: The message that is to be added
658 void ap_queue_message(struct ap_queue
*aq
, struct ap_message
*ap_msg
)
660 /* For asynchronous message handling a valid receive-callback
663 BUG_ON(!ap_msg
->receive
);
665 spin_lock_bh(&aq
->lock
);
666 /* Queue the message. */
667 list_add_tail(&ap_msg
->list
, &aq
->requestq
);
668 aq
->requestq_count
++;
669 aq
->total_request_count
++;
670 atomic_inc(&aq
->card
->total_request_count
);
671 /* Send/receive as many request from the queue as possible. */
672 ap_wait(ap_sm_event_loop(aq
, AP_EVENT_POLL
));
673 spin_unlock_bh(&aq
->lock
);
675 EXPORT_SYMBOL(ap_queue_message
);
678 * ap_cancel_message(): Cancel a crypto request.
679 * @aq: The AP device that has the message queued
680 * @ap_msg: The message that is to be removed
682 * Cancel a crypto request. This is done by removing the request
683 * from the device pending or request queue. Note that the
684 * request stays on the AP queue. When it finishes the message
685 * reply will be discarded because the psmid can't be found.
687 void ap_cancel_message(struct ap_queue
*aq
, struct ap_message
*ap_msg
)
689 struct ap_message
*tmp
;
691 spin_lock_bh(&aq
->lock
);
692 if (!list_empty(&ap_msg
->list
)) {
693 list_for_each_entry(tmp
, &aq
->pendingq
, list
)
694 if (tmp
->psmid
== ap_msg
->psmid
) {
695 aq
->pendingq_count
--;
698 aq
->requestq_count
--;
700 list_del_init(&ap_msg
->list
);
702 spin_unlock_bh(&aq
->lock
);
704 EXPORT_SYMBOL(ap_cancel_message
);
707 * __ap_flush_queue(): Flush requests.
708 * @aq: Pointer to the AP queue
710 * Flush all requests from the request/pending queue of an AP device.
712 static void __ap_flush_queue(struct ap_queue
*aq
)
714 struct ap_message
*ap_msg
, *next
;
716 list_for_each_entry_safe(ap_msg
, next
, &aq
->pendingq
, list
) {
717 list_del_init(&ap_msg
->list
);
718 aq
->pendingq_count
--;
719 ap_msg
->rc
= -EAGAIN
;
720 ap_msg
->receive(aq
, ap_msg
, NULL
);
722 list_for_each_entry_safe(ap_msg
, next
, &aq
->requestq
, list
) {
723 list_del_init(&ap_msg
->list
);
724 aq
->requestq_count
--;
725 ap_msg
->rc
= -EAGAIN
;
726 ap_msg
->receive(aq
, ap_msg
, NULL
);
730 void ap_flush_queue(struct ap_queue
*aq
)
732 spin_lock_bh(&aq
->lock
);
733 __ap_flush_queue(aq
);
734 spin_unlock_bh(&aq
->lock
);
736 EXPORT_SYMBOL(ap_flush_queue
);
738 void ap_queue_remove(struct ap_queue
*aq
)
741 del_timer_sync(&aq
->timeout
);
743 EXPORT_SYMBOL(ap_queue_remove
);