drm/amdgpu: be explicit about cpu vram access for driver BOs (v2)
authorAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Aug 2015 04:14:16 +0000 (00:14 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 3 Sep 2015 14:29:32 +0000 (10:29 -0400)
For kernel driver BOs, be explicit about whether we need
vram access up front.  This avoids unecessary migrations and
avoids using visible vram for buffers were it's not needed.

v2: line wrap fixes

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
12 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/fiji_smc.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/iceland_smc.c
drivers/gpu/drm/amd/amdgpu/tonga_smc.c

index 42d1a22c119942decff10c8e92930792d6856afb..6ff6ae945794a24167d6403a48bb8aa57d2fa4a2 100644 (file)
@@ -244,7 +244,8 @@ static int amdgpu_vram_scratch_init(struct amdgpu_device *adev)
 
        if (adev->vram_scratch.robj == NULL) {
                r = amdgpu_bo_create(adev, AMDGPU_GPU_PAGE_SIZE,
-                                    PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, 0,
+                                    PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
+                                    AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                                     NULL, &adev->vram_scratch.robj);
                if (r) {
                        return r;
index 81b821247dde5ca4fa3992083813fe848ac97e99..8a122b1b77861028c123301726b8bb440537ad55 100644 (file)
@@ -126,8 +126,8 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
        aligned_size = ALIGN(size, PAGE_SIZE);
        ret = amdgpu_gem_object_create(adev, aligned_size, 0,
                                       AMDGPU_GEM_DOMAIN_VRAM,
-                                      0, true,
-                                      &gobj);
+                                      AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                                      true, &gobj);
        if (ret) {
                printk(KERN_ERR "failed to allocate framebuffer (%d)\n",
                       aligned_size);
index e02db0b2e8393e47bda5b6e084c2ae1f0d3631cd..cbd3a486c5c2c0bc8ce29f965dec462eb88f6569 100644 (file)
@@ -125,7 +125,8 @@ int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
 
        if (adev->gart.robj == NULL) {
                r = amdgpu_bo_create(adev, adev->gart.table_size,
-                                    PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, 0,
+                                    PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
+                                    AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                                     NULL, &adev->gart.robj);
                if (r) {
                        return r;
index 4b36e779622f9459b6556854102a3ec8ebd877aa..5839fab374bf62dac0a5781a4617da0e5335aafd 100644 (file)
@@ -656,7 +656,8 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
 
        r = amdgpu_gem_object_create(adev, args->size, 0,
                                     AMDGPU_GEM_DOMAIN_VRAM,
-                                    0, ttm_bo_type_device,
+                                    AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                                    ttm_bo_type_device,
                                     &gobj);
        if (r)
                return -ENOMEM;
index 399143541d8a2c377967d8df3183a62a594abced..b5abd5cde413ffaa42934aa0bf4a731ec8bb8fe2 100644 (file)
@@ -859,7 +859,8 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
        amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size);
 
        r = amdgpu_bo_create(adev, 256 * 1024, PAGE_SIZE, true,
-                            AMDGPU_GEM_DOMAIN_VRAM, 0,
+                            AMDGPU_GEM_DOMAIN_VRAM,
+                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                             NULL, &adev->stollen_vga_memory);
        if (r) {
                return r;
index 3ad4a83c418fed123a5660aacba5a7f6457651cf..2cf6c6b06e3b157b756fc978126361257becbacc 100644 (file)
@@ -154,7 +154,9 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
        bo_size = AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8)
                 +  AMDGPU_UVD_STACK_SIZE + AMDGPU_UVD_HEAP_SIZE;
        r = amdgpu_bo_create(adev, bo_size, PAGE_SIZE, true,
-                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &adev->uvd.vcpu_bo);
+                            AMDGPU_GEM_DOMAIN_VRAM,
+                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                            NULL, &adev->uvd.vcpu_bo);
        if (r) {
                dev_err(adev->dev, "(%d) failed to allocate UVD bo\n", r);
                return r;
@@ -901,7 +903,9 @@ int amdgpu_uvd_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
        int r, i;
 
        r = amdgpu_bo_create(adev, 1024, PAGE_SIZE, true,
-                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &bo);
+                            AMDGPU_GEM_DOMAIN_VRAM,
+                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                            NULL, &bo);
        if (r)
                return r;
 
@@ -948,7 +952,9 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
        int r, i;
 
        r = amdgpu_bo_create(adev, 1024, PAGE_SIZE, true,
-                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &bo);
+                            AMDGPU_GEM_DOMAIN_VRAM,
+                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                            NULL, &bo);
        if (r)
                return r;
 
index 1a984c934b1f274b7d099f9acf4c8352d3d6b59f..76982438d1c6ba32a5d9fce5ebb8ba2f76c2ed01 100644 (file)
@@ -141,7 +141,9 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size)
        /* allocate firmware, stack and heap BO */
 
        r = amdgpu_bo_create(adev, size, PAGE_SIZE, true,
-                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &adev->vce.vcpu_bo);
+                            AMDGPU_GEM_DOMAIN_VRAM,
+                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                            NULL, &adev->vce.vcpu_bo);
        if (r) {
                dev_err(adev->dev, "(%d) failed to allocate VCE bo\n", r);
                return r;
index 5848564d3d66623cd88c524aefe14f1e6aed07fc..f68b7cdc370a8694bb489e97c82d27e490e3c3b0 100644 (file)
@@ -1099,7 +1099,9 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
 
                r = amdgpu_bo_create(adev, AMDGPU_VM_PTE_COUNT * 8,
                                     AMDGPU_GPU_PAGE_SIZE, true,
-                                    AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &pt);
+                                    AMDGPU_GEM_DOMAIN_VRAM,
+                                    AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
+                                    NULL, &pt);
                if (r)
                        goto error_free;
 
@@ -1299,7 +1301,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
        vm->page_directory_fence = NULL;
 
        r = amdgpu_bo_create(adev, pd_size, align, true,
-                            AMDGPU_GEM_DOMAIN_VRAM, 0,
+                            AMDGPU_GEM_DOMAIN_VRAM,
+                            AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
                             NULL, &vm->page_directory);
        if (r)
                return r;
index 493c8c9c7faa77bf6fcb8963ab08fdf5670a38a9..322edea65857872ebd084ff322ee6fff6bf31e13 100644 (file)
@@ -762,7 +762,9 @@ int fiji_smu_init(struct amdgpu_device *adev)
 
        /* Allocate FW image data structure and header buffer */
        ret = amdgpu_bo_create(adev, image_size, PAGE_SIZE,
-                               true, AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, toc_buf);
+                              true, AMDGPU_GEM_DOMAIN_VRAM,
+                              AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                              NULL, toc_buf);
        if (ret) {
                DRM_ERROR("Failed to allocate memory for TOC buffer\n");
                return -ENOMEM;
@@ -770,7 +772,9 @@ int fiji_smu_init(struct amdgpu_device *adev)
 
        /* Allocate buffer for SMU internal buffer */
        ret = amdgpu_bo_create(adev, smu_internal_buffer_size, PAGE_SIZE,
-                               true, AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, smu_buf);
+                              true, AMDGPU_GEM_DOMAIN_VRAM,
+                              AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                              NULL, smu_buf);
        if (ret) {
                DRM_ERROR("Failed to allocate memory for SMU internal buffer\n");
                return -ENOMEM;
index 517a68f82ec3b1c71773c0296ff1ba780de141a6..4bd1e5cf65ca81a04de64ec775164c5e5c410947 100644 (file)
@@ -3786,7 +3786,9 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
                /* save restore block */
                if (adev->gfx.rlc.save_restore_obj == NULL) {
                        r = amdgpu_bo_create(adev, dws * 4, PAGE_SIZE, true,
-                                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &adev->gfx.rlc.save_restore_obj);
+                                            AMDGPU_GEM_DOMAIN_VRAM,
+                                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                                            NULL, &adev->gfx.rlc.save_restore_obj);
                        if (r) {
                                dev_warn(adev->dev, "(%d) create RLC sr bo failed\n", r);
                                return r;
@@ -3827,7 +3829,9 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
 
                if (adev->gfx.rlc.clear_state_obj == NULL) {
                        r = amdgpu_bo_create(adev, dws * 4, PAGE_SIZE, true,
-                                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &adev->gfx.rlc.clear_state_obj);
+                                            AMDGPU_GEM_DOMAIN_VRAM,
+                                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                                            NULL, &adev->gfx.rlc.clear_state_obj);
                        if (r) {
                                dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
                                gfx_v7_0_rlc_fini(adev);
@@ -3864,7 +3868,9 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
        if (adev->gfx.rlc.cp_table_size) {
                if (adev->gfx.rlc.cp_table_obj == NULL) {
                        r = amdgpu_bo_create(adev, adev->gfx.rlc.cp_table_size, PAGE_SIZE, true,
-                                            AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, &adev->gfx.rlc.cp_table_obj);
+                                            AMDGPU_GEM_DOMAIN_VRAM,
+                                            AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                                            NULL, &adev->gfx.rlc.cp_table_obj);
                        if (r) {
                                dev_warn(adev->dev, "(%d) create RLC cp table bo failed\n", r);
                                gfx_v7_0_rlc_fini(adev);
index c6f1e2f12b5f7fc1a5689349a0195e99b3637044..c900aa942adef4f31674ddb98070c7702c6600b3 100644 (file)
@@ -623,7 +623,9 @@ int iceland_smu_init(struct amdgpu_device *adev)
 
        /* Allocate FW image data structure and header buffer */
        ret = amdgpu_bo_create(adev, image_size, PAGE_SIZE,
-                              true, AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, toc_buf);
+                              true, AMDGPU_GEM_DOMAIN_VRAM,
+                              AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                              NULL, toc_buf);
        if (ret) {
                DRM_ERROR("Failed to allocate memory for TOC buffer\n");
                return -ENOMEM;
index 5fc53a40c7ac190c2a06f52542546f52b5f0cda8..1f5ac941a610819f434958cb04b8bb5bb6946439 100644 (file)
@@ -761,7 +761,9 @@ int tonga_smu_init(struct amdgpu_device *adev)
 
        /* Allocate FW image data structure and header buffer */
        ret = amdgpu_bo_create(adev, image_size, PAGE_SIZE,
-                               true, AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, toc_buf);
+                              true, AMDGPU_GEM_DOMAIN_VRAM,
+                              AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                              NULL, toc_buf);
        if (ret) {
                DRM_ERROR("Failed to allocate memory for TOC buffer\n");
                return -ENOMEM;
@@ -769,7 +771,9 @@ int tonga_smu_init(struct amdgpu_device *adev)
 
        /* Allocate buffer for SMU internal buffer */
        ret = amdgpu_bo_create(adev, smu_internal_buffer_size, PAGE_SIZE,
-                               true, AMDGPU_GEM_DOMAIN_VRAM, 0, NULL, smu_buf);
+                              true, AMDGPU_GEM_DOMAIN_VRAM,
+                              AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
+                              NULL, smu_buf);
        if (ret) {
                DRM_ERROR("Failed to allocate memory for SMU internal buffer\n");
                return -ENOMEM;