drivers/s390/crypto/ap_queue.c
Source file repositories/reference/linux-study-clean/drivers/s390/crypto/ap_queue.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/crypto/ap_queue.c- Extension
.c- Size
- 36585 bytes
- Lines
- 1393
- Domain
- Driver Families
- Bucket
- drivers/s390
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/init.hlinux/slab.hasm/facility.hasm/trace/ap.hap_bus.hap_debug.h
Detected Declarations
function ap_q_supported_in_sefunction ap_q_supports_bindfunction ap_q_supports_assocfunction ap_q_needs_bindfunction ap_queue_enable_irqfunction __ap_sendfunction ap_sm_nopfunction ap_sm_recvfunction list_for_each_entryfunction ap_sm_readfunction ap_sm_writefunction ap_sm_read_writefunction ap_sm_resetfunction ap_sm_reset_waitfunction ap_sm_setirq_waitfunction ap_sm_assoc_waitfunction ap_sm_eventfunction ap_sm_event_loopfunction request_count_showfunction request_count_storefunction requestq_count_showfunction pendingq_count_showfunction reset_showfunction reset_storefunction interrupt_showfunction config_showfunction chkstop_showfunction ap_functions_showfunction driver_override_showfunction driver_override_storefunction states_showfunction last_err_rc_showfunction se_bind_showfunction se_bind_storefunction se_associate_showfunction se_associate_storefunction ap_queue_device_releasefunction ap_queue_init_replyfunction ap_queue_messagefunction ap_queue_usablefunction ap_cancel_messagefunction list_for_each_entryfunction __ap_flush_queuefunction list_for_each_entry_safefunction ap_flush_queuefunction ap_queue_prepare_removefunction ap_queue_removefunction _ap_queue_init_state
Annotated Snippet
list_for_each_entry(ap_msg, &aq->pendingq, list) {
if (ap_msg->psmid != aq->reply->psmid)
continue;
list_del_init(&ap_msg->list);
aq->pendingq_count--;
if (parts > 1) {
ap_msg->rc = -EMSGSIZE;
ap_msg->receive(aq, ap_msg, NULL);
} else {
ap_msg->receive(aq, ap_msg, aq->reply);
}
found = true;
break;
}
if (!found) {
AP_DBF_WARN("%s unassociated reply psmid=0x%016lx on 0x%02x.%04x\n",
__func__, aq->reply->psmid,
AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid));
}
fallthrough;
case AP_RESPONSE_NO_PENDING_REPLY:
if (!status.queue_empty || aq->queue_count <= 0)
break;
/* The card shouldn't forget requests but who knows. */
aq->queue_count = 0;
list_splice_init(&aq->pendingq, &aq->requestq);
aq->requestq_count += aq->pendingq_count;
pr_debug("queue 0x%02x.%04x rescheduled %d reqs (new req %d)\n",
AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid),
aq->pendingq_count, aq->requestq_count);
aq->pendingq_count = 0;
break;
default:
break;
}
return status;
}
/**
* ap_sm_read(): Receive pending reply messages from an AP queue.
* @aq: pointer to the AP queue
*
* Returns AP_SM_WAIT_NONE, AP_SM_WAIT_AGAIN, or AP_SM_WAIT_INTERRUPT
*/
static enum ap_sm_wait ap_sm_read(struct ap_queue *aq)
{
struct ap_queue_status status;
if (!aq->reply)
return AP_SM_WAIT_NONE;
status = ap_sm_recv(aq);
if (status.async)
return AP_SM_WAIT_NONE;
switch (status.response_code) {
case AP_RESPONSE_NORMAL:
if (aq->queue_count > 0) {
aq->sm_state = AP_SM_STATE_WORKING;
return AP_SM_WAIT_AGAIN;
}
aq->sm_state = AP_SM_STATE_IDLE;
break;
case AP_RESPONSE_NO_PENDING_REPLY:
if (aq->queue_count > 0)
return status.irq_enabled ?
AP_SM_WAIT_INTERRUPT : AP_SM_WAIT_HIGH_TIMEOUT;
aq->sm_state = AP_SM_STATE_IDLE;
break;
default:
aq->dev_state = AP_DEV_STATE_ERROR;
aq->last_err_rc = status.response_code;
AP_DBF_WARN("%s RC 0x%02x on 0x%02x.%04x -> AP_DEV_STATE_ERROR\n",
__func__, status.response_code,
AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid));
return AP_SM_WAIT_NONE;
}
/* Check and maybe enable irq support (again) on this queue */
if (!status.irq_enabled && status.queue_empty) {
void *lsi_ptr = ap_airq_ptr();
if (lsi_ptr && ap_queue_enable_irq(aq, lsi_ptr) == 0) {
aq->sm_state = AP_SM_STATE_SETIRQ_WAIT;
return AP_SM_WAIT_AGAIN;
}
}
return AP_SM_WAIT_NONE;
}
/**
* ap_sm_write(): Send messages from the request queue to an AP queue.
* @aq: pointer to the AP queue
Annotation
- Immediate include surface: `linux/export.h`, `linux/init.h`, `linux/slab.h`, `asm/facility.h`, `asm/trace/ap.h`, `ap_bus.h`, `ap_debug.h`.
- Detected declarations: `function ap_q_supported_in_se`, `function ap_q_supports_bind`, `function ap_q_supports_assoc`, `function ap_q_needs_bind`, `function ap_queue_enable_irq`, `function __ap_send`, `function ap_sm_nop`, `function ap_sm_recv`, `function list_for_each_entry`, `function ap_sm_read`.
- Atlas domain: Driver Families / drivers/s390.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.