Skip to content

Commit 7b05a7c

Browse files
committed
drm/nouveau: get vmm via nouveau_cli_vmm()
Provide a getter function for the client's current vmm context. Since we'll add a new (u)vmm context for UMD bindings in subsequent commits, this will keep the code clean. Reviewed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Danilo Krummrich <dakr@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230804182406.5222-5-dakr@redhat.com
1 parent e022389 commit 7b05a7c

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

drivers/gpu/drm/nouveau/nouveau_bo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
204204
struct nouveau_drm *drm = cli->drm;
205205
struct nouveau_bo *nvbo;
206206
struct nvif_mmu *mmu = &cli->mmu;
207-
struct nvif_vmm *vmm = cli->svm.cli ? &cli->svm.vmm : &cli->vmm.vmm;
207+
struct nvif_vmm *vmm = &nouveau_cli_vmm(cli)->vmm;
208208
int i, pi = -1;
209209

210210
if (!*size) {

drivers/gpu/drm/nouveau/nouveau_chan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
149149

150150
chan->device = device;
151151
chan->drm = drm;
152-
chan->vmm = cli->svm.cli ? &cli->svm : &cli->vmm;
152+
chan->vmm = nouveau_cli_vmm(cli);
153153
atomic_set(&chan->killed, 0);
154154

155155
/* allocate memory for dma push buffer */

drivers/gpu/drm/nouveau/nouveau_drv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ struct nouveau_cli_work {
112112
struct dma_fence_cb cb;
113113
};
114114

115+
static inline struct nouveau_vmm *
116+
nouveau_cli_vmm(struct nouveau_cli *cli)
117+
{
118+
if (cli->svm.cli)
119+
return &cli->svm;
120+
121+
return &cli->vmm;
122+
}
123+
115124
void nouveau_cli_work_queue(struct nouveau_cli *, struct dma_fence *,
116125
struct nouveau_cli_work *);
117126

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv)
103103
struct nouveau_bo *nvbo = nouveau_gem_object(gem);
104104
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
105105
struct device *dev = drm->dev->dev;
106-
struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : &cli->vmm;
106+
struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
107107
struct nouveau_vma *vma;
108108
int ret;
109109

@@ -180,7 +180,7 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv)
180180
struct nouveau_bo *nvbo = nouveau_gem_object(gem);
181181
struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
182182
struct device *dev = drm->dev->dev;
183-
struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : & cli->vmm;
183+
struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
184184
struct nouveau_vma *vma;
185185
int ret;
186186

@@ -269,7 +269,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
269269
{
270270
struct nouveau_cli *cli = nouveau_cli(file_priv);
271271
struct nouveau_bo *nvbo = nouveau_gem_object(gem);
272-
struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : &cli->vmm;
272+
struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
273273
struct nouveau_vma *vma;
274274

275275
if (is_power_of_2(nvbo->valid_domains))

0 commit comments

Comments
 (0)