drm/nouveau: get vmm via nouveau_cli_vmm()
authorDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:23:44 +0000 (20:23 +0200)
committerDanilo Krummrich <dakr@redhat.com>
Fri, 4 Aug 2023 18:34:33 +0000 (20:34 +0200)
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
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_chan.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_gem.c

index c2ec91cc845d554ba908657f2705ca65dcd4df01..7724fe63067d70d5e5873723b071d0b664f1193b 100644 (file)
@@ -204,7 +204,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
        struct nouveau_drm *drm = cli->drm;
        struct nouveau_bo *nvbo;
        struct nvif_mmu *mmu = &cli->mmu;
-       struct nvif_vmm *vmm = cli->svm.cli ? &cli->svm.vmm : &cli->vmm.vmm;
+       struct nvif_vmm *vmm = &nouveau_cli_vmm(cli)->vmm;
        int i, pi = -1;
 
        if (!*size) {
index 3dfbc374478e6ac88a053aa9e53add5855f62504..6d639314250a5465c8f3c66666c83fe67e7eeead 100644 (file)
@@ -149,7 +149,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
 
        chan->device = device;
        chan->drm = drm;
-       chan->vmm = cli->svm.cli ? &cli->svm : &cli->vmm;
+       chan->vmm = nouveau_cli_vmm(cli);
        atomic_set(&chan->killed, 0);
 
        /* allocate memory for dma push buffer */
index b5de312a523ffc8a4ed7db198decc2fcb5f15ca6..81350e685b50df7b9af05bdba93288ff8b9f62c8 100644 (file)
@@ -112,6 +112,15 @@ struct nouveau_cli_work {
        struct dma_fence_cb cb;
 };
 
+static inline struct nouveau_vmm *
+nouveau_cli_vmm(struct nouveau_cli *cli)
+{
+       if (cli->svm.cli)
+               return &cli->svm;
+
+       return &cli->vmm;
+}
+
 void nouveau_cli_work_queue(struct nouveau_cli *, struct dma_fence *,
                            struct nouveau_cli_work *);
 
index ab9062e5097770be99ff6fefc7f6faddc9085738..45ca4eb98f5415afa719ba95c5f39aec35d7f2c3 100644 (file)
@@ -103,7 +103,7 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv)
        struct nouveau_bo *nvbo = nouveau_gem_object(gem);
        struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
        struct device *dev = drm->dev->dev;
-       struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : &cli->vmm;
+       struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
        struct nouveau_vma *vma;
        int ret;
 
@@ -180,7 +180,7 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv)
        struct nouveau_bo *nvbo = nouveau_gem_object(gem);
        struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
        struct device *dev = drm->dev->dev;
-       struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : & cli->vmm;
+       struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
        struct nouveau_vma *vma;
        int ret;
 
@@ -269,7 +269,7 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
 {
        struct nouveau_cli *cli = nouveau_cli(file_priv);
        struct nouveau_bo *nvbo = nouveau_gem_object(gem);
-       struct nouveau_vmm *vmm = cli->svm.cli ? &cli->svm : &cli->vmm;
+       struct nouveau_vmm *vmm = nouveau_cli_vmm(cli);
        struct nouveau_vma *vma;
 
        if (is_power_of_2(nvbo->valid_domains))