drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/engine/fifo/uchan.c- Extension
.c- Size
- 10671 bytes
- Lines
- 419
- 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.
- 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
priv.hcgrp.hchan.hchid.hrunl.hcore/gpuobj.hcore/oproxy.hsubdev/mmu.hengine/dma.hnvif/if0020.h
Detected Declarations
struct nvkm_uchanstruct nvkm_uobjfunction nvkm_uchan_ueventfunction nvkm_uchan_object_fini_1function nvkm_uchan_object_init_0function nvkm_uchan_object_dtorfunction nvkm_uchan_object_newfunction nvkm_uchan_sclassfunction nvkm_runl_foreach_engnfunction nvkm_uchan_mapfunction nvkm_uchan_finifunction nvkm_uchan_initfunction nvkm_uchan_dtorfunction nvkm_uchan_chanfunction nvkm_uchan_new
Annotated Snippet
struct nvkm_uchan {
struct nvkm_object object;
struct nvkm_chan *chan;
};
static int
nvkm_uchan_uevent(struct nvkm_object *object, void *argv, u32 argc, struct nvkm_uevent *uevent)
{
struct nvkm_chan *chan = nvkm_uchan(object)->chan;
struct nvkm_runl *runl = chan->cgrp->runl;
union nvif_chan_event_args *args = argv;
if (!uevent)
return 0;
if (argc != sizeof(args->v0) || args->v0.version != 0)
return -ENOSYS;
switch (args->v0.type) {
case NVIF_CHAN_EVENT_V0_NON_STALL_INTR:
return nvkm_uevent_add(uevent, &runl->fifo->nonstall.event, runl->id,
NVKM_FIFO_NONSTALL_EVENT, NULL);
case NVIF_CHAN_EVENT_V0_KILLED:
return nvkm_uevent_add(uevent, &runl->chid->event, chan->id,
NVKM_CHAN_EVENT_ERRORED, NULL);
default:
break;
}
return -ENOSYS;
}
struct nvkm_uobj {
struct nvkm_oproxy oproxy;
struct nvkm_chan *chan;
struct nvkm_cctx *cctx;
int hash;
};
static int
nvkm_uchan_object_fini_1(struct nvkm_oproxy *oproxy, enum nvkm_suspend_state suspend)
{
struct nvkm_uobj *uobj = container_of(oproxy, typeof(*uobj), oproxy);
struct nvkm_chan *chan = uobj->chan;
struct nvkm_cctx *cctx = uobj->cctx;
struct nvkm_ectx *ectx = cctx->vctx->ectx;
if (!ectx->object)
return 0;
/* Unbind engine context from channel, if no longer required. */
if (refcount_dec_and_mutex_lock(&cctx->uses, &chan->cgrp->mutex)) {
nvkm_chan_cctx_bind(chan, ectx->engn, NULL);
if (refcount_dec_and_test(&ectx->uses))
nvkm_object_fini(ectx->object, NVKM_POWEROFF);
mutex_unlock(&chan->cgrp->mutex);
}
return 0;
}
static int
nvkm_uchan_object_init_0(struct nvkm_oproxy *oproxy)
{
struct nvkm_uobj *uobj = container_of(oproxy, typeof(*uobj), oproxy);
struct nvkm_chan *chan = uobj->chan;
struct nvkm_cctx *cctx = uobj->cctx;
struct nvkm_ectx *ectx = cctx->vctx->ectx;
int ret = 0;
if (!ectx->object)
return 0;
/* Bind engine context to channel, if it hasn't been already. */
if (!refcount_inc_not_zero(&cctx->uses)) {
mutex_lock(&chan->cgrp->mutex);
if (!refcount_inc_not_zero(&cctx->uses)) {
if (!refcount_inc_not_zero(&ectx->uses)) {
ret = nvkm_object_init(ectx->object);
if (ret == 0)
refcount_set(&ectx->uses, 1);
}
if (ret == 0) {
nvkm_chan_cctx_bind(chan, ectx->engn, cctx);
refcount_set(&cctx->uses, 1);
}
}
mutex_unlock(&chan->cgrp->mutex);
}
Annotation
- Immediate include surface: `priv.h`, `cgrp.h`, `chan.h`, `chid.h`, `runl.h`, `core/gpuobj.h`, `core/oproxy.h`, `subdev/mmu.h`.
- Detected declarations: `struct nvkm_uchan`, `struct nvkm_uobj`, `function nvkm_uchan_uevent`, `function nvkm_uchan_object_fini_1`, `function nvkm_uchan_object_init_0`, `function nvkm_uchan_object_dtor`, `function nvkm_uchan_object_new`, `function nvkm_uchan_sclass`, `function nvkm_runl_foreach_engn`, `function nvkm_uchan_map`.
- 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.
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.