diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2014-07-17 06:01:08 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2014-08-05 08:53:33 -0400 |
commit | 02376d8282b88f07d0716da6155094c8760b1a13 (patch) | |
tree | 9e81e9b229f9230f2d42f8e80fdd50966eac13bc /drivers | |
parent | 77497f2735ad6e29c55475e15e9790dbfa2c2ef8 (diff) |
drm/radeon: Allow write-combined CPU mappings of BOs in GTT (v2)
v2: fix rebase onto drm-fixes
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/radeon/cik.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/cik_sdma.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/evergreen.c | 12 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r600.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_benchmark.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_device.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_fb.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gart.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gem.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_object.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_prime.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ring.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_sa.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_test.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_uvd.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_vce.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_vm.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/si_dma.c | 3 |
21 files changed, 70 insertions, 47 deletions
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index 64100fc50346..e6576b4b849d 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c | |||
@@ -4676,7 +4676,7 @@ static int cik_mec_init(struct radeon_device *rdev) | |||
4676 | r = radeon_bo_create(rdev, | 4676 | r = radeon_bo_create(rdev, |
4677 | rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2, | 4677 | rdev->mec.num_mec *rdev->mec.num_pipe * MEC_HPD_SIZE * 2, |
4678 | PAGE_SIZE, true, | 4678 | PAGE_SIZE, true, |
4679 | RADEON_GEM_DOMAIN_GTT, NULL, | 4679 | RADEON_GEM_DOMAIN_GTT, 0, NULL, |
4680 | &rdev->mec.hpd_eop_obj); | 4680 | &rdev->mec.hpd_eop_obj); |
4681 | if (r) { | 4681 | if (r) { |
4682 | dev_warn(rdev->dev, "(%d) create HDP EOP bo failed\n", r); | 4682 | dev_warn(rdev->dev, "(%d) create HDP EOP bo failed\n", r); |
@@ -4846,7 +4846,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev) | |||
4846 | r = radeon_bo_create(rdev, | 4846 | r = radeon_bo_create(rdev, |
4847 | sizeof(struct bonaire_mqd), | 4847 | sizeof(struct bonaire_mqd), |
4848 | PAGE_SIZE, true, | 4848 | PAGE_SIZE, true, |
4849 | RADEON_GEM_DOMAIN_GTT, NULL, | 4849 | RADEON_GEM_DOMAIN_GTT, 0, NULL, |
4850 | &rdev->ring[idx].mqd_obj); | 4850 | &rdev->ring[idx].mqd_obj); |
4851 | if (r) { | 4851 | if (r) { |
4852 | dev_warn(rdev->dev, "(%d) create MQD bo failed\n", r); | 4852 | dev_warn(rdev->dev, "(%d) create MQD bo failed\n", r); |
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c index 60aa1cb39f2f..4b2ab769cd99 100644 --- a/drivers/gpu/drm/radeon/cik_sdma.c +++ b/drivers/gpu/drm/radeon/cik_sdma.c | |||
@@ -771,7 +771,8 @@ void cik_sdma_vm_set_page(struct radeon_device *rdev, | |||
771 | 771 | ||
772 | trace_radeon_vm_set_page(pe, addr, count, incr, flags); | 772 | trace_radeon_vm_set_page(pe, addr, count, incr, flags); |
773 | 773 | ||
774 | if (flags == R600_PTE_GART) { | 774 | /* XXX: How to distinguish between GART and other system memory pages? */ |
775 | if (flags & R600_PTE_SYSTEM) { | ||
775 | uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8; | 776 | uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8; |
776 | while (count) { | 777 | while (count) { |
777 | unsigned bytes = count * 8; | 778 | unsigned bytes = count * 8; |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index ae7923c8ec8b..27ebaaa88d89 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -4022,7 +4022,8 @@ int sumo_rlc_init(struct radeon_device *rdev) | |||
4022 | /* save restore block */ | 4022 | /* save restore block */ |
4023 | if (rdev->rlc.save_restore_obj == NULL) { | 4023 | if (rdev->rlc.save_restore_obj == NULL) { |
4024 | r = radeon_bo_create(rdev, dws * 4, PAGE_SIZE, true, | 4024 | r = radeon_bo_create(rdev, dws * 4, PAGE_SIZE, true, |
4025 | RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->rlc.save_restore_obj); | 4025 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, |
4026 | &rdev->rlc.save_restore_obj); | ||
4026 | if (r) { | 4027 | if (r) { |
4027 | dev_warn(rdev->dev, "(%d) create RLC sr bo failed\n", r); | 4028 | dev_warn(rdev->dev, "(%d) create RLC sr bo failed\n", r); |
4028 | return r; | 4029 | return r; |
@@ -4100,7 +4101,8 @@ int sumo_rlc_init(struct radeon_device *rdev) | |||
4100 | 4101 | ||
4101 | if (rdev->rlc.clear_state_obj == NULL) { | 4102 | if (rdev->rlc.clear_state_obj == NULL) { |
4102 | r = radeon_bo_create(rdev, dws * 4, PAGE_SIZE, true, | 4103 | r = radeon_bo_create(rdev, dws * 4, PAGE_SIZE, true, |
4103 | RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->rlc.clear_state_obj); | 4104 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, |
4105 | &rdev->rlc.clear_state_obj); | ||
4104 | if (r) { | 4106 | if (r) { |
4105 | dev_warn(rdev->dev, "(%d) create RLC c bo failed\n", r); | 4107 | dev_warn(rdev->dev, "(%d) create RLC c bo failed\n", r); |
4106 | sumo_rlc_fini(rdev); | 4108 | sumo_rlc_fini(rdev); |
@@ -4174,8 +4176,10 @@ int sumo_rlc_init(struct radeon_device *rdev) | |||
4174 | 4176 | ||
4175 | if (rdev->rlc.cp_table_size) { | 4177 | if (rdev->rlc.cp_table_size) { |
4176 | if (rdev->rlc.cp_table_obj == NULL) { | 4178 | if (rdev->rlc.cp_table_obj == NULL) { |
4177 | r = radeon_bo_create(rdev, rdev->rlc.cp_table_size, PAGE_SIZE, true, | 4179 | r = radeon_bo_create(rdev, rdev->rlc.cp_table_size, |
4178 | RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->rlc.cp_table_obj); | 4180 | PAGE_SIZE, true, |
4181 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, | ||
4182 | &rdev->rlc.cp_table_obj); | ||
4179 | if (r) { | 4183 | if (r) { |
4180 | dev_warn(rdev->dev, "(%d) create RLC cp table bo failed\n", r); | 4184 | dev_warn(rdev->dev, "(%d) create RLC cp table bo failed\n", r); |
4181 | sumo_rlc_fini(rdev); | 4185 | sumo_rlc_fini(rdev); |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index e6a2243114b5..c17ff5dc95c2 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -1338,7 +1338,7 @@ int r600_vram_scratch_init(struct radeon_device *rdev) | |||
1338 | if (rdev->vram_scratch.robj == NULL) { | 1338 | if (rdev->vram_scratch.robj == NULL) { |
1339 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, | 1339 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, |
1340 | PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, | 1340 | PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, |
1341 | NULL, &rdev->vram_scratch.robj); | 1341 | 0, NULL, &rdev->vram_scratch.robj); |
1342 | if (r) { | 1342 | if (r) { |
1343 | return r; | 1343 | return r; |
1344 | } | 1344 | } |
@@ -3226,7 +3226,7 @@ int r600_ih_ring_alloc(struct radeon_device *rdev) | |||
3226 | if (rdev->ih.ring_obj == NULL) { | 3226 | if (rdev->ih.ring_obj == NULL) { |
3227 | r = radeon_bo_create(rdev, rdev->ih.ring_size, | 3227 | r = radeon_bo_create(rdev, rdev->ih.ring_size, |
3228 | PAGE_SIZE, true, | 3228 | PAGE_SIZE, true, |
3229 | RADEON_GEM_DOMAIN_GTT, | 3229 | RADEON_GEM_DOMAIN_GTT, 0, |
3230 | NULL, &rdev->ih.ring_obj); | 3230 | NULL, &rdev->ih.ring_obj); |
3231 | if (r) { | 3231 | if (r) { |
3232 | DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r); | 3232 | DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r); |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index b1eea04a329e..67e9931fd76a 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -468,6 +468,7 @@ struct radeon_bo { | |||
468 | struct ttm_placement placement; | 468 | struct ttm_placement placement; |
469 | struct ttm_buffer_object tbo; | 469 | struct ttm_buffer_object tbo; |
470 | struct ttm_bo_kmap_obj kmap; | 470 | struct ttm_bo_kmap_obj kmap; |
471 | u32 flags; | ||
471 | unsigned pin_count; | 472 | unsigned pin_count; |
472 | void *kptr; | 473 | void *kptr; |
473 | u32 tiling_flags; | 474 | u32 tiling_flags; |
@@ -548,7 +549,7 @@ int radeon_gem_init(struct radeon_device *rdev); | |||
548 | void radeon_gem_fini(struct radeon_device *rdev); | 549 | void radeon_gem_fini(struct radeon_device *rdev); |
549 | int radeon_gem_object_create(struct radeon_device *rdev, int size, | 550 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
550 | int alignment, int initial_domain, | 551 | int alignment, int initial_domain, |
551 | bool discardable, bool kernel, | 552 | u32 flags, bool discardable, bool kernel, |
552 | struct drm_gem_object **obj); | 553 | struct drm_gem_object **obj); |
553 | 554 | ||
554 | int radeon_mode_dumb_create(struct drm_file *file_priv, | 555 | int radeon_mode_dumb_create(struct drm_file *file_priv, |
diff --git a/drivers/gpu/drm/radeon/radeon_benchmark.c b/drivers/gpu/drm/radeon/radeon_benchmark.c index 6e05a2e75a46..69f5695bdab9 100644 --- a/drivers/gpu/drm/radeon/radeon_benchmark.c +++ b/drivers/gpu/drm/radeon/radeon_benchmark.c | |||
@@ -97,7 +97,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size, | |||
97 | int time; | 97 | int time; |
98 | 98 | ||
99 | n = RADEON_BENCHMARK_ITERATIONS; | 99 | n = RADEON_BENCHMARK_ITERATIONS; |
100 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, NULL, &sobj); | 100 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, 0, NULL, &sobj); |
101 | if (r) { | 101 | if (r) { |
102 | goto out_cleanup; | 102 | goto out_cleanup; |
103 | } | 103 | } |
@@ -109,7 +109,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size, | |||
109 | if (r) { | 109 | if (r) { |
110 | goto out_cleanup; | 110 | goto out_cleanup; |
111 | } | 111 | } |
112 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, NULL, &dobj); | 112 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, 0, NULL, &dobj); |
113 | if (r) { | 113 | if (r) { |
114 | goto out_cleanup; | 114 | goto out_cleanup; |
115 | } | 115 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 697add2cd4e3..61990bda285d 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
@@ -385,7 +385,8 @@ int radeon_wb_init(struct radeon_device *rdev) | |||
385 | 385 | ||
386 | if (rdev->wb.wb_obj == NULL) { | 386 | if (rdev->wb.wb_obj == NULL) { |
387 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, | 387 | r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, |
388 | RADEON_GEM_DOMAIN_GTT, NULL, &rdev->wb.wb_obj); | 388 | RADEON_GEM_DOMAIN_GTT, 0, NULL, |
389 | &rdev->wb.wb_obj); | ||
389 | if (r) { | 390 | if (r) { |
390 | dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); | 391 | dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); |
391 | return r; | 392 | return r; |
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c index db598d712901..477ea0df0daa 100644 --- a/drivers/gpu/drm/radeon/radeon_fb.c +++ b/drivers/gpu/drm/radeon/radeon_fb.c | |||
@@ -127,7 +127,7 @@ static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev, | |||
127 | aligned_size = ALIGN(size, PAGE_SIZE); | 127 | aligned_size = ALIGN(size, PAGE_SIZE); |
128 | ret = radeon_gem_object_create(rdev, aligned_size, 0, | 128 | ret = radeon_gem_object_create(rdev, aligned_size, 0, |
129 | RADEON_GEM_DOMAIN_VRAM, | 129 | RADEON_GEM_DOMAIN_VRAM, |
130 | false, true, | 130 | 0, false, true, |
131 | &gobj); | 131 | &gobj); |
132 | if (ret) { | 132 | if (ret) { |
133 | printk(KERN_ERR "failed to allocate framebuffer (%d)\n", | 133 | printk(KERN_ERR "failed to allocate framebuffer (%d)\n", |
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index d684642d900b..a053a0779aac 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c | |||
@@ -128,7 +128,7 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev) | |||
128 | if (rdev->gart.robj == NULL) { | 128 | if (rdev->gart.robj == NULL) { |
129 | r = radeon_bo_create(rdev, rdev->gart.table_size, | 129 | r = radeon_bo_create(rdev, rdev->gart.table_size, |
130 | PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, | 130 | PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, |
131 | NULL, &rdev->gart.robj); | 131 | 0, NULL, &rdev->gart.robj); |
132 | if (r) { | 132 | if (r) { |
133 | return r; | 133 | return r; |
134 | } | 134 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index fdd189b2b217..ce1d61efa1f9 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c | |||
@@ -42,7 +42,7 @@ void radeon_gem_object_free(struct drm_gem_object *gobj) | |||
42 | 42 | ||
43 | int radeon_gem_object_create(struct radeon_device *rdev, int size, | 43 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
44 | int alignment, int initial_domain, | 44 | int alignment, int initial_domain, |
45 | bool discardable, bool kernel, | 45 | u32 flags, bool discardable, bool kernel, |
46 | struct drm_gem_object **obj) | 46 | struct drm_gem_object **obj) |
47 | { | 47 | { |
48 | struct radeon_bo *robj; | 48 | struct radeon_bo *robj; |
@@ -64,7 +64,8 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, | |||
64 | } | 64 | } |
65 | 65 | ||
66 | retry: | 66 | retry: |
67 | r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, NULL, &robj); | 67 | r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, |
68 | flags, NULL, &robj); | ||
68 | if (r) { | 69 | if (r) { |
69 | if (r != -ERESTARTSYS) { | 70 | if (r != -ERESTARTSYS) { |
70 | if (initial_domain == RADEON_GEM_DOMAIN_VRAM) { | 71 | if (initial_domain == RADEON_GEM_DOMAIN_VRAM) { |
@@ -252,8 +253,8 @@ int radeon_gem_create_ioctl(struct drm_device *dev, void *data, | |||
252 | /* create a gem object to contain this object in */ | 253 | /* create a gem object to contain this object in */ |
253 | args->size = roundup(args->size, PAGE_SIZE); | 254 | args->size = roundup(args->size, PAGE_SIZE); |
254 | r = radeon_gem_object_create(rdev, args->size, args->alignment, | 255 | r = radeon_gem_object_create(rdev, args->size, args->alignment, |
255 | args->initial_domain, false, | 256 | args->initial_domain, args->flags, |
256 | false, &gobj); | 257 | false, false, &gobj); |
257 | if (r) { | 258 | if (r) { |
258 | up_read(&rdev->exclusive_lock); | 259 | up_read(&rdev->exclusive_lock); |
259 | r = radeon_gem_handle_lockup(rdev, r); | 260 | r = radeon_gem_handle_lockup(rdev, r); |
@@ -461,11 +462,6 @@ int radeon_gem_va_ioctl(struct drm_device *dev, void *data, | |||
461 | args->operation = RADEON_VA_RESULT_ERROR; | 462 | args->operation = RADEON_VA_RESULT_ERROR; |
462 | return -EINVAL; | 463 | return -EINVAL; |
463 | } | 464 | } |
464 | if (!(args->flags & RADEON_VM_PAGE_SNOOPED)) { | ||
465 | dev_err(&dev->pdev->dev, "only supported snooped mapping for now\n"); | ||
466 | args->operation = RADEON_VA_RESULT_ERROR; | ||
467 | return -EINVAL; | ||
468 | } | ||
469 | 465 | ||
470 | switch (args->operation) { | 466 | switch (args->operation) { |
471 | case RADEON_VA_MAP: | 467 | case RADEON_VA_MAP: |
@@ -572,7 +568,7 @@ int radeon_mode_dumb_create(struct drm_file *file_priv, | |||
572 | args->size = ALIGN(args->size, PAGE_SIZE); | 568 | args->size = ALIGN(args->size, PAGE_SIZE); |
573 | 569 | ||
574 | r = radeon_gem_object_create(rdev, args->size, 0, | 570 | r = radeon_gem_object_create(rdev, args->size, 0, |
575 | RADEON_GEM_DOMAIN_VRAM, | 571 | RADEON_GEM_DOMAIN_VRAM, 0, |
576 | false, ttm_bo_type_device, | 572 | false, ttm_bo_type_device, |
577 | &gobj); | 573 | &gobj); |
578 | if (r) | 574 | if (r) |
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 6c717b257d6d..1b05a4de5c0a 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c | |||
@@ -114,15 +114,23 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) | |||
114 | rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED | | 114 | rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED | |
115 | TTM_PL_FLAG_VRAM; | 115 | TTM_PL_FLAG_VRAM; |
116 | if (domain & RADEON_GEM_DOMAIN_GTT) { | 116 | if (domain & RADEON_GEM_DOMAIN_GTT) { |
117 | if (rbo->rdev->flags & RADEON_IS_AGP) { | 117 | if (rbo->flags & RADEON_GEM_GTT_UC) { |
118 | rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_TT; | 118 | rbo->placements[c++] = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_TT; |
119 | } else if ((rbo->flags & RADEON_GEM_GTT_WC) || | ||
120 | (rbo->rdev->flags & RADEON_IS_AGP)) { | ||
121 | rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED | | ||
122 | TTM_PL_FLAG_TT; | ||
119 | } else { | 123 | } else { |
120 | rbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_TT; | 124 | rbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_TT; |
121 | } | 125 | } |
122 | } | 126 | } |
123 | if (domain & RADEON_GEM_DOMAIN_CPU) { | 127 | if (domain & RADEON_GEM_DOMAIN_CPU) { |
124 | if (rbo->rdev->flags & RADEON_IS_AGP) { | 128 | if (rbo->flags & RADEON_GEM_GTT_UC) { |
125 | rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_SYSTEM; | 129 | rbo->placements[c++] = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_SYSTEM; |
130 | } else if ((rbo->flags & RADEON_GEM_GTT_WC) || | ||
131 | rbo->rdev->flags & RADEON_IS_AGP) { | ||
132 | rbo->placements[c++] = TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED | | ||
133 | TTM_PL_FLAG_SYSTEM; | ||
126 | } else { | 134 | } else { |
127 | rbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_SYSTEM; | 135 | rbo->placements[c++] = TTM_PL_FLAG_CACHED | TTM_PL_FLAG_SYSTEM; |
128 | } | 136 | } |
@@ -146,7 +154,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) | |||
146 | 154 | ||
147 | int radeon_bo_create(struct radeon_device *rdev, | 155 | int radeon_bo_create(struct radeon_device *rdev, |
148 | unsigned long size, int byte_align, bool kernel, u32 domain, | 156 | unsigned long size, int byte_align, bool kernel, u32 domain, |
149 | struct sg_table *sg, struct radeon_bo **bo_ptr) | 157 | u32 flags, struct sg_table *sg, struct radeon_bo **bo_ptr) |
150 | { | 158 | { |
151 | struct radeon_bo *bo; | 159 | struct radeon_bo *bo; |
152 | enum ttm_bo_type type; | 160 | enum ttm_bo_type type; |
@@ -183,6 +191,12 @@ int radeon_bo_create(struct radeon_device *rdev, | |||
183 | bo->initial_domain = domain & (RADEON_GEM_DOMAIN_VRAM | | 191 | bo->initial_domain = domain & (RADEON_GEM_DOMAIN_VRAM | |
184 | RADEON_GEM_DOMAIN_GTT | | 192 | RADEON_GEM_DOMAIN_GTT | |
185 | RADEON_GEM_DOMAIN_CPU); | 193 | RADEON_GEM_DOMAIN_CPU); |
194 | |||
195 | bo->flags = flags; | ||
196 | /* PCI GART is always snooped */ | ||
197 | if (!(rdev->flags & RADEON_IS_PCIE)) | ||
198 | bo->flags &= ~(RADEON_GEM_GTT_WC | RADEON_GEM_GTT_UC); | ||
199 | |||
186 | radeon_ttm_placement_from_domain(bo, domain); | 200 | radeon_ttm_placement_from_domain(bo, domain); |
187 | /* Kernel allocation are uninterruptible */ | 201 | /* Kernel allocation are uninterruptible */ |
188 | down_read(&rdev->pm.mclk_lock); | 202 | down_read(&rdev->pm.mclk_lock); |
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index 5a873f31a171..972ec0f2d851 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h | |||
@@ -124,7 +124,7 @@ extern int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, | |||
124 | 124 | ||
125 | extern int radeon_bo_create(struct radeon_device *rdev, | 125 | extern int radeon_bo_create(struct radeon_device *rdev, |
126 | unsigned long size, int byte_align, | 126 | unsigned long size, int byte_align, |
127 | bool kernel, u32 domain, | 127 | bool kernel, u32 domain, u32 flags, |
128 | struct sg_table *sg, | 128 | struct sg_table *sg, |
129 | struct radeon_bo **bo_ptr); | 129 | struct radeon_bo **bo_ptr); |
130 | extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); | 130 | extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); |
@@ -170,7 +170,8 @@ static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo) | |||
170 | 170 | ||
171 | extern int radeon_sa_bo_manager_init(struct radeon_device *rdev, | 171 | extern int radeon_sa_bo_manager_init(struct radeon_device *rdev, |
172 | struct radeon_sa_manager *sa_manager, | 172 | struct radeon_sa_manager *sa_manager, |
173 | unsigned size, u32 align, u32 domain); | 173 | unsigned size, u32 align, u32 domain, |
174 | u32 flags); | ||
174 | extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev, | 175 | extern void radeon_sa_bo_manager_fini(struct radeon_device *rdev, |
175 | struct radeon_sa_manager *sa_manager); | 176 | struct radeon_sa_manager *sa_manager); |
176 | extern int radeon_sa_bo_manager_start(struct radeon_device *rdev, | 177 | extern int radeon_sa_bo_manager_start(struct radeon_device *rdev, |
diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c index 20074560fc25..f7e48d329db3 100644 --- a/drivers/gpu/drm/radeon/radeon_prime.c +++ b/drivers/gpu/drm/radeon/radeon_prime.c | |||
@@ -65,7 +65,7 @@ struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev, | |||
65 | int ret; | 65 | int ret; |
66 | 66 | ||
67 | ret = radeon_bo_create(rdev, size, PAGE_SIZE, false, | 67 | ret = radeon_bo_create(rdev, size, PAGE_SIZE, false, |
68 | RADEON_GEM_DOMAIN_GTT, sg, &bo); | 68 | RADEON_GEM_DOMAIN_GTT, 0, sg, &bo); |
69 | if (ret) | 69 | if (ret) |
70 | return ERR_PTR(ret); | 70 | return ERR_PTR(ret); |
71 | 71 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index f8050f5429e2..71439f0a3c26 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c | |||
@@ -204,7 +204,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev) | |||
204 | r = radeon_sa_bo_manager_init(rdev, &rdev->ring_tmp_bo, | 204 | r = radeon_sa_bo_manager_init(rdev, &rdev->ring_tmp_bo, |
205 | RADEON_IB_POOL_SIZE*64*1024, | 205 | RADEON_IB_POOL_SIZE*64*1024, |
206 | RADEON_GPU_PAGE_SIZE, | 206 | RADEON_GPU_PAGE_SIZE, |
207 | RADEON_GEM_DOMAIN_GTT); | 207 | RADEON_GEM_DOMAIN_GTT, 0); |
208 | if (r) { | 208 | if (r) { |
209 | return r; | 209 | return r; |
210 | } | 210 | } |
@@ -640,7 +640,7 @@ int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsig | |||
640 | /* Allocate ring buffer */ | 640 | /* Allocate ring buffer */ |
641 | if (ring->ring_obj == NULL) { | 641 | if (ring->ring_obj == NULL) { |
642 | r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true, | 642 | r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true, |
643 | RADEON_GEM_DOMAIN_GTT, | 643 | RADEON_GEM_DOMAIN_GTT, 0, |
644 | NULL, &ring->ring_obj); | 644 | NULL, &ring->ring_obj); |
645 | if (r) { | 645 | if (r) { |
646 | dev_err(rdev->dev, "(%d) ring create failed\n", r); | 646 | dev_err(rdev->dev, "(%d) ring create failed\n", r); |
diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c index adcf3e2f07da..b84f97c8718c 100644 --- a/drivers/gpu/drm/radeon/radeon_sa.c +++ b/drivers/gpu/drm/radeon/radeon_sa.c | |||
@@ -49,7 +49,7 @@ static void radeon_sa_bo_try_free(struct radeon_sa_manager *sa_manager); | |||
49 | 49 | ||
50 | int radeon_sa_bo_manager_init(struct radeon_device *rdev, | 50 | int radeon_sa_bo_manager_init(struct radeon_device *rdev, |
51 | struct radeon_sa_manager *sa_manager, | 51 | struct radeon_sa_manager *sa_manager, |
52 | unsigned size, u32 align, u32 domain) | 52 | unsigned size, u32 align, u32 domain, u32 flags) |
53 | { | 53 | { |
54 | int i, r; | 54 | int i, r; |
55 | 55 | ||
@@ -65,7 +65,7 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev, | |||
65 | } | 65 | } |
66 | 66 | ||
67 | r = radeon_bo_create(rdev, size, align, true, | 67 | r = radeon_bo_create(rdev, size, align, true, |
68 | domain, NULL, &sa_manager->bo); | 68 | domain, flags, NULL, &sa_manager->bo); |
69 | if (r) { | 69 | if (r) { |
70 | dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r); | 70 | dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r); |
71 | return r; | 71 | return r; |
diff --git a/drivers/gpu/drm/radeon/radeon_test.c b/drivers/gpu/drm/radeon/radeon_test.c index 3a13e0d1055c..9c5b66cb32ae 100644 --- a/drivers/gpu/drm/radeon/radeon_test.c +++ b/drivers/gpu/drm/radeon/radeon_test.c | |||
@@ -73,7 +73,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) | |||
73 | } | 73 | } |
74 | 74 | ||
75 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, | 75 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, |
76 | NULL, &vram_obj); | 76 | 0, NULL, &vram_obj); |
77 | if (r) { | 77 | if (r) { |
78 | DRM_ERROR("Failed to create VRAM object\n"); | 78 | DRM_ERROR("Failed to create VRAM object\n"); |
79 | goto out_cleanup; | 79 | goto out_cleanup; |
@@ -93,7 +93,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) | |||
93 | struct radeon_fence *fence = NULL; | 93 | struct radeon_fence *fence = NULL; |
94 | 94 | ||
95 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, | 95 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, |
96 | RADEON_GEM_DOMAIN_GTT, NULL, gtt_obj + i); | 96 | RADEON_GEM_DOMAIN_GTT, 0, NULL, gtt_obj + i); |
97 | if (r) { | 97 | if (r) { |
98 | DRM_ERROR("Failed to create GTT object %d\n", i); | 98 | DRM_ERROR("Failed to create GTT object %d\n", i); |
99 | goto out_lclean; | 99 | goto out_lclean; |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 7fb7c1cc6af3..72afe82a95c9 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -730,7 +730,7 @@ int radeon_ttm_init(struct radeon_device *rdev) | |||
730 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); | 730 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
731 | 731 | ||
732 | r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true, | 732 | r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true, |
733 | RADEON_GEM_DOMAIN_VRAM, | 733 | RADEON_GEM_DOMAIN_VRAM, 0, |
734 | NULL, &rdev->stollen_vga_memory); | 734 | NULL, &rdev->stollen_vga_memory); |
735 | if (r) { | 735 | if (r) { |
736 | return r; | 736 | return r; |
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c index a4ad270e8261..6bf55ec85b62 100644 --- a/drivers/gpu/drm/radeon/radeon_uvd.c +++ b/drivers/gpu/drm/radeon/radeon_uvd.c | |||
@@ -117,7 +117,7 @@ int radeon_uvd_init(struct radeon_device *rdev) | |||
117 | bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) + | 117 | bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) + |
118 | RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; | 118 | RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; |
119 | r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, | 119 | r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, |
120 | RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo); | 120 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, &rdev->uvd.vcpu_bo); |
121 | if (r) { | 121 | if (r) { |
122 | dev_err(rdev->dev, "(%d) failed to allocate UVD bo\n", r); | 122 | dev_err(rdev->dev, "(%d) failed to allocate UVD bo\n", r); |
123 | return r; | 123 | return r; |
@@ -674,7 +674,7 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring, | |||
674 | int r, i; | 674 | int r, i; |
675 | 675 | ||
676 | r = radeon_bo_create(rdev, 1024, PAGE_SIZE, true, | 676 | r = radeon_bo_create(rdev, 1024, PAGE_SIZE, true, |
677 | RADEON_GEM_DOMAIN_VRAM, NULL, &bo); | 677 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, &bo); |
678 | if (r) | 678 | if (r) |
679 | return r; | 679 | return r; |
680 | 680 | ||
@@ -720,7 +720,7 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring, | |||
720 | int r, i; | 720 | int r, i; |
721 | 721 | ||
722 | r = radeon_bo_create(rdev, 1024, PAGE_SIZE, true, | 722 | r = radeon_bo_create(rdev, 1024, PAGE_SIZE, true, |
723 | RADEON_GEM_DOMAIN_VRAM, NULL, &bo); | 723 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, &bo); |
724 | if (r) | 724 | if (r) |
725 | return r; | 725 | return r; |
726 | 726 | ||
diff --git a/drivers/gpu/drm/radeon/radeon_vce.c b/drivers/gpu/drm/radeon/radeon_vce.c index aa21c31a846c..f9b70a43aa52 100644 --- a/drivers/gpu/drm/radeon/radeon_vce.c +++ b/drivers/gpu/drm/radeon/radeon_vce.c | |||
@@ -126,7 +126,7 @@ int radeon_vce_init(struct radeon_device *rdev) | |||
126 | size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size) + | 126 | size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size) + |
127 | RADEON_VCE_STACK_SIZE + RADEON_VCE_HEAP_SIZE; | 127 | RADEON_VCE_STACK_SIZE + RADEON_VCE_HEAP_SIZE; |
128 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, | 128 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, |
129 | RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->vce.vcpu_bo); | 129 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, &rdev->vce.vcpu_bo); |
130 | if (r) { | 130 | if (r) { |
131 | dev_err(rdev->dev, "(%d) failed to allocate VCE bo\n", r); | 131 | dev_err(rdev->dev, "(%d) failed to allocate VCE bo\n", r); |
132 | return r; | 132 | return r; |
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c index 725d3669014f..f0a8cd7a83a6 100644 --- a/drivers/gpu/drm/radeon/radeon_vm.c +++ b/drivers/gpu/drm/radeon/radeon_vm.c | |||
@@ -510,7 +510,7 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev, | |||
510 | 510 | ||
511 | r = radeon_bo_create(rdev, RADEON_VM_PTE_COUNT * 8, | 511 | r = radeon_bo_create(rdev, RADEON_VM_PTE_COUNT * 8, |
512 | RADEON_GPU_PAGE_SIZE, true, | 512 | RADEON_GPU_PAGE_SIZE, true, |
513 | RADEON_GEM_DOMAIN_VRAM, NULL, &pt); | 513 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, &pt); |
514 | if (r) | 514 | if (r) |
515 | return r; | 515 | return r; |
516 | 516 | ||
@@ -858,6 +858,7 @@ int radeon_vm_bo_update(struct radeon_device *rdev, | |||
858 | 858 | ||
859 | bo_va->flags &= ~RADEON_VM_PAGE_VALID; | 859 | bo_va->flags &= ~RADEON_VM_PAGE_VALID; |
860 | bo_va->flags &= ~RADEON_VM_PAGE_SYSTEM; | 860 | bo_va->flags &= ~RADEON_VM_PAGE_SYSTEM; |
861 | bo_va->flags &= ~RADEON_VM_PAGE_SNOOPED; | ||
861 | if (mem) { | 862 | if (mem) { |
862 | addr = mem->start << PAGE_SHIFT; | 863 | addr = mem->start << PAGE_SHIFT; |
863 | if (mem->mem_type != TTM_PL_SYSTEM) { | 864 | if (mem->mem_type != TTM_PL_SYSTEM) { |
@@ -866,6 +867,9 @@ int radeon_vm_bo_update(struct radeon_device *rdev, | |||
866 | } | 867 | } |
867 | if (mem->mem_type == TTM_PL_TT) { | 868 | if (mem->mem_type == TTM_PL_TT) { |
868 | bo_va->flags |= RADEON_VM_PAGE_SYSTEM; | 869 | bo_va->flags |= RADEON_VM_PAGE_SYSTEM; |
870 | if (!(bo_va->bo->flags & (RADEON_GEM_GTT_WC | RADEON_GEM_GTT_UC))) | ||
871 | bo_va->flags |= RADEON_VM_PAGE_SNOOPED; | ||
872 | |||
869 | } else { | 873 | } else { |
870 | addr += rdev->vm_manager.vram_base_offset; | 874 | addr += rdev->vm_manager.vram_base_offset; |
871 | } | 875 | } |
@@ -1031,7 +1035,7 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm) | |||
1031 | } | 1035 | } |
1032 | 1036 | ||
1033 | r = radeon_bo_create(rdev, pd_size, align, true, | 1037 | r = radeon_bo_create(rdev, pd_size, align, true, |
1034 | RADEON_GEM_DOMAIN_VRAM, NULL, | 1038 | RADEON_GEM_DOMAIN_VRAM, 0, NULL, |
1035 | &vm->page_directory); | 1039 | &vm->page_directory); |
1036 | if (r) | 1040 | if (r) |
1037 | return r; | 1041 | return r; |
diff --git a/drivers/gpu/drm/radeon/si_dma.c b/drivers/gpu/drm/radeon/si_dma.c index e24c94b6d14d..c9da34181b32 100644 --- a/drivers/gpu/drm/radeon/si_dma.c +++ b/drivers/gpu/drm/radeon/si_dma.c | |||
@@ -79,7 +79,8 @@ void si_dma_vm_set_page(struct radeon_device *rdev, | |||
79 | 79 | ||
80 | trace_radeon_vm_set_page(pe, addr, count, incr, flags); | 80 | trace_radeon_vm_set_page(pe, addr, count, incr, flags); |
81 | 81 | ||
82 | if (flags == R600_PTE_GART) { | 82 | /* XXX: How to distinguish between GART and other system memory pages? */ |
83 | if (flags & R600_PTE_SYSTEM) { | ||
83 | uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8; | 84 | uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8; |
84 | while (count) { | 85 | while (count) { |
85 | unsigned bytes = count * 8; | 86 | unsigned bytes = count * 8; |