drm/radeon: export reservation_object from dmabuf to ttm
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Thu, 18 Sep 2014 12:11:56 +0000 (14:11 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 3 Oct 2014 13:19:17 +0000 (09:19 -0400)
Adds an extra argument to radeon_bo_create, which is only used in radeon_prime.c.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
17 files changed:
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/radeon_benchmark.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_gart.c
drivers/gpu/drm/radeon/radeon_gem.c
drivers/gpu/drm/radeon/radeon_object.c
drivers/gpu/drm/radeon/radeon_object.h
drivers/gpu/drm/radeon/radeon_prime.c
drivers/gpu/drm/radeon/radeon_ring.c
drivers/gpu/drm/radeon/radeon_sa.c
drivers/gpu/drm/radeon/radeon_test.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/radeon/radeon_uvd.c
drivers/gpu/drm/radeon/radeon_vce.c
drivers/gpu/drm/radeon/radeon_vm.c

index fc49a8d0fe00c930b0c9deb48ee49f0eaa16bfe8..d48a539b038a10adb24e5e8d878e43f606bfc2a0 100644 (file)
@@ -4687,7 +4687,7 @@ static int cik_mec_init(struct radeon_device *rdev)
                r = radeon_bo_create(rdev,
                                     rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2,
                                     PAGE_SIZE, true,
-                                    RADEON_GEM_DOMAIN_GTT, 0, NULL,
+                                    RADEON_GEM_DOMAIN_GTT, 0, NULL, NULL,
                                     &rdev->mec.hpd_eop_obj);
                if (r) {
                        dev_warn(rdev->dev, "(%d) create HDP EOP bo failed\n", r);
@@ -4858,7 +4858,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
                                             sizeof(struct bonaire_mqd),
                                             PAGE_SIZE, true,
                                             RADEON_GEM_DOMAIN_GTT, 0, NULL,
-                                            &rdev->ring[idx].mqd_obj);
+                                            NULL, &rdev->ring[idx].mqd_obj);
                        if (r) {
                                dev_warn(rdev->dev, "(%d) create MQD bo failed\n", r);
                                return r;
index c09e40a0d3d0a7c3c9493c2ab95f1019cf7fe3cc..8fe9f870fb5a318a44dbb90983fdafe01342ed3f 100644 (file)
@@ -4022,7 +4022,7 @@ int sumo_rlc_init(struct radeon_device *rdev)
                if (rdev->rlc.save_restore_obj == NULL) {
                        r = radeon_bo_create(rdev, dws * 4, PAGE_SIZE, true,
                                             RADEON_GEM_DOMAIN_VRAM, 0, NULL,
-                                            &rdev->rlc.save_restore_obj);
+                                            NULL, &rdev->rlc.save_restore_obj);
                        if (r) {
                                dev_warn(rdev->dev, "(%d) create RLC sr bo failed\n", r);
                                return r;
@@ -4101,7 +4101,7 @@ int sumo_rlc_init(struct radeon_device *rdev)
                if (rdev->rlc.clear_state_obj == NULL) {
                        r = radeon_bo_create(rdev, dws * 4, PAGE_SIZE, true,
                                             RADEON_GEM_DOMAIN_VRAM, 0, NULL,
-                                            &rdev->rlc.clear_state_obj);
+                                            NULL, &rdev->rlc.clear_state_obj);
                        if (r) {
                                dev_warn(rdev->dev, "(%d) create RLC c bo failed\n", r);
                                sumo_rlc_fini(rdev);
@@ -4178,7 +4178,7 @@ int sumo_rlc_init(struct radeon_device *rdev)
                        r = radeon_bo_create(rdev, rdev->rlc.cp_table_size,
                                             PAGE_SIZE, true,
                                             RADEON_GEM_DOMAIN_VRAM, 0, NULL,
-                                            &rdev->rlc.cp_table_obj);
+                                            NULL, &rdev->rlc.cp_table_obj);
                        if (r) {
                                dev_warn(rdev->dev, "(%d) create RLC cp table bo failed\n", r);
                                sumo_rlc_fini(rdev);
index f8eb519c32865a9510e2ba31cfcef5958c727a8f..85414283fcccd9f9abdae2620f760a78282c45b8 100644 (file)
@@ -1430,7 +1430,7 @@ int r600_vram_scratch_init(struct radeon_device *rdev)
        if (rdev->vram_scratch.robj == NULL) {
                r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE,
                                     PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
-                                    0, NULL, &rdev->vram_scratch.robj);
+                                    0, NULL, NULL, &rdev->vram_scratch.robj);
                if (r) {
                        return r;
                }
@@ -3368,7 +3368,7 @@ int r600_ih_ring_alloc(struct radeon_device *rdev)
                r = radeon_bo_create(rdev, rdev->ih.ring_size,
                                     PAGE_SIZE, true,
                                     RADEON_GEM_DOMAIN_GTT, 0,
-                                    NULL, &rdev->ih.ring_obj);
+                                    NULL, NULL, &rdev->ih.ring_obj);
                if (r) {
                        DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r);
                        return r;
index 1e8855060fc71ff32a4c7d1102982df04c169f33..9e7f23dd14bd5992d73b72ddec32d084ee906aed 100644 (file)
@@ -93,7 +93,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size,
        int time;
 
        n = RADEON_BENCHMARK_ITERATIONS;
-       r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, 0, NULL, &sobj);
+       r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, 0, NULL, NULL, &sobj);
        if (r) {
                goto out_cleanup;
        }
@@ -105,7 +105,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size,
        if (r) {
                goto out_cleanup;
        }
-       r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, 0, NULL, &dobj);
+       r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, 0, NULL, NULL, &dobj);
        if (r) {
                goto out_cleanup;
        }
index e84a76e6656a5e2d5feacd4568a5cfb40a734f04..6fbab15821128b44bc88d36a14f2e3894df857d7 100644 (file)
@@ -430,7 +430,7 @@ int radeon_wb_init(struct radeon_device *rdev)
 
        if (rdev->wb.wb_obj == NULL) {
                r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
-                                    RADEON_GEM_DOMAIN_GTT, 0, NULL,
+                                    RADEON_GEM_DOMAIN_GTT, 0, NULL, NULL,
                                     &rdev->wb.wb_obj);
                if (r) {
                        dev_warn(rdev->dev, "(%d) create WB bo failed\n", r);
index a053a0779aac35e907ab4e52ed8c71746a0c30c9..84146d5901aa5aacad168255c14d72cafce5cf15 100644 (file)
@@ -128,7 +128,7 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev)
        if (rdev->gart.robj == NULL) {
                r = radeon_bo_create(rdev, rdev->gart.table_size,
                                     PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
-                                    0, NULL, &rdev->gart.robj);
+                                    0, NULL, NULL, &rdev->gart.robj);
                if (r) {
                        return r;
                }
index 4b7c8ec36c2f02f19aadf2f17d78eb84b50a25fa..c194497aa586e16c5c17776d5baa5959f3eac7c5 100644 (file)
@@ -67,7 +67,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, unsigned long size,
 
 retry:
        r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain,
-                            flags, NULL, &robj);
+                            flags, NULL, NULL, &robj);
        if (r) {
                if (r != -ERESTARTSYS) {
                        if (initial_domain == RADEON_GEM_DOMAIN_VRAM) {
index 0e82f0223fd48df3134bfd23287128e01e141779..99a960a4f30265c893a411763843a260d38e6a41 100644 (file)
@@ -167,8 +167,10 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
 }
 
 int radeon_bo_create(struct radeon_device *rdev,
-                    unsigned long size, int byte_align, bool kernel, u32 domain,
-                    u32 flags, struct sg_table *sg, struct radeon_bo **bo_ptr)
+                    unsigned long size, int byte_align, bool kernel,
+                    u32 domain, u32 flags, struct sg_table *sg,
+                    struct reservation_object *resv,
+                    struct radeon_bo **bo_ptr)
 {
        struct radeon_bo *bo;
        enum ttm_bo_type type;
@@ -216,7 +218,7 @@ int radeon_bo_create(struct radeon_device *rdev,
        down_read(&rdev->pm.mclk_lock);
        r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
                        &bo->placement, page_align, !kernel, NULL,
-                       acc_size, sg, NULL, &radeon_ttm_bo_destroy);
+                       acc_size, sg, resv, &radeon_ttm_bo_destroy);
        up_read(&rdev->pm.mclk_lock);
        if (unlikely(r != 0)) {
                return r;
index 98a47fdf362510284d21b864f1e5e565b5388604..1b8ec7917154809e10336fb346c6aacbafa72939 100644 (file)
@@ -126,6 +126,7 @@ extern int radeon_bo_create(struct radeon_device *rdev,
                            unsigned long size, int byte_align,
                            bool kernel, u32 domain, u32 flags,
                            struct sg_table *sg,
+                           struct reservation_object *resv,
                            struct radeon_bo **bo_ptr);
 extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr);
 extern void radeon_bo_kunmap(struct radeon_bo *bo);
index 171daf7fc483073f0f425624725610388c4092f6..f3609c97496b2f56bf35cfbe2cf52f76b30b9f79 100644 (file)
@@ -61,12 +61,15 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev,
                                                        struct dma_buf_attachment *attach,
                                                        struct sg_table *sg)
 {
+       struct reservation_object *resv = attach->dmabuf->resv;
        struct radeon_device *rdev = dev->dev_private;
        struct radeon_bo *bo;
        int ret;
 
+       ww_mutex_lock(&resv->lock, NULL);
        ret = radeon_bo_create(rdev, attach->dmabuf->size, PAGE_SIZE, false,
-                              RADEON_GEM_DOMAIN_GTT, 0, sg, &bo);
+                              RADEON_GEM_DOMAIN_GTT, 0, sg, resv, &bo);
+       ww_mutex_unlock(&resv->lock);
        if (ret)
                return ERR_PTR(ret);
 
index 6f2a9bd6bb5404808b5dbb675d2849b7ba33240d..3d17af34afa73265eea6ed31210e265acae6eb1a 100644 (file)
@@ -383,7 +383,7 @@ int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsig
        /* Allocate ring buffer */
        if (ring->ring_obj == NULL) {
                r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true,
-                                    RADEON_GEM_DOMAIN_GTT, 0,
+                                    RADEON_GEM_DOMAIN_GTT, 0, NULL,
                                     NULL, &ring->ring_obj);
                if (r) {
                        dev_err(rdev->dev, "(%d) ring create failed\n", r);
index b84f97c8718cd1b7b1f46137b1646af1691f8d4e..c507896aca45a43a3fe271b79b84e7db61bfb85a 100644 (file)
@@ -65,7 +65,7 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev,
        }
 
        r = radeon_bo_create(rdev, size, align, true,
-                            domain, flags, NULL, &sa_manager->bo);
+                            domain, flags, NULL, NULL, &sa_manager->bo);
        if (r) {
                dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r);
                return r;
index ce943e1a5e511df6a4efa67f9e6627bcb2fa4da1..07b506b410080f482b4d41948c3bd627ae4bb39e 100644 (file)
@@ -67,7 +67,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
        }
 
        r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
-                            0, NULL, &vram_obj);
+                            0, NULL, NULL, &vram_obj);
        if (r) {
                DRM_ERROR("Failed to create VRAM object\n");
                goto out_cleanup;
@@ -87,7 +87,8 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
                struct radeon_fence *fence = NULL;
 
                r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
-                                    RADEON_GEM_DOMAIN_GTT, 0, NULL, gtt_obj + i);
+                                    RADEON_GEM_DOMAIN_GTT, 0, NULL, NULL,
+                                    gtt_obj + i);
                if (r) {
                        DRM_ERROR("Failed to create GTT object %d\n", i);
                        goto out_lclean;
index 738a2f248b368a3f868d5e25bd59867c310218ab..8624979afb65f55ecba4ffb888aa09d0b3c8b39d 100644 (file)
@@ -865,7 +865,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
        radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size);
 
        r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true,
-                            RADEON_GEM_DOMAIN_VRAM, 0,
+                            RADEON_GEM_DOMAIN_VRAM, 0, NULL,
                             NULL, &rdev->stollen_vga_memory);
        if (r) {
                return r;
index ba4f38916026772986af461028b7a0f2ea9b667e..11b6624692536c13dbea4cc4e9b4c75b46902d1d 100644 (file)
@@ -141,7 +141,8 @@ int radeon_uvd_init(struct radeon_device *rdev)
                  RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE +
                  RADEON_GPU_PAGE_SIZE;
        r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
-                            RADEON_GEM_DOMAIN_VRAM, 0, NULL, &rdev->uvd.vcpu_bo);
+                            RADEON_GEM_DOMAIN_VRAM, 0, NULL,
+                            NULL, &rdev->uvd.vcpu_bo);
        if (r) {
                dev_err(rdev->dev, "(%d) failed to allocate UVD bo\n", r);
                return r;
index c7190aadbd8981bee97c0c4ed4d923cdf7880b52..9e85757d55991a6cd0e077cada024d87f0484c08 100644 (file)
@@ -126,7 +126,8 @@ int radeon_vce_init(struct radeon_device *rdev)
        size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size) +
               RADEON_VCE_STACK_SIZE + RADEON_VCE_HEAP_SIZE;
        r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
-                            RADEON_GEM_DOMAIN_VRAM, 0, NULL, &rdev->vce.vcpu_bo);
+                            RADEON_GEM_DOMAIN_VRAM, 0, NULL, NULL,
+                            &rdev->vce.vcpu_bo);
        if (r) {
                dev_err(rdev->dev, "(%d) failed to allocate VCE bo\n", r);
                return r;
index 8af1a94e7448234c35ae938f24353ee49c02d6f1..4532cc76a0a66094cd1cff8449f8957dd60152bf 100644 (file)
@@ -548,7 +548,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
 
                r = radeon_bo_create(rdev, RADEON_VM_PTE_COUNT * 8,
                                     RADEON_GPU_PAGE_SIZE, true,
-                                    RADEON_GEM_DOMAIN_VRAM, 0, NULL, &pt);
+                                    RADEON_GEM_DOMAIN_VRAM, 0,
+                                    NULL, NULL, &pt);
                if (r)
                        return r;
 
@@ -1127,7 +1128,7 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
 
        r = radeon_bo_create(rdev, pd_size, align, true,
                             RADEON_GEM_DOMAIN_VRAM, 0, NULL,
-                            &vm->page_directory);
+                            NULL, &vm->page_directory);
        if (r)
                return r;