drivers/gpu/drm/nouveau/nouveau_svm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nouveau_svm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nouveau_svm.c- Extension
.c- Size
- 28731 bytes
- Lines
- 1088
- 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
nouveau_svm.hnouveau_drv.hnouveau_chan.hnouveau_dmem.hnvif/event.hnvif/object.hnvif/vmm.hnvif/class.hnvif/clb069.hnvif/ifc00d.hlinux/sched/mm.hlinux/sort.hlinux/hmm.hlinux/memremap.hlinux/rmap.h
Detected Declarations
struct nouveau_svmstruct nouveau_svm_fault_bufferstruct nouveau_svm_faultstruct nouveau_pfnmap_argsstruct nouveau_ivmmstruct svm_notifierfunction nouveau_ivmm_findfunction nouveau_svmm_bindfunction nouveau_svmm_partfunction nouveau_svmm_joinfunction nouveau_svmm_invalidatefunction nouveau_svmm_invalidate_range_startfunction nouveau_svmm_free_notifierfunction nouveau_svmm_finifunction nouveau_svmm_initfunction nouveau_svm_fault_replayfunction channelfunction nouveau_svm_fault_cancel_faultfunction nouveau_svm_fault_priorityfunction nouveau_svm_fault_cmpfunction nouveau_svm_fault_cachefunction nouveau_svm_range_invalidatefunction nouveau_hmm_convert_pfnfunction nvif_object_ioctlfunction consistentfunction nouveau_atomic_range_faultfunction nouveau_range_faultfunction nouveau_svm_faultfunction nouveau_svm_eventfunction nouveau_pfns_to_argsfunction nouveau_pfns_allocfunction nouveau_pfns_freefunction nouveau_pfns_mapfunction nouveau_svm_fault_buffer_finifunction nouveau_svm_fault_buffer_initfunction nouveau_svm_fault_buffer_dtorfunction nouveau_svm_fault_buffer_ctorfunction nouveau_svm_resumefunction nouveau_svm_suspendfunction nouveau_svm_finifunction nouveau_svm_init
Annotated Snippet
struct nouveau_svm {
struct nouveau_drm *drm;
struct mutex mutex;
struct list_head inst;
struct nouveau_svm_fault_buffer {
int id;
struct nvif_object object;
u32 entries;
u32 getaddr;
u32 putaddr;
u32 get;
u32 put;
struct nvif_event notify;
struct work_struct work;
struct nouveau_svm_fault {
u64 inst;
u64 addr;
u64 time;
u32 engine;
u8 gpc;
u8 hub;
u8 access;
u8 client;
u8 fault;
struct nouveau_svmm *svmm;
} **fault;
int fault_nr;
} buffer[];
};
#define FAULT_ACCESS_READ 0
#define FAULT_ACCESS_WRITE 1
#define FAULT_ACCESS_ATOMIC 2
#define FAULT_ACCESS_PREFETCH 3
#define SVM_DBG(s,f,a...) NV_DEBUG((s)->drm, "svm: "f"\n", ##a)
#define SVM_ERR(s,f,a...) NV_WARN((s)->drm, "svm: "f"\n", ##a)
struct nouveau_pfnmap_args {
struct nvif_ioctl_v0_hdr i;
struct nvif_ioctl_mthd_v0_hdr m;
struct nvif_vmm_pfnmap_v0 p;
};
struct nouveau_ivmm {
struct nouveau_svmm *svmm;
u64 inst;
struct list_head head;
};
static struct nouveau_ivmm *
nouveau_ivmm_find(struct nouveau_svm *svm, u64 inst)
{
struct nouveau_ivmm *ivmm;
list_for_each_entry(ivmm, &svm->inst, head) {
if (ivmm->inst == inst)
return ivmm;
}
return NULL;
}
#define SVMM_DBG(s,f,a...) \
NV_DEBUG((s)->vmm->cli->drm, "svm-%p: "f"\n", (s), ##a)
#define SVMM_ERR(s,f,a...) \
NV_WARN((s)->vmm->cli->drm, "svm-%p: "f"\n", (s), ##a)
int
nouveau_svmm_bind(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct nouveau_cli *cli = nouveau_cli(file_priv);
struct drm_nouveau_svm_bind *args = data;
unsigned target, cmd;
unsigned long addr, end;
struct mm_struct *mm;
args->va_start &= PAGE_MASK;
args->va_end = ALIGN(args->va_end, PAGE_SIZE);
/* Sanity check arguments */
if (args->reserved0 || args->reserved1)
return -EINVAL;
if (args->header & (~NOUVEAU_SVM_BIND_VALID_MASK))
return -EINVAL;
if (args->va_start >= args->va_end)
return -EINVAL;
cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT;
Annotation
- Immediate include surface: `nouveau_svm.h`, `nouveau_drv.h`, `nouveau_chan.h`, `nouveau_dmem.h`, `nvif/event.h`, `nvif/object.h`, `nvif/vmm.h`, `nvif/class.h`.
- Detected declarations: `struct nouveau_svm`, `struct nouveau_svm_fault_buffer`, `struct nouveau_svm_fault`, `struct nouveau_pfnmap_args`, `struct nouveau_ivmm`, `struct svm_notifier`, `function nouveau_ivmm_find`, `function nouveau_svmm_bind`, `function nouveau_svmm_part`, `function nouveau_svmm_join`.
- 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.