[PATCH 25/26] drm/radeon: keep the cs relocs inside the ib

Christian König deathsimple at vodafone.de
Wed Apr 25 05:46:42 PDT 2012


Free them wenn the ib is freed, another
step to better debugging.

Signed-off-by: Christian König <deathsimple at vodafone.de>
---
 drivers/gpu/drm/radeon/radeon.h      |    3 +++
 drivers/gpu/drm/radeon/radeon_cs.c   |   14 ++++++++++++--
 drivers/gpu/drm/radeon/radeon_ring.c |    3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 21b9a75..6070c3e 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -576,6 +576,7 @@ void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
 /*
  * CP & rings.
  */
+struct radeon_cs_reloc;
 
 struct radeon_ib {
 	struct radeon_sa_bo	sa_bo;
@@ -585,6 +586,8 @@ struct radeon_ib {
 	struct radeon_fence	*fence;
 	unsigned		vm_id;
 	bool			is_const_ib;
+	unsigned		nrelocs;
+	struct radeon_cs_reloc	*relocs;
 };
 
 struct radeon_ring {
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index c3273b8..a3ce65a 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -313,7 +313,6 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error)
 		}
 	}
 	kfree(parser->track);
-	kfree(parser->relocs);
 	kfree(parser->relocs_ptr);
 	for (i = 0; i < parser->nchunks; i++) {
 		kfree(parser->chunks[i].kdata);
@@ -324,7 +323,18 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error)
 	}
 	kfree(parser->chunks);
 	kfree(parser->chunks_array);
-	radeon_ib_free(parser->rdev, &parser->ib);
+
+	if (parser->ib) {
+		/* keep the relocs for debugging */
+		parser->ib->nrelocs = parser->nrelocs;
+		parser->ib->relocs = parser->relocs;
+
+		/* even if we locally free it the ib stays
+		   alive until it is processed */
+		radeon_ib_free(parser->rdev, &parser->ib);
+	} else {
+		kfree(parser->relocs);
+	}
 }
 
 static int radeon_cs_ib_chunk(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 992a615..1c4348c 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -97,6 +97,8 @@ int radeon_ib_get(struct radeon_device *rdev, int ring,
 	(*ib)->gpu_addr += (*ib)->sa_bo.offset;
 	(*ib)->vm_id = 0;
 	(*ib)->is_const_ib = false;
+	(*ib)->nrelocs = 0;
+	(*ib)->relocs = NULL;
 
 	return 0;
 }
@@ -118,6 +120,7 @@ void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib)
 	if (destroy) {
 		radeon_sa_bo_free(rdev, &tmp->sa_bo);
 		radeon_fence_unref(&tmp->fence);
+		kfree(tmp->relocs);
 		kfree(tmp);
 	}
 }
-- 
1.7.5.4



More information about the dri-devel mailing list