sound/xen/xen_snd_front_evtchnl.c
Source file repositories/reference/linux-study-clean/sound/xen/xen_snd_front_evtchnl.c
File Facts
- System
- Linux kernel
- Corpus path
sound/xen/xen_snd_front_evtchnl.c- Extension
.c- Size
- 11931 bytes
- Lines
- 473
- Domain
- Driver Families
- Bucket
- sound/xen
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
xen/events.hxen/grant_table.hxen/xen.hxen/xenbus.hxen_snd_front.hxen_snd_front_alsa.hxen_snd_front_cfg.hxen_snd_front_evtchnl.h
Detected Declarations
function Copyrightfunction evtchnl_interrupt_evtfunction xen_snd_front_evtchnl_flushfunction evtchnl_freefunction xen_snd_front_evtchnl_free_allfunction evtchnl_allocfunction xen_snd_front_evtchnl_create_allfunction evtchnl_publishfunction xen_snd_front_evtchnl_publish_allfunction xen_snd_front_evtchnl_set_connectedfunction scoped_guardfunction xen_snd_front_evtchnl_pair_set_connectedfunction xen_snd_front_evtchnl_pair_clearfunction scoped_guard
Annotated Snippet
switch (resp->operation) {
case XENSND_OP_OPEN:
case XENSND_OP_CLOSE:
case XENSND_OP_READ:
case XENSND_OP_WRITE:
case XENSND_OP_TRIGGER:
channel->u.req.resp_status = resp->status;
complete(&channel->u.req.completion);
break;
case XENSND_OP_HW_PARAM_QUERY:
channel->u.req.resp_status = resp->status;
channel->u.req.resp.hw_param =
resp->resp.hw_param;
complete(&channel->u.req.completion);
break;
default:
dev_err(&front_info->xb_dev->dev,
"Operation %d is not supported\n",
resp->operation);
break;
}
}
channel->u.req.ring.rsp_cons = i;
if (i != channel->u.req.ring.req_prod_pvt) {
int more_to_do;
RING_FINAL_CHECK_FOR_RESPONSES(&channel->u.req.ring,
more_to_do);
if (more_to_do)
goto again;
} else {
channel->u.req.ring.sring->rsp_event = i + 1;
}
return IRQ_HANDLED;
}
static irqreturn_t evtchnl_interrupt_evt(int irq, void *dev_id)
{
struct xen_snd_front_evtchnl *channel = dev_id;
struct xensnd_event_page *page = channel->u.evt.page;
u32 cons, prod;
if (unlikely(channel->state != EVTCHNL_STATE_CONNECTED))
return IRQ_HANDLED;
guard(mutex)(&channel->ring_io_lock);
if (unlikely(channel->state != EVTCHNL_STATE_CONNECTED))
return IRQ_HANDLED;
prod = page->in_prod;
/* Ensure we see ring contents up to prod. */
virt_rmb();
if (prod == page->in_cons)
return IRQ_HANDLED;
/*
* Assume that the backend is trusted to always write sane values
* to the ring counters, so no overflow checks on frontend side
* are required.
*/
for (cons = page->in_cons; cons != prod; cons++) {
struct xensnd_evt *event;
event = &XENSND_IN_RING_REF(page, cons);
if (unlikely(event->id != channel->evt_id++))
continue;
switch (event->type) {
case XENSND_EVT_CUR_POS:
xen_snd_front_alsa_handle_cur_pos(channel,
event->op.cur_pos.position);
break;
}
}
page->in_cons = cons;
/* Ensure ring contents. */
virt_wmb();
return IRQ_HANDLED;
}
void xen_snd_front_evtchnl_flush(struct xen_snd_front_evtchnl *channel)
{
int notify;
Annotation
- Immediate include surface: `xen/events.h`, `xen/grant_table.h`, `xen/xen.h`, `xen/xenbus.h`, `xen_snd_front.h`, `xen_snd_front_alsa.h`, `xen_snd_front_cfg.h`, `xen_snd_front_evtchnl.h`.
- Detected declarations: `function Copyright`, `function evtchnl_interrupt_evt`, `function xen_snd_front_evtchnl_flush`, `function evtchnl_free`, `function xen_snd_front_evtchnl_free_all`, `function evtchnl_alloc`, `function xen_snd_front_evtchnl_create_all`, `function evtchnl_publish`, `function xen_snd_front_evtchnl_publish_all`, `function xen_snd_front_evtchnl_set_connected`.
- Atlas domain: Driver Families / sound/xen.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.