Преглед на файлове

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>
Christopher James Halse Rogers преди 8 години
родител
ревизия
803d89ade4
променени са 2 файла, в които са добавени 9 реда и са изтрити 0 реда
  1. 5 0
      drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
  2. 4 0
      drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

+ 5 - 0
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

@@ -729,6 +729,11 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
 		break;
 		break;
 	}
 	}
 	case AMDGPU_GEM_OP_SET_PLACEMENT:
 	case AMDGPU_GEM_OP_SET_PLACEMENT:
+		if (robj->prime_shared_count && (args->value & AMDGPU_GEM_DOMAIN_VRAM)) {
+			r = -EINVAL;
+			amdgpu_bo_unreserve(robj);
+			break;
+		}
 		if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) {
 		if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) {
 			r = -EPERM;
 			r = -EPERM;
 			amdgpu_bo_unreserve(robj);
 			amdgpu_bo_unreserve(robj);

+ 4 - 0
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

@@ -650,6 +650,10 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
 	if (WARN_ON_ONCE(min_offset > max_offset))
 	if (WARN_ON_ONCE(min_offset > max_offset))
 		return -EINVAL;
 		return -EINVAL;
 
 
+	/* A shared bo cannot be migrated to VRAM */
+	if (bo->prime_shared_count && (domain == AMDGPU_GEM_DOMAIN_VRAM))
+		return -EINVAL;
+
 	if (bo->pin_count) {
 	if (bo->pin_count) {
 		uint32_t mem_type = bo->tbo.mem.mem_type;
 		uint32_t mem_type = bo->tbo.mem.mem_type;