]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/amdgpu: Add helper function to get buffer domain
authorDeepak Sharma <Deepak.Sharma@amd.com>
Sat, 26 May 2018 00:12:29 +0000 (17:12 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 29 May 2018 18:17:51 +0000 (13:17 -0500)
Move logic of getting supported domain to a helper
function

Signed-off-by: Deepak Sharma <Deepak.Sharma@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h

index 63758db5e2ea224eca6cae37575b7ee6e2a0dca2..556406a44da39141e2af23e2b76e18c705c38516 100644 (file)
@@ -750,19 +750,15 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
        struct amdgpu_device *adev = dev->dev_private;
        struct drm_gem_object *gobj;
        uint32_t handle;
-       u32 domain = amdgpu_display_supported_domains(adev);
+       u32 domain;
        int r;
 
        args->pitch = amdgpu_align_pitch(adev, args->width,
                                         DIV_ROUND_UP(args->bpp, 8), 0);
        args->size = (u64)args->pitch * args->height;
        args->size = ALIGN(args->size, PAGE_SIZE);
-       if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
-               domain = AMDGPU_GEM_DOMAIN_VRAM;
-               if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
-                       domain = AMDGPU_GEM_DOMAIN_GTT;
-       }
-
+       domain = amdgpu_bo_get_preferred_pin_domain(adev,
+                               amdgpu_display_supported_domains(adev));
        r = amdgpu_gem_object_create(adev, args->size, 0, domain,
                                     AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                                     false, NULL, &gobj);
index 6a9e46ae7f0a460cc47ebf443f6098c7362965d8..5e4e1bd9038379fe62666e44318162adfc544fea 100644 (file)
@@ -703,11 +703,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
        /* This assumes only APU display buffers are pinned with (VRAM|GTT).
         * See function amdgpu_display_supported_domains()
         */
-       if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
-               domain = AMDGPU_GEM_DOMAIN_VRAM;
-               if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
-                       domain = AMDGPU_GEM_DOMAIN_GTT;
-       }
+       domain = amdgpu_bo_get_preferred_pin_domain(adev, domain);
 
        if (bo->pin_count) {
                uint32_t mem_type = bo->tbo.mem.mem_type;
@@ -1066,3 +1062,14 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
 
        return bo->tbo.offset;
 }
+
+uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,
+                                           uint32_t domain)
+{
+       if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
+               if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+                       domain = AMDGPU_GEM_DOMAIN_GTT;
+       }
+       return domain;
+}
index 540e03fa159f4b6c1025bdbb22e8749af33c2bbd..731748033878b35a32f70a6fe4eda9d0d44835cb 100644 (file)
@@ -289,7 +289,8 @@ int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
                                  struct reservation_object *resv,
                                  struct dma_fence **fence,
                                  bool direct);
-
+uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,
+                                           uint32_t domain);
 
 /*
  * sub allocation