drivers/gpu/drm/xen/xen_drm_front_evtchnl.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/xen/xen_drm_front_evtchnl.c- Extension
.c- Size
- 8734 bytes
- Lines
- 366
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/errno.hlinux/irq.hdrm/drm_print.hxen/xenbus.hxen/events.hxen/grant_table.hxen_drm_front.hxen_drm_front_evtchnl.h
Detected Declarations
function Copyrightfunction evtchnl_interrupt_evtfunction evtchnl_freefunction evtchnl_allocfunction xen_drm_front_evtchnl_create_allfunction evtchnl_publishfunction xen_drm_front_evtchnl_publish_allfunction xen_drm_front_evtchnl_flushfunction xen_drm_front_evtchnl_set_statefunction xen_drm_front_evtchnl_free_all
Annotated Snippet
switch (resp->operation) {
case XENDISPL_OP_PG_FLIP:
case XENDISPL_OP_FB_ATTACH:
case XENDISPL_OP_FB_DETACH:
case XENDISPL_OP_DBUF_CREATE:
case XENDISPL_OP_DBUF_DESTROY:
case XENDISPL_OP_SET_CONFIG:
evtchnl->u.req.resp_status = resp->status;
complete(&evtchnl->u.req.completion);
break;
default:
DRM_ERROR("Operation %d is not supported\n",
resp->operation);
break;
}
}
evtchnl->u.req.ring.rsp_cons = i;
if (i != evtchnl->u.req.ring.req_prod_pvt) {
int more_to_do;
RING_FINAL_CHECK_FOR_RESPONSES(&evtchnl->u.req.ring,
more_to_do);
if (more_to_do)
goto again;
} else {
evtchnl->u.req.ring.sring->rsp_event = i + 1;
}
spin_unlock_irqrestore(&front_info->io_lock, flags);
return IRQ_HANDLED;
}
static irqreturn_t evtchnl_interrupt_evt(int irq, void *dev_id)
{
struct xen_drm_front_evtchnl *evtchnl = dev_id;
struct xen_drm_front_info *front_info = evtchnl->front_info;
struct xendispl_event_page *page = evtchnl->u.evt.page;
u32 cons, prod;
unsigned long flags;
if (unlikely(evtchnl->state != EVTCHNL_STATE_CONNECTED))
return IRQ_HANDLED;
spin_lock_irqsave(&front_info->io_lock, flags);
prod = page->in_prod;
/* ensure we see ring contents up to prod */
virt_rmb();
if (prod == page->in_cons)
goto out;
for (cons = page->in_cons; cons != prod; cons++) {
struct xendispl_evt *event;
event = &XENDISPL_IN_RING_REF(page, cons);
if (unlikely(event->id != evtchnl->evt_id++))
continue;
switch (event->type) {
case XENDISPL_EVT_PG_FLIP:
xen_drm_front_on_frame_done(front_info, evtchnl->index,
event->op.pg_flip.fb_cookie);
break;
}
}
page->in_cons = cons;
/* ensure ring contents */
virt_wmb();
out:
spin_unlock_irqrestore(&front_info->io_lock, flags);
return IRQ_HANDLED;
}
static void evtchnl_free(struct xen_drm_front_info *front_info,
struct xen_drm_front_evtchnl *evtchnl)
{
void *page = NULL;
if (evtchnl->type == EVTCHNL_TYPE_REQ)
page = evtchnl->u.req.ring.sring;
else if (evtchnl->type == EVTCHNL_TYPE_EVT)
page = evtchnl->u.evt.page;
if (!page)
return;
evtchnl->state = EVTCHNL_STATE_DISCONNECTED;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/irq.h`, `drm/drm_print.h`, `xen/xenbus.h`, `xen/events.h`, `xen/grant_table.h`, `xen_drm_front.h`, `xen_drm_front_evtchnl.h`.
- Detected declarations: `function Copyright`, `function evtchnl_interrupt_evt`, `function evtchnl_free`, `function evtchnl_alloc`, `function xen_drm_front_evtchnl_create_all`, `function evtchnl_publish`, `function xen_drm_front_evtchnl_publish_all`, `function xen_drm_front_evtchnl_flush`, `function xen_drm_front_evtchnl_set_state`, `function xen_drm_front_evtchnl_free_all`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.