aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <christopher.halse.rogers@canonical.com>2017-04-02 23:31:22 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-04-07 12:20:39 -0400
commit803d89ade4ede131405c57ec1a1db32673995b2e (patch)
treec1dbe6e11f0417731240688e2c77fdcf374967ea
parent1769152ac64b0b07583f696b621624df2ca4c840 (diff)
drm/amdgpu: Refuse to pin or change acceptable domains of prime BOs to VRAM. (v2)
Migration to VRAM will break the sharing, resulting in rendering on the exporting GPU never becoming visible on the importing GPU. v2: Don't pin BOs to GTT. Instead, refuse to migrate them out of GTT. Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index bb710e0ace01..03a9c5cad222 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -729,6 +729,11 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
729 break; 729 break;
730 } 730 }
731 case AMDGPU_GEM_OP_SET_PLACEMENT: 731 case AMDGPU_GEM_OP_SET_PLACEMENT:
732 if (robj->prime_shared_count && (args->value & AMDGPU_GEM_DOMAIN_VRAM)) {
733 r = -EINVAL;
734 amdgpu_bo_unreserve(robj);
735 break;
736 }
732 if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { 737 if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) {
733 r = -EPERM; 738 r = -EPERM;
734 amdgpu_bo_unreserve(robj); 739 amdgpu_bo_unreserve(robj);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 758d8cf8fd17..cb89fff863c0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -650,6 +650,10 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
650 if (WARN_ON_ONCE(min_offset > max_offset)) 650 if (WARN_ON_ONCE(min_offset > max_offset))
651 return -EINVAL; 651 return -EINVAL;
652 652
653 /* A shared bo cannot be migrated to VRAM */
654 if (bo->prime_shared_count && (domain == AMDGPU_GEM_DOMAIN_VRAM))
655 return -EINVAL;
656
653 if (bo->pin_count) { 657 if (bo->pin_count) {
654 uint32_t mem_type = bo->tbo.mem.mem_type; 658 uint32_t mem_type = bo->tbo.mem.mem_type;
655 659