99 lines · c
1/* SPDX-License-Identifier: MIT */2 3#ifndef __NOUVEAU_UVMM_H__4#define __NOUVEAU_UVMM_H__5 6#include <drm/drm_gpuvm.h>7 8#include "nouveau_drv.h"9 10struct nouveau_uvmm {11 struct drm_gpuvm base;12 struct nouveau_vmm vmm;13 struct maple_tree region_mt;14 struct mutex mutex;15};16 17struct nouveau_uvma_region {18 struct nouveau_uvmm *uvmm;19 20 struct {21 u64 addr;22 u64 range;23 } va;24 25 struct kref kref;26 27 struct completion complete;28 bool dirty;29};30 31struct nouveau_uvma {32 struct drm_gpuva va;33 34 struct nouveau_uvma_region *region;35 u8 kind;36};37 38#define uvmm_from_gpuvm(x) container_of((x), struct nouveau_uvmm, base)39#define uvma_from_va(x) container_of((x), struct nouveau_uvma, va)40 41#define to_uvmm(x) uvmm_from_gpuvm((x)->va.vm)42 43struct nouveau_uvmm_bind_job {44 struct nouveau_job base;45 46 struct kref kref;47 struct completion complete;48 49 /* struct bind_job_op */50 struct list_head ops;51};52 53struct nouveau_uvmm_bind_job_args {54 struct drm_file *file_priv;55 struct nouveau_sched *sched;56 57 unsigned int flags;58 59 struct {60 struct drm_nouveau_sync *s;61 u32 count;62 } in_sync;63 64 struct {65 struct drm_nouveau_sync *s;66 u32 count;67 } out_sync;68 69 struct {70 struct drm_nouveau_vm_bind_op *s;71 u32 count;72 } op;73};74 75#define to_uvmm_bind_job(job) container_of((job), struct nouveau_uvmm_bind_job, base)76 77void nouveau_uvmm_fini(struct nouveau_uvmm *uvmm);78 79void nouveau_uvmm_bo_map_all(struct nouveau_bo *nvbov, struct nouveau_mem *mem);80void nouveau_uvmm_bo_unmap_all(struct nouveau_bo *nvbo);81 82int nouveau_uvmm_ioctl_vm_init(struct drm_device *dev, void *data,83 struct drm_file *file_priv);84 85int nouveau_uvmm_ioctl_vm_bind(struct drm_device *dev, void *data,86 struct drm_file *file_priv);87 88static inline void nouveau_uvmm_lock(struct nouveau_uvmm *uvmm)89{90 mutex_lock(&uvmm->mutex);91}92 93static inline void nouveau_uvmm_unlock(struct nouveau_uvmm *uvmm)94{95 mutex_unlock(&uvmm->mutex);96}97 98#endif99