diff mbox series

[2/2] drm/amdgpu: raise error on incorrect mem_type

Message ID 20210625172804.3193-2-nirmoy.das@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/amdgpu: return early for preempt type BOs | expand

Commit Message

Das, Nirmoy June 25, 2021, 5:28 p.m. UTC
Be more defensive and raise error on wrong mem_type
argument in amdgpu_gtt_mgr_has_gart_addr().

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 543000304a1c..0b0fa87b115c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -107,8 +107,12 @@  const struct attribute_group amdgpu_gtt_mgr_attr_group = {
  */
 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *res)
 {
-	struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(res);
+	struct amdgpu_gtt_node *node;
+
+	if (WARN_ON(res->mem_type != TTM_PL_TT))
+		return false;
 
+	node = to_amdgpu_gtt_node(res);
 	return drm_mm_node_allocated(&node->base.mm_nodes[0]);
 }