Skip to content

Commit a3540b4

Browse files
committed
drm/nouveau: uvmm: remove dedicated VM pointer from VMAs
VMAs can find their corresponding VM through their embedded struct drm_gpuva which already carries a pointer to a struct drm_gpuva_manager which the VM is based on. Hence, remove the struct nouveau_uvmm pointer from struct nouveau_uvma to save a couple of bytes per mapping. Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3cbc772 commit a3540b4

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

drivers/gpu/drm/nouveau/nouveau_uvmm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ nouveau_uvma_vmm_put(struct nouveau_uvma *uvma)
181181
u64 addr = uvma->va.va.addr;
182182
u64 range = uvma->va.va.range;
183183

184-
return nouveau_uvmm_vmm_put(uvma->uvmm, addr, range);
184+
return nouveau_uvmm_vmm_put(to_uvmm(uvma), addr, range);
185185
}
186186

187187
static int
@@ -192,7 +192,7 @@ nouveau_uvma_map(struct nouveau_uvma *uvma,
192192
u64 offset = uvma->va.gem.offset;
193193
u64 range = uvma->va.va.range;
194194

195-
return nouveau_uvmm_vmm_map(uvma->uvmm, addr, range,
195+
return nouveau_uvmm_vmm_map(to_uvmm(uvma), addr, range,
196196
offset, uvma->kind, mem);
197197
}
198198

@@ -206,7 +206,7 @@ nouveau_uvma_unmap(struct nouveau_uvma *uvma)
206206
if (drm_gpuva_invalidated(&uvma->va))
207207
return 0;
208208

209-
return nouveau_uvmm_vmm_unmap(uvma->uvmm, addr, range, sparse);
209+
return nouveau_uvmm_vmm_unmap(to_uvmm(uvma), addr, range, sparse);
210210
}
211211

212212
static int
@@ -586,7 +586,6 @@ op_map_prepare(struct nouveau_uvmm *uvmm,
586586
if (ret)
587587
return ret;
588588

589-
uvma->uvmm = uvmm;
590589
uvma->region = args->region;
591590
uvma->kind = args->kind;
592591

@@ -794,7 +793,7 @@ op_unmap_range(struct drm_gpuva_op_unmap *u,
794793
bool sparse = !!uvma->region;
795794

796795
if (!drm_gpuva_invalidated(u->va))
797-
nouveau_uvmm_vmm_unmap(uvma->uvmm, addr, range, sparse);
796+
nouveau_uvmm_vmm_unmap(to_uvmm(uvma), addr, range, sparse);
798797
}
799798

800799
static void

drivers/gpu/drm/nouveau/nouveau_uvmm.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ struct nouveau_uvma_region {
3737
struct nouveau_uvma {
3838
struct drm_gpuva va;
3939

40-
struct nouveau_uvmm *uvmm;
4140
struct nouveau_uvma_region *region;
42-
4341
u8 kind;
4442
};
4543

44+
#define uvmm_from_mgr(x) container_of((x), struct nouveau_uvmm, umgr)
45+
#define uvma_from_va(x) container_of((x), struct nouveau_uvma, va)
46+
47+
#define to_uvmm(x) uvmm_from_mgr((x)->va.mgr)
48+
4649
struct nouveau_uvmm_bind_job {
4750
struct nouveau_job base;
4851

@@ -79,9 +82,6 @@ struct nouveau_uvmm_bind_job_args {
7982

8083
#define to_uvmm_bind_job(job) container_of((job), struct nouveau_uvmm_bind_job, base)
8184

82-
#define uvmm_from_mgr(x) container_of((x), struct nouveau_uvmm, umgr)
83-
#define uvma_from_va(x) container_of((x), struct nouveau_uvma, va)
84-
8585
int nouveau_uvmm_init(struct nouveau_uvmm *uvmm, struct nouveau_cli *cli,
8686
u64 kernel_managed_addr, u64 kernel_managed_size);
8787
void nouveau_uvmm_fini(struct nouveau_uvmm *uvmm);

0 commit comments

Comments
 (0)