[PATCH 3/6] drm/amdgpu: disallow foreign BOs in the display path v2

Felix Kuehling Felix.Kuehling at amd.com
Wed Jul 19 02:22:10 UTC 2017


From: Christian König <christian.koenig at amd.com>

Pinning them in other devices VRAM would obviously not work.

v2: Add checks to DC code paths

Signed-off-by: Christian König <christian.koenig at amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c             | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c                  | 5 +++++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c                  | 5 +++++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c                   | 5 +++++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c                   | 5 +++++
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 5 +++++
 6 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 3341c34..bd6b0dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -180,6 +180,12 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
 	obj = new_amdgpu_fb->obj;
 	new_abo = gem_to_amdgpu_bo(obj);
 
+	if (amdgpu_ttm_adev(new_abo->tbo.bdev) != adev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		r = -EINVAL;
+		goto cleanup;
+	}
+
 	/* pin the new buffer */
 	r = amdgpu_bo_reserve(new_abo, false);
 	if (unlikely(r != 0)) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index 3bcdbb7..2c0f04d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -1915,6 +1915,11 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,
 	 */
 	obj = amdgpu_fb->obj;
 	abo = gem_to_amdgpu_bo(obj);
+	if (amdgpu_ttm_adev(abo->tbo.bdev) != adev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		return -EINVAL;
+	}
+
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
 		return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 039de10..c3d0eaa 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -1954,6 +1954,11 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,
 	 */
 	obj = amdgpu_fb->obj;
 	abo = gem_to_amdgpu_bo(obj);
+	if (amdgpu_ttm_adev(abo->tbo.bdev) != adev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		return -EINVAL;
+	}
+
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
 		return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index 5b525c9..76daa5a 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -1868,6 +1868,11 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,
 	 */
 	obj = amdgpu_fb->obj;
 	abo = gem_to_amdgpu_bo(obj);
+	if (amdgpu_ttm_adev(abo->tbo.bdev) != adev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		return -EINVAL;
+	}
+
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
 		return r;
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index 092ee37..929b040 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -1846,6 +1846,11 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,
 	 */
 	obj = amdgpu_fb->obj;
 	abo = gem_to_amdgpu_bo(obj);
+	if (amdgpu_ttm_adev(abo->tbo.bdev) != adev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		return -EINVAL;
+	}
+
 	r = amdgpu_bo_reserve(abo, false);
 	if (unlikely(r != 0))
 		return r;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index 8b499cc..770018a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -1621,6 +1621,11 @@ static int dm_plane_helper_prepare_fb(
 
 	obj = afb->obj;
 	rbo = gem_to_amdgpu_bo(obj);
+	if (amdgpu_ttm_adev(rbo->tbo.bdev)->ddev != plane->dev) {
+		DRM_ERROR("Foreign BOs not allowed in the display engine\n");
+		return -EINVAL;
+	}
+
 	r = amdgpu_bo_reserve(rbo, false);
 	if (unlikely(r != 0))
 		return r;
-- 
1.9.1



More information about the dri-devel mailing list