Skip to contentSkip to conversation

Include request for reset-rework branch v3

PATCH New [email protected] 4 participants 20 messages May 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Cheers,
Jerome

#1 lore raw

PATCH 1/13 drm/radeon: make radeon_gpu_is_lockup a per ring function

From: Christian König <[email protected]>

Different rings have different criteria to test if they are stuck.

v2: rebased on current drm-next

---
 drivers/gpu/drm/radeon/radeon.h       |    4 +-
 drivers/gpu/drm/radeon/radeon_asic.c  |   44 ++++++++++++++++++--------------
 drivers/gpu/drm/radeon/radeon_fence.c |    2 +-
 3 files changed, 28 insertions(+), 22 deletions(-)
drivers/gpu/drm/radeon/radeon.h +2 -2
index 138b952..bea99e3 100644
@@ -1144,7 +1144,6 @@ struct radeon_asic {
 	int (*resume)(struct radeon_device *rdev);
 	int (*suspend)(struct radeon_device *rdev);
 	void (*vga_set_state)(struct radeon_device *rdev, bool state);
-	bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
 	int (*asic_reset)(struct radeon_device *rdev);
 	/* ioctl hw specific callback. Some hw might want to perform special
 	 * operation on specific ioctl. For instance on wait idle some hw
@@ -1173,6 +1172,7 @@ struct radeon_asic {
 		void (*ring_start)(struct radeon_device *rdev, struct radeon_ring *cp);
 		int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
 		int (*ib_test)(struct radeon_device *rdev, struct radeon_ring *cp);
+		bool (*is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
 	} ring[RADEON_NUM_RINGS];
 	/* irqs */
 	struct {
@@ -1730,7 +1730,6 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
 #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
 #define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
-#define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), (cp))
 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
 #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
 #define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), (i), (p))
@@ -1739,6 +1738,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
 #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), (cp))
 #define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
 #define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
+#define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp))
 #define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
 #define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
 #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
drivers/gpu/drm/radeon/radeon_asic.c +25 -19

308 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 4bd36a3..66b2229 100644
@@ -259,7 +259,7 @@ retry:
 		 * if we experiencing a lockup the value doesn't change
 		 */
 		if (seq == rdev->fence_drv[fence->ring].last_seq &&
-		    radeon_gpu_is_lockup(rdev, &rdev->ring[fence->ring])) {
+		    radeon_ring_is_lockup(rdev, fence->ring, &rdev->ring[fence->ring])) {
 			/* good news we believe it's a lockup */
 			printk(KERN_WARNING "GPU lockup (waiting for 0x%08X last fence id 0x%08X)\n",
 			     fence->seq, seq);
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 2/13 drm/radeon: replace gpu_lockup with ring->ready flag

In reply to [email protected]

From: Christian König <[email protected]>

It makes no sense at all to have more than one flag.

---
 drivers/gpu/drm/radeon/r100.c          |    1 -
 drivers/gpu/drm/radeon/r300.c          |    1 -
 drivers/gpu/drm/radeon/radeon.h        |    1 -
 drivers/gpu/drm/radeon/radeon_device.c |    1 -
 drivers/gpu/drm/radeon/radeon_fence.c  |   36 +++++++++++--------------------
 drivers/gpu/drm/radeon/rs600.c         |    1 -
 6 files changed, 13 insertions(+), 28 deletions(-)
drivers/gpu/drm/radeon/r100.c +0 -1
index fe33d35..6573e28 100644
@@ -2296,7 +2296,6 @@ int r100_asic_reset(struct radeon_device *rdev)
 	if (G_000E40_SE_BUSY(status) || G_000E40_RE_BUSY(status) ||
 		G_000E40_TAM_BUSY(status) || G_000E40_PB_BUSY(status)) {
 		dev_err(rdev->dev, "failed to reset GPU\n");
-		rdev->gpu_lockup = true;
 		ret = -1;
 	} else
 		dev_info(rdev->dev, "GPU reset succeed\n");
drivers/gpu/drm/radeon/r300.c +0 -1
index fa14383..a63f432 100644
@@ -449,7 +449,6 @@ int r300_asic_reset(struct radeon_device *rdev)
 	/* Check if GPU is idle */
 	if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) {
 		dev_err(rdev->dev, "failed to reset GPU\n");
-		rdev->gpu_lockup = true;
 		ret = -1;
 	} else
 		dev_info(rdev->dev, "GPU reset succeed\n");
drivers/gpu/drm/radeon/radeon.h +0 -1
index bea99e3..365334b 100644
@@ -1529,7 +1529,6 @@ struct radeon_device {
 	struct radeon_mutex		cs_mutex;
 	struct radeon_wb		wb;
 	struct radeon_dummy_page	dummy_page;
-	bool				gpu_lockup;
 	bool				shutdown;
 	bool				suspend;
 	bool				need_dma32;
drivers/gpu/drm/radeon/radeon_device.c +0 -1
index ea7df16..eb63a06 100644
@@ -714,7 +714,6 @@ int radeon_device_init(struct radeon_device *rdev,
 	rdev->is_atom_bios = false;
 	rdev->usec_timeout = RADEON_MAX_USEC_TIMEOUT;
 	rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
-	rdev->gpu_lockup = false;
 	rdev->accel_working = false;
 
 	DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X).\n",
drivers/gpu/drm/radeon/radeon_fence.c +13 -23
index 66b2229..36c411f 100644
@@ -71,14 +71,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence *fence)
 		return 0;
 	}
 	fence->seq = atomic_add_return(1, &rdev->fence_drv[fence->ring].seq);
-	if (!rdev->ring[fence->ring].ready)
-		/* FIXME: cp is not running assume everythings is done right
-		 * away
-		 */
-		radeon_fence_write(rdev, fence->seq, fence->ring);
-	else
-		radeon_fence_ring_emit(rdev, fence->ring, fence);
-
+	radeon_fence_ring_emit(rdev, fence->ring, fence);
 	trace_radeon_fence_emit(rdev->ddev, fence->seq);
 	fence->emitted = true;
 	list_move_tail(&fence->list, &rdev->fence_drv[fence->ring].emitted);
@@ -191,9 +184,6 @@ bool radeon_fence_signaled(struct radeon_fence *fence)
 	if (!fence)
 		return true;
 
-	if (fence->rdev->gpu_lockup)
-		return true;
-
 	write_lock_irqsave(&fence->rdev->fence_lock, irq_flags);
 	signaled = fence->signaled;
 	/* if we are shuting down report all fence as signaled */
@@ -260,18 +250,16 @@ retry:
 		 */
 		if (seq == rdev->fence_drv[fence->ring].last_seq &&
 		    radeon_ring_is_lockup(rdev, fence->ring, &rdev->ring[fence->ring])) {
+
 			/* good news we believe it's a lockup */
 			printk(KERN_WARNING "GPU lockup (waiting for 0x%08X last fence id 0x%08X)\n",
 			     fence->seq, seq);
-			/* FIXME: what should we do ? marking everyone
-			 * as signaled for now
-			 */
-			rdev->gpu_lockup = true;
+
+			/* mark the ring as not ready any more */
+			rdev->ring[fence->ring].ready = false;
 			r = radeon_gpu_reset(rdev);
 			if (r)
 				return r;
-			radeon_fence_write(rdev, fence->seq, fence->ring);
-			rdev->gpu_lockup = false;
 		}
 		timeout = RADEON_FENCE_JIFFIES_TIMEOUT;
 		write_lock_irqsave(&rdev->fence_lock, irq_flags);
@@ -289,10 +277,11 @@ int radeon_fence_wait_next(struct radeon_device *rdev, int ring)
 	struct radeon_fence *fence;
 	int r;
 
-	if (rdev->gpu_lockup) {
-		return 0;
-	}
 	write_lock_irqsave(&rdev->fence_lock, irq_flags);
+	if (!rdev->ring[ring].ready) {
+		write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
+		return -EBUSY;
+	}
 	if (list_empty(&rdev->fence_drv[ring].emitted)) {
 		write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
 		return 0;
@@ -312,10 +301,11 @@ int radeon_fence_wait_last(struct radeon_device *rdev, int ring)
 	struct radeon_fence *fence;
 	int r;
 
-	if (rdev->gpu_lockup) {
-		return 0;
-	}
 	write_lock_irqsave(&rdev->fence_lock, irq_flags);
+	if (!rdev->ring[ring].ready) {
+		write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
+		return -EBUSY;
+	}
 	if (list_empty(&rdev->fence_drv[ring].emitted)) {
 		write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
 		return 0;
drivers/gpu/drm/radeon/rs600.c +0 -1
index d25cf86..f709fe8 100644
@@ -396,7 +396,6 @@ int rs600_asic_reset(struct radeon_device *rdev)
 	/* Check if GPU is idle */
 	if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) {
 		dev_err(rdev->dev, "failed to reset GPU\n");
-		rdev->gpu_lockup = true;
 		ret = -1;
 	} else
 		dev_info(rdev->dev, "GPU reset succeed\n");
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 3/13 drm/radeon: register ring debugfs handlers on init

In reply to [email protected]

From: Christian König <[email protected]>

Just register the debugfs files on init instead of checking the chipset type multiple times.

---
 drivers/gpu/drm/radeon/radeon_ring.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/radeon_ring.c +19 -12
index cc33b3d..b6eb1d2 100644
@@ -34,7 +34,7 @@
 #include "atom.h"
 
 int radeon_debugfs_ib_init(struct radeon_device *rdev);
-int radeon_debugfs_ring_init(struct radeon_device *rdev);
+int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring);
 
 u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
 {
@@ -237,9 +237,6 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
 	if (radeon_debugfs_ib_init(rdev)) {
 		DRM_ERROR("Failed to register debugfs file for IB !\n");
 	}
-	if (radeon_debugfs_ring_init(rdev)) {
-		DRM_ERROR("Failed to register debugfs file for rings !\n");
-	}
 	radeon_mutex_unlock(&rdev->ib_pool.mutex);
 	return 0;
 }
@@ -411,6 +408,9 @@ int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsig
 	}
 	ring->ptr_mask = (ring->ring_size / 4) - 1;
 	ring->ring_free_dw = ring->ring_size / 4;
+	if (radeon_debugfs_ring_init(rdev, ring)) {
+		DRM_ERROR("Failed to register debugfs file for rings !\n");
+	}
 	return 0;
 }
 
@@ -501,17 +501,24 @@ static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
 static unsigned radeon_debugfs_ib_idx[RADEON_IB_POOL_SIZE];
 #endif
 
-int radeon_debugfs_ring_init(struct radeon_device *rdev)
+int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring)
 {
 #if defined(CONFIG_DEBUG_FS)
-	if (rdev->family >= CHIP_CAYMAN)
-		return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list,
-						ARRAY_SIZE(radeon_debugfs_ring_info_list));
-	else
-		return radeon_debugfs_add_files(rdev, radeon_debugfs_ring_info_list, 1);
-#else
-	return 0;
+	unsigned i;
+	for (i = 0; i < ARRAY_SIZE(radeon_debugfs_ring_info_list); ++i) {
+		struct drm_info_list *info = &radeon_debugfs_ring_info_list[i];
+		int ridx = *(int*)radeon_debugfs_ring_info_list[i].data;
+		unsigned r;
+
+		if (&rdev->ring[ridx] != ring)
+			continue;
+
+		r = radeon_debugfs_add_files(rdev, info, 1);
+		if (r)
+			return r;
+	}
 #endif
+	return 0;
 }
 
 int radeon_debugfs_ib_init(struct radeon_device *rdev)
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH 4/13 drm/radeon: use central function for IB testing

In reply to [email protected]

From: Christian König <[email protected]>

Removing all the different error messages and having just one standard behaviour over all chipset generations.

---
 drivers/gpu/drm/radeon/evergreen.c   |    7 ++-----
 drivers/gpu/drm/radeon/ni.c          |    7 ++-----
 drivers/gpu/drm/radeon/r100.c        |    7 ++-----
 drivers/gpu/drm/radeon/r300.c        |    7 ++-----
 drivers/gpu/drm/radeon/r420.c        |    7 ++-----
 drivers/gpu/drm/radeon/r520.c        |    8 +++-----
 drivers/gpu/drm/radeon/r600.c        |    7 ++-----
 drivers/gpu/drm/radeon/radeon.h      |    1 +
 drivers/gpu/drm/radeon/radeon_ring.c |   30 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/rs400.c       |    7 ++-----
 drivers/gpu/drm/radeon/rs600.c       |    7 ++-----
 drivers/gpu/drm/radeon/rs690.c       |    7 ++-----
 drivers/gpu/drm/radeon/rv515.c       |    8 +++-----
 drivers/gpu/drm/radeon/rv770.c       |    7 ++-----
 14 files changed, 57 insertions(+), 60 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +2 -5
index cfa372c..ca47f52 100644
@@ -3248,12 +3248,9 @@ static int evergreen_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		DRM_ERROR("radeon: failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	r = r600_audio_init(rdev);
 	if (r) {
drivers/gpu/drm/radeon/ni.c +2 -5
index a48ca53..0146428 100644
@@ -1601,12 +1601,9 @@ static int cayman_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		DRM_ERROR("radeon: failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	r = radeon_vm_manager_start(rdev);
 	if (r)
drivers/gpu/drm/radeon/r100.c +2 -5
index 6573e28..ac53bd8 100644
@@ -3964,12 +3964,9 @@ static int r100_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/r300.c +2 -5
index a63f432..26e0db8 100644
@@ -1417,12 +1417,9 @@ static int r300_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/r420.c +2 -5
index f3fcaac..99137be 100644
@@ -279,12 +279,9 @@ static int r420_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/r520.c +3 -5
index ebcc15b..b5cf837 100644
@@ -207,12 +207,10 @@ static int r520_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
+
 	return 0;
 }
 
drivers/gpu/drm/radeon/r600.c +2 -5
index c8187c4..06eccd1 100644
@@ -2494,12 +2494,9 @@ int r600_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		DRM_ERROR("radeon: failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/radeon.h +1 -0
index 365334b..8801657 100644
@@ -793,6 +793,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev);
 void radeon_ib_pool_fini(struct radeon_device *rdev);
 int radeon_ib_pool_start(struct radeon_device *rdev);
 int radeon_ib_pool_suspend(struct radeon_device *rdev);
+int radeon_ib_ring_tests(struct radeon_device *rdev);
 /* Ring access between begin & end cannot sleep */
 int radeon_ring_index(struct radeon_device *rdev, struct radeon_ring *cp);
 void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
drivers/gpu/drm/radeon/radeon_ring.c +30 -0
index b6eb1d2..1b020ef 100644
@@ -267,6 +267,36 @@ int radeon_ib_pool_suspend(struct radeon_device *rdev)
 	return radeon_sa_bo_manager_suspend(rdev, &rdev->ib_pool.sa_manager);
 }
 
+int radeon_ib_ring_tests(struct radeon_device *rdev)
+{
+	unsigned i;
+	int r;
+
+	for (i = 0; i < RADEON_NUM_RINGS; ++i) {
+		struct radeon_ring *ring = &rdev->ring[i];
+
+		if (!ring->ready)
+			continue;
+
+		r = radeon_ib_test(rdev, i, ring);
+		if (r) {
+			ring->ready = false;
+
+			if (i == RADEON_RING_TYPE_GFX_INDEX) {
+				/* oh, oh, that's really bad */
+				DRM_ERROR("radeon: failed testing IB on GFX ring (%d).\n", r);
+		                rdev->accel_working = false;
+				return r;
+
+			} else {
+				/* still not good, but we can live with it */
+				DRM_ERROR("radeon: failed testing IB on ring %d (%d).\n", i, r);
+			}
+		}
+	}
+	return 0;
+}
+
 /*
  * Ring.
  */
drivers/gpu/drm/radeon/rs400.c +2 -5
index 4cf381b..a464eb5 100644
@@ -430,12 +430,9 @@ static int rs400_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/rs600.c +2 -5
index f709fe8..a286dea 100644
@@ -882,12 +882,9 @@ static int rs600_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/rs690.c +2 -5
index f2c3b9d..3277dde 100644
@@ -647,12 +647,9 @@ static int rs690_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
drivers/gpu/drm/radeon/rv515.c +3 -5
index d8d78fe..7f08ced 100644
@@ -412,12 +412,10 @@ static int rv515_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "failed testing IB (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
+
 	return 0;
 }
 
drivers/gpu/drm/radeon/rv770.c +2 -5
index cdab1ae..a8b0016 100644
@@ -1114,12 +1114,9 @@ static int rv770_startup(struct radeon_device *rdev)
 	if (r)
 		return r;
 
-	r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
-	if (r) {
-		dev_err(rdev->dev, "IB test failed (%d).\n", r);
-		rdev->accel_working = false;
+	r = radeon_ib_ring_tests(rdev);
+	if (r)
 		return r;
-	}
 
 	return 0;
 }
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

PATCH 5/13 drm/radeon: rework gpu lockup detection and processing

In reply to [email protected]

From: Christian König <[email protected]>

Previusly multiple rings could trigger multiple GPU resets at the same time.

---
 drivers/gpu/drm/radeon/radeon.h       |    3 +-
 drivers/gpu/drm/radeon/radeon_fence.c |  150 +++++++++++++++++----------------
 2 files changed, 77 insertions(+), 76 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -2
index 8801657..85a3aa9 100644
@@ -255,8 +255,7 @@ struct radeon_fence_driver {
 	volatile uint32_t		*cpu_addr;
 	atomic_t			seq;
 	uint32_t			last_seq;
-	unsigned long			last_jiffies;
-	unsigned long			last_timeout;
+	unsigned long			last_activity;
 	wait_queue_head_t		queue;
 	struct list_head		created;
 	struct list_head		emitted;
drivers/gpu/drm/radeon/radeon_fence.c +76 -74

182 lines not on this page · raw message

Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

PATCH 6/13 drm/radeon: fix a bug in the SA code

In reply to [email protected]

From: Christian König <[email protected]>

Aligning offset can make it bigger than tmp->offset leading to an overrun bug in the following subtraction.

v2: Against initial suspicions this can't happen in mainline,
so no need to push it into stable.

---
 drivers/gpu/drm/radeon/radeon_sa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/radeon_sa.c +1 -1
index 4cce47e..8fbfe69 100644
@@ -150,7 +150,7 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
 	offset = 0;
 	list_for_each_entry(tmp, &sa_manager->sa_bo, list) {
 		/* room before this object ? */
-		if ((tmp->offset - offset) >= size) {
+		if (offset < tmp->offset && (tmp->offset - offset) >= size) {
 			head = tmp->list.prev;
 			goto out;
 		}
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

PATCH 7/13 drm/radeon: add proper locking to the SA

In reply to [email protected]

From: Christian König <[email protected]>

Make the suballocator self containing to locking.

v2: split the bugfix into a seperate patch.

---
 drivers/gpu/drm/radeon/radeon.h    |    1 +
 drivers/gpu/drm/radeon/radeon_sa.c |   17 +++++++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -0
index 85a3aa9..1aefbd9 100644
@@ -381,6 +381,7 @@ struct radeon_bo_list {
  * alignment).
  */
 struct radeon_sa_manager {
+	spinlock_t		lock;
 	struct radeon_bo	*bo;
 	struct list_head	sa_bo;
 	unsigned		size;
drivers/gpu/drm/radeon/radeon_sa.c +11 -6
index 8fbfe69..472d346 100644
@@ -37,6 +37,7 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev,
 {
 	int r;
 
+	spin_lock_init(&sa_manager->lock);
 	sa_manager->bo = NULL;
 	sa_manager->size = size;
 	sa_manager->domain = domain;
@@ -139,15 +140,15 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
 
 	BUG_ON(align > RADEON_GPU_PAGE_SIZE);
 	BUG_ON(size > sa_manager->size);
+	spin_lock(&sa_manager->lock);
 
 	/* no one ? */
-	head = sa_manager->sa_bo.prev;
 	if (list_empty(&sa_manager->sa_bo)) {
+		head = &sa_manager->sa_bo;
 		goto out;
 	}
 
 	/* look for a hole big enough */
-	offset = 0;
 	list_for_each_entry(tmp, &sa_manager->sa_bo, list) {
 		/* room before this object ? */
 		if (offset < tmp->offset && (tmp->offset - offset) >= size) {
@@ -157,9 +158,8 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
 		offset = tmp->offset + tmp->size;
 		wasted = offset % align;
 		if (wasted) {
-			wasted = align - wasted;
+			offset += align - wasted;
 		}
-		offset += wasted;
 	}
 	/* room at the end ? */
 	head = sa_manager->sa_bo.prev;
@@ -167,11 +167,11 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
 	offset = tmp->offset + tmp->size;
 	wasted = offset % align;
 	if (wasted) {
-		wasted = align - wasted;
+		offset += wasted = align - wasted;
 	}
-	offset += wasted;
 	if ((sa_manager->size - offset) < size) {
 		/* failed to find somethings big enough */
+		spin_unlock(&sa_manager->lock);
 		return -ENOMEM;
 	}
 
@@ -180,10 +180,15 @@ out:
 	sa_bo->offset = offset;
 	sa_bo->size = size;
 	list_add(&sa_bo->list, head);
+	spin_unlock(&sa_manager->lock);
 	return 0;
 }
 
 void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo *sa_bo)
 {
+	struct radeon_sa_manager *sa_manager = sa_bo->manager;
+
+	spin_lock(&sa_manager->lock);
 	list_del_init(&sa_bo->list);
+	spin_unlock(&sa_manager->lock);
 }
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

PATCH 8/13 drm/radeon: add sub allocator debugfs file

In reply to [email protected]

From: Christian König <[email protected]>

Dumping the current allocations.

---
 drivers/gpu/drm/radeon/radeon_object.h |    5 +++++
 drivers/gpu/drm/radeon/radeon_ring.c   |   22 ++++++++++++++++++++++
 drivers/gpu/drm/radeon/radeon_sa.c     |   14 ++++++++++++++
 3 files changed, 41 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/radeon_object.h +5 -0
index f9104be..d9b9333 100644
@@ -161,5 +161,10 @@ extern int radeon_sa_bo_new(struct radeon_device *rdev,
 			    unsigned size, unsigned align);
 extern void radeon_sa_bo_free(struct radeon_device *rdev,
 			      struct radeon_sa_bo *sa_bo);
+#if defined(CONFIG_DEBUG_FS)
+extern void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager,
+					 struct seq_file *m);
+#endif
+
 
 #endif
drivers/gpu/drm/radeon/radeon_ring.c +22 -0
index 1b020ef..1d9bce9 100644
@@ -529,6 +529,23 @@ static int radeon_debugfs_ib_info(struct seq_file *m, void *data)
 static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE];
 static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
 static unsigned radeon_debugfs_ib_idx[RADEON_IB_POOL_SIZE];
+
+static int radeon_debugfs_sa_info(struct seq_file *m, void *data)
+{
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct radeon_device *rdev = dev->dev_private;
+
+	radeon_sa_bo_dump_debug_info(&rdev->ib_pool.sa_manager, m);
+
+	return 0;
+
+}
+
+static struct drm_info_list radeon_debugfs_sa_list[] = {
+        {"radeon_sa_info", &radeon_debugfs_sa_info, 0, NULL},
+};
+
 #endif
 
 int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring)
@@ -555,6 +572,11 @@ int radeon_debugfs_ib_init(struct radeon_device *rdev)
 {
 #if defined(CONFIG_DEBUG_FS)
 	unsigned i;
+	int r;
+
+	r = radeon_debugfs_add_files(rdev, radeon_debugfs_sa_list, 1);
+	if (r)
+		return r;
 
 	for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
 		sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i);
drivers/gpu/drm/radeon/radeon_sa.c +14 -0
index 472d346..1e1bec1 100644
@@ -192,3 +192,17 @@ void radeon_sa_bo_free(struct radeon_device *rdev, struct radeon_sa_bo *sa_bo)
 	list_del_init(&sa_bo->list);
 	spin_unlock(&sa_manager->lock);
 }
+
+#if defined(CONFIG_DEBUG_FS)
+void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager,
+				  struct seq_file *m)
+{
+	struct radeon_sa_bo *i;
+
+	spin_lock(&sa_manager->lock);
+	list_for_each_entry(i, &sa_manager->sa_bo, list) {
+		seq_printf(m, "offset %08d: size %4d\n", i->offset, i->size);
+	}
+	spin_unlock(&sa_manager->lock);
+}
+#endif
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH 9/13 drm/radeon: improve sa allocator v2

In reply to [email protected]

From: Jerome Glisse <[email protected]>

The sa allocator is suppose to be a ring allocator, ie allocation happen first at the end and if there is no more room we start at the begining again. This patch make the code match this design. sa_manager keep track of the start & end hole, it first try to allocate in the end hole, if it fails it allocate in the begining hole, if it fails it returns (caller is expected to retry).

When freeing we need to make sure that we properly grow the end hole and start hole. We take advantage of the fact that the sa_bo list is ordered by offset. That means that when we free an sa_bo the previous sa_bo in list is also the sa_bo just before the sa_bo we are freeing and reversly for the next.

v2: Use read ptr metaphore to mimic ring behavior and simplify
code a bit.

---
 drivers/gpu/drm/radeon/radeon.h           |    4 +-
 drivers/gpu/drm/radeon/radeon_cs.c        |    4 +-
 drivers/gpu/drm/radeon/radeon_gart.c      |    6 +-
 drivers/gpu/drm/radeon/radeon_object.h    |   11 +++
 drivers/gpu/drm/radeon/radeon_ring.c      |    6 +-
 drivers/gpu/drm/radeon/radeon_sa.c        |  128 +++++++++++++++++++----------
 drivers/gpu/drm/radeon/radeon_semaphore.c |    4 +-
 7 files changed, 107 insertions(+), 56 deletions(-)
drivers/gpu/drm/radeon/radeon.h +3 -1
index 1aefbd9..dc4f4f3 100644
@@ -385,6 +385,7 @@ struct radeon_sa_manager {
 	struct radeon_bo	*bo;
 	struct list_head	sa_bo;
 	unsigned		size;
+	struct radeon_sa_bo	*last;
 	uint64_t		gpu_addr;
 	void			*cpu_ptr;
 	uint32_t		domain;
@@ -396,7 +397,8 @@ struct radeon_sa_bo;
 struct radeon_sa_bo {
 	struct list_head		list;
 	struct radeon_sa_manager	*manager;
-	unsigned			offset;
+	unsigned			soffset;
+	unsigned			eoffset;
 	unsigned			size;
 };
 
drivers/gpu/drm/radeon/radeon_cs.c +2 -2
index 5cac832..8de6b3a 100644
@@ -476,7 +476,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
 		/* ib pool is bind at 0 in virtual address space to gpu_addr is the
 		 * offset inside the pool bo
 		 */
-		parser->const_ib->gpu_addr = parser->const_ib->sa_bo.offset;
+		parser->const_ib->gpu_addr = parser->const_ib->sa_bo.soffset;
 		r = radeon_ib_schedule(rdev, parser->const_ib);
 		if (r)
 			goto out;
@@ -486,7 +486,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
 	/* ib pool is bind at 0 in virtual address space to gpu_addr is the
 	 * offset inside the pool bo
 	 */
-	parser->ib->gpu_addr = parser->ib->sa_bo.offset;
+	parser->ib->gpu_addr = parser->ib->sa_bo.soffset;
 	parser->ib->is_const_ib = false;
 	r = radeon_ib_schedule(rdev, parser->ib);
 out:
drivers/gpu/drm/radeon/radeon_gart.c +2 -4
index c58a036..4a5d9d4 100644
@@ -404,10 +404,8 @@ retry:
 		radeon_vm_unbind(rdev, vm_evict);
 		goto retry;
 	}
-	vm->pt = rdev->vm_manager.sa_manager.cpu_ptr;
-	vm->pt += (vm->sa_bo.offset >> 3);
-	vm->pt_gpu_addr = rdev->vm_manager.sa_manager.gpu_addr;
-	vm->pt_gpu_addr += vm->sa_bo.offset;
+	vm->pt = radeon_sa_bo_cpu_addr(&vm->sa_bo);
+	vm->pt_gpu_addr = radeon_sa_bo_gpu_addr(&vm->sa_bo);
 	memset(vm->pt, 0, RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8));
 
 retry_id:
drivers/gpu/drm/radeon/radeon_object.h +11 -0
index d9b9333..99ab46a 100644
@@ -146,6 +146,17 @@ extern struct radeon_bo_va *radeon_bo_va(struct radeon_bo *rbo,
 /*
  * sub allocation
  */
+
+static inline uint64_t radeon_sa_bo_gpu_addr(struct radeon_sa_bo *sa_bo)
+{
+	return sa_bo->manager->gpu_addr + sa_bo->soffset;
+}
+
+static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo)
+{
+	return sa_bo->manager->cpu_ptr + sa_bo->soffset;
+}
+
 extern int radeon_sa_bo_manager_init(struct radeon_device *rdev,
 				     struct radeon_sa_manager *sa_manager,
 				     unsigned size, u32 domain);
drivers/gpu/drm/radeon/radeon_ring.c +2 -4
index 1d9bce9..981ab95 100644
@@ -127,10 +127,8 @@ retry:
 					     size, 256);
 			if (!r) {
 				*ib = &rdev->ib_pool.ibs[idx];
-				(*ib)->ptr = rdev->ib_pool.sa_manager.cpu_ptr;
-				(*ib)->ptr += ((*ib)->sa_bo.offset >> 2);
-				(*ib)->gpu_addr = rdev->ib_pool.sa_manager.gpu_addr;
-				(*ib)->gpu_addr += (*ib)->sa_bo.offset;
+				(*ib)->ptr = radeon_sa_bo_cpu_addr(&(*ib)->sa_bo);
+				(*ib)->gpu_addr = radeon_sa_bo_gpu_addr(&(*ib)->sa_bo);
 				(*ib)->fence = fence;
 				(*ib)->vm_id = 0;
 				(*ib)->is_const_ib = false;
drivers/gpu/drm/radeon/radeon_sa.c +85 -43

182 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_semaphore.c +2 -2
index 61dd4e3..c3763e4 100644
@@ -55,9 +55,9 @@ static int radeon_semaphore_add_bo(struct radeon_device *rdev)
 		return r;
 	}
 	gpu_addr = rdev->ib_pool.sa_manager.gpu_addr;
-	gpu_addr += bo->ib->sa_bo.offset;
+	gpu_addr += bo->ib->sa_bo.soffset;
 	cpu_ptr = rdev->ib_pool.sa_manager.cpu_ptr;
-	cpu_ptr += (bo->ib->sa_bo.offset >> 2);
+	cpu_ptr += (bo->ib->sa_bo.soffset >> 2);
 	for (i = 0; i < (RADEON_SEMAPHORE_BO_SIZE/8); i++) {
 		bo->semaphores[i].gpu_addr = gpu_addr;
 		bo->semaphores[i].cpu_ptr = cpu_ptr;
Signature · 1 line
1.7.7.6
#10 lore raw

PATCH 10/13 drm/radeon: return -ENOENT in fence_wait_next v2

In reply to [email protected]

From: Christian König <[email protected]>

We should signal the caller that we haven't waited at all.

v2: only change fence_wait_next not fence_wait_last.

---
 drivers/gpu/drm/radeon/radeon_fence.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/radeon_fence.c +1 -1
index 1a9765a..2fbbc34 100644
@@ -286,7 +286,7 @@ int radeon_fence_wait_next(struct radeon_device *rdev, int ring)
 	}
 	if (list_empty(&rdev->fence_drv[ring].emitted)) {
 		write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
-		return 0;
+		return -ENOENT;
 	}
 	fence = list_entry(rdev->fence_drv[ring].emitted.next,
 			   struct radeon_fence, list);
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH 11/13 drm/radeon: rename fence_wait_last to fence_wait_empty

In reply to [email protected]

From: Christian König <[email protected]>

As discussed with Michel that name better
describes the behavior of this function.

---
 drivers/gpu/drm/radeon/radeon.h        |    2 +-
 drivers/gpu/drm/radeon/radeon_device.c |    2 +-
 drivers/gpu/drm/radeon/radeon_fence.c  |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon.h +1 -1
index dc4f4f3..f1a9bd0 100644
@@ -285,7 +285,7 @@ void radeon_fence_process(struct radeon_device *rdev, int ring);
 bool radeon_fence_signaled(struct radeon_fence *fence);
 int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
 int radeon_fence_wait_next(struct radeon_device *rdev, int ring);
-int radeon_fence_wait_last(struct radeon_device *rdev, int ring);
+int radeon_fence_wait_empty(struct radeon_device *rdev, int ring);
 struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
 void radeon_fence_unref(struct radeon_fence **fence);
 int radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
drivers/gpu/drm/radeon/radeon_device.c +1 -1
index eb63a06..f6f9d6c 100644
@@ -915,7 +915,7 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
 	radeon_bo_evict_vram(rdev);
 	/* wait for gpu to finish processing current batch */
 	for (i = 0; i < RADEON_NUM_RINGS; i++)
-		radeon_fence_wait_last(rdev, i);
+		radeon_fence_wait_empty(rdev, i);
 
 	radeon_save_bios_scratch_regs(rdev);
 
drivers/gpu/drm/radeon/radeon_fence.c +2 -2
index 2fbbc34..2d13843 100644
@@ -297,7 +297,7 @@ int radeon_fence_wait_next(struct radeon_device *rdev, int ring)
 	return r;
 }
 
-int radeon_fence_wait_last(struct radeon_device *rdev, int ring)
+int radeon_fence_wait_empty(struct radeon_device *rdev, int ring)
 {
 	unsigned long irq_flags;
 	struct radeon_fence *fence;
@@ -442,7 +442,7 @@ void radeon_fence_driver_fini(struct radeon_device *rdev)
 	for (ring = 0; ring < RADEON_NUM_RINGS; ring++) {
 		if (!rdev->fence_drv[ring].initialized)
 			continue;
-		radeon_fence_wait_last(rdev, ring);
+		radeon_fence_wait_empty(rdev, ring);
 		wake_up_all(&rdev->fence_drv[ring].queue);
 		write_lock_irqsave(&rdev->fence_lock, irq_flags);
 		radeon_scratch_free(rdev, rdev->fence_drv[ring].scratch_reg);
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH 12/13 drm/radeon: don't keep list of created fences.

In reply to [email protected]

From: Christian König <[email protected]>

It's never used and so practically superfluous.

---
 drivers/gpu/drm/radeon/radeon.h       |    1 -
 drivers/gpu/drm/radeon/radeon_fence.c |    7 -------
 2 files changed, 0 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/radeon.h +0 -1
index f1a9bd0..59bcfb9 100644
@@ -257,7 +257,6 @@ struct radeon_fence_driver {
 	uint32_t			last_seq;
 	unsigned long			last_activity;
 	wait_queue_head_t		queue;
-	struct list_head		created;
 	struct list_head		emitted;
 	struct list_head		signaled;
 	bool				initialized;
drivers/gpu/drm/radeon/radeon_fence.c +0 -7
index 2d13843..aadd73a 100644
@@ -139,8 +139,6 @@ int radeon_fence_create(struct radeon_device *rdev,
 			struct radeon_fence **fence,
 			int ring)
 {
-	unsigned long irq_flags;
-
 	*fence = kmalloc(sizeof(struct radeon_fence), GFP_KERNEL);
 	if ((*fence) == NULL) {
 		return -ENOMEM;
@@ -153,10 +151,6 @@ int radeon_fence_create(struct radeon_device *rdev,
 	(*fence)->ring = ring;
 	(*fence)->semaphore = NULL;
 	INIT_LIST_HEAD(&(*fence)->list);
-
-	write_lock_irqsave(&rdev->fence_lock, irq_flags);
-	list_add_tail(&(*fence)->list, &rdev->fence_drv[ring].created);
-	write_unlock_irqrestore(&rdev->fence_lock, irq_flags);
 	return 0;
 }
 
@@ -411,7 +405,6 @@ static void radeon_fence_driver_init_ring(struct radeon_device *rdev, int ring)
 	rdev->fence_drv[ring].cpu_addr = NULL;
 	rdev->fence_drv[ring].gpu_addr = 0;
 	atomic_set(&rdev->fence_drv[ring].seq, 0);
-	INIT_LIST_HEAD(&rdev->fence_drv[ring].created);
 	INIT_LIST_HEAD(&rdev->fence_drv[ring].emitted);
 	INIT_LIST_HEAD(&rdev->fence_drv[ring].signaled);
 	init_waitqueue_head(&rdev->fence_drv[ring].queue);
Signature · 6 lines
1.7.7.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH 13/13 drm/radeon: add fence and retry to sa allocator v2

In reply to [email protected]

From: Jerome Glisse <[email protected]>

This allow to associate a fence with sa bo and retry and wait if sa bo alloc can block.

v2: bug fixes

---
 drivers/gpu/drm/radeon/radeon.h           |   10 ++-
 drivers/gpu/drm/radeon/radeon_cs.c        |    4 +-
 drivers/gpu/drm/radeon/radeon_gart.c      |   14 ++--
 drivers/gpu/drm/radeon/radeon_object.h    |   10 ++--
 drivers/gpu/drm/radeon/radeon_ring.c      |   14 ++--
 drivers/gpu/drm/radeon/radeon_sa.c        |  102 ++++++++++++++++++++++++++---
 drivers/gpu/drm/radeon/radeon_semaphore.c |    4 +-
 7 files changed, 122 insertions(+), 36 deletions(-)
drivers/gpu/drm/radeon/radeon.h +6 -4
index 59bcfb9..4815ebe 100644
@@ -379,6 +379,8 @@ struct radeon_bo_list {
  * Assumption is that there won't be hole (all object on same
  * alignment).
  */
+struct radeon_sa_bo;
+
 struct radeon_sa_manager {
 	spinlock_t		lock;
 	struct radeon_bo	*bo;
@@ -390,8 +392,6 @@ struct radeon_sa_manager {
 	uint32_t		domain;
 };
 
-struct radeon_sa_bo;
-
 /* sub-allocation buffer */
 struct radeon_sa_bo {
 	struct list_head		list;
@@ -399,6 +399,8 @@ struct radeon_sa_bo {
 	unsigned			soffset;
 	unsigned			eoffset;
 	unsigned			size;
+	struct radeon_fence		*fence;
+	bool				free;
 };
 
 /*
@@ -626,7 +628,7 @@ void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
  */
 
 struct radeon_ib {
-	struct radeon_sa_bo	sa_bo;
+	struct radeon_sa_bo	*sa_bo;
 	unsigned		idx;
 	uint32_t		length_dw;
 	uint64_t		gpu_addr;
@@ -680,7 +682,7 @@ struct radeon_vm {
 	unsigned			last_pfn;
 	u64				pt_gpu_addr;
 	u64				*pt;
-	struct radeon_sa_bo		sa_bo;
+	struct radeon_sa_bo		*sa_bo;
 	struct mutex			mutex;
 	/* last fence for cs using this vm */
 	struct radeon_fence		*fence;
drivers/gpu/drm/radeon/radeon_cs.c +2 -2
index 8de6b3a..b39f22e 100644
@@ -476,7 +476,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
 		/* ib pool is bind at 0 in virtual address space to gpu_addr is the
 		 * offset inside the pool bo
 		 */
-		parser->const_ib->gpu_addr = parser->const_ib->sa_bo.soffset;
+		parser->const_ib->gpu_addr = parser->const_ib->sa_bo->soffset;
 		r = radeon_ib_schedule(rdev, parser->const_ib);
 		if (r)
 			goto out;
@@ -486,7 +486,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
 	/* ib pool is bind at 0 in virtual address space to gpu_addr is the
 	 * offset inside the pool bo
 	 */
-	parser->ib->gpu_addr = parser->ib->sa_bo.soffset;
+	parser->ib->gpu_addr = parser->ib->sa_bo->soffset;
 	parser->ib->is_const_ib = false;
 	r = radeon_ib_schedule(rdev, parser->ib);
 out:
drivers/gpu/drm/radeon/radeon_gart.c +7 -7
index 4a5d9d4..89328e3 100644
@@ -393,19 +393,19 @@ int radeon_vm_bind(struct radeon_device *rdev, struct radeon_vm *vm)
 	}
 
 retry:
-	r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager, &vm->sa_bo,
-			     RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8),
-			     RADEON_GPU_PAGE_SIZE);
-	if (r) {
+	vm->sa_bo = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
+				     RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8),
+				     RADEON_GPU_PAGE_SIZE, false, NULL);
+	if (vm->sa_bo == NULL) {
 		if (list_empty(&rdev->vm_manager.lru_vm)) {
-			return r;
+			return -ENOMEM;
 		}
 		vm_evict = list_first_entry(&rdev->vm_manager.lru_vm, struct radeon_vm, list);
 		radeon_vm_unbind(rdev, vm_evict);
 		goto retry;
 	}
-	vm->pt = radeon_sa_bo_cpu_addr(&vm->sa_bo);
-	vm->pt_gpu_addr = radeon_sa_bo_gpu_addr(&vm->sa_bo);
+	vm->pt = radeon_sa_bo_cpu_addr(vm->sa_bo);
+	vm->pt_gpu_addr = radeon_sa_bo_gpu_addr(vm->sa_bo);
 	memset(vm->pt, 0, RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8));
 
 retry_id:
drivers/gpu/drm/radeon/radeon_object.h +5 -5
index 99ab46a..7bbc319 100644
@@ -166,12 +166,12 @@ extern int radeon_sa_bo_manager_start(struct radeon_device *rdev,
 				      struct radeon_sa_manager *sa_manager);
 extern int radeon_sa_bo_manager_suspend(struct radeon_device *rdev,
 					struct radeon_sa_manager *sa_manager);
-extern int radeon_sa_bo_new(struct radeon_device *rdev,
-			    struct radeon_sa_manager *sa_manager,
-			    struct radeon_sa_bo *sa_bo,
-			    unsigned size, unsigned align);
+extern struct radeon_sa_bo *radeon_sa_bo_new(struct radeon_device *rdev,
+					     struct radeon_sa_manager *sa_manager,
+					     unsigned size, unsigned align,
+					     bool block, struct radeon_fence *fence);
 extern void radeon_sa_bo_free(struct radeon_device *rdev,
-			      struct radeon_sa_bo *sa_bo);
+			      struct radeon_sa_bo **sa_bo);
 #if defined(CONFIG_DEBUG_FS)
 extern void radeon_sa_bo_dump_debug_info(struct radeon_sa_manager *sa_manager,
 					 struct seq_file *m);
drivers/gpu/drm/radeon/radeon_ring.c +7 -7
index 981ab95..b646bdb 100644
@@ -122,13 +122,12 @@ retry:
 	for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
 		radeon_ib_try_free(rdev, &rdev->ib_pool.ibs[idx]);
 		if (rdev->ib_pool.ibs[idx].fence == NULL) {
-			r = radeon_sa_bo_new(rdev, &rdev->ib_pool.sa_manager,
-					     &rdev->ib_pool.ibs[idx].sa_bo,
-					     size, 256);
-			if (!r) {
+			rdev->ib_pool.ibs[idx].sa_bo = radeon_sa_bo_new(rdev, &rdev->ib_pool.sa_manager,
+									size, 256, false, NULL);
+			if (rdev->ib_pool.ibs[idx].sa_bo) {
 				*ib = &rdev->ib_pool.ibs[idx];
-				(*ib)->ptr = radeon_sa_bo_cpu_addr(&(*ib)->sa_bo);
-				(*ib)->gpu_addr = radeon_sa_bo_gpu_addr(&(*ib)->sa_bo);
+				(*ib)->ptr = radeon_sa_bo_cpu_addr((*ib)->sa_bo);
+				(*ib)->gpu_addr = radeon_sa_bo_gpu_addr((*ib)->sa_bo);
 				(*ib)->fence = fence;
 				(*ib)->vm_id = 0;
 				(*ib)->is_const_ib = false;
@@ -146,6 +145,7 @@ retry:
 	}
 	/* this should be rare event, ie all ib scheduled none signaled yet.
 	 */
+	r = -ENOMEM;
 	for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
 		if (rdev->ib_pool.ibs[idx].fence && rdev->ib_pool.ibs[idx].fence->emitted) {
 			r = radeon_fence_wait(rdev->ib_pool.ibs[idx].fence, false);
@@ -226,7 +226,7 @@ int radeon_ib_pool_init(struct radeon_device *rdev)
 		rdev->ib_pool.ibs[i].fence = NULL;
 		rdev->ib_pool.ibs[i].idx = i;
 		rdev->ib_pool.ibs[i].length_dw = 0;
-		INIT_LIST_HEAD(&rdev->ib_pool.ibs[i].sa_bo.list);
+		rdev->ib_pool.ibs[i].sa_bo = NULL;
 	}
 	rdev->ib_pool.head_id = 0;
 	rdev->ib_pool.ready = true;
drivers/gpu/drm/radeon/radeon_sa.c +93 -9

167 lines not on this page · raw message

drivers/gpu/drm/radeon/radeon_semaphore.c +2 -2
index c3763e4..d79afb3 100644
@@ -55,9 +55,9 @@ static int radeon_semaphore_add_bo(struct radeon_device *rdev)
 		return r;
 	}
 	gpu_addr = rdev->ib_pool.sa_manager.gpu_addr;
-	gpu_addr += bo->ib->sa_bo.soffset;
+	gpu_addr += bo->ib->sa_bo->soffset;
 	cpu_ptr = rdev->ib_pool.sa_manager.cpu_ptr;
-	cpu_ptr += (bo->ib->sa_bo.soffset >> 2);
+	cpu_ptr += (bo->ib->sa_bo->soffset >> 2);
 	for (i = 0; i < (RADEON_SEMAPHORE_BO_SIZE/8); i++) {
 		bo->semaphores[i].gpu_addr = gpu_addr;
 		bo->semaphores[i].cpu_ptr = cpu_ptr;
Signature · 1 line
1.7.7.6
#14 lore raw
In reply to [email protected]
Quoted 6 lines · On Wed, May 2, 2012 at 12:00 AM, <[email protected]> wrote:

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Quoted 6 lines

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Cheers,
Jerome

Before i forget, the big issue with doing work from irq handler is that we never know in middle of what other part can be. I believe it's lot better to have irq process only update fence (signaled/not signaled). and have the actual work happening on behalf of the process wether through sa alloc path or ttm path.

Cheers,
Jerome

#15 lore raw
Quoted 10 lines · Jerome Glisse
Quoted 9 lines · On Wed, May 2, 2012 at 12:00 AM,<[email protected]> wrote:

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Quoted 8 lines
Quoted 3 lines

Cheers,
Jerome

Before i forget, the big issue with doing work from irq handler is that we never know in middle of what other part can be. I believe it's lot better to have irq process only update fence (signaled/not signaled). and have the actual work happening on behalf of the process wether through sa alloc path or ttm path.

Disagree.

Why should it be better to delay work outside of the interrupt context if proper locking can make the driver much more responsive and easier to implement?

I don't want to call into TTM or stuff like that, just want make it possible to release the resources acquired for a job immediately after the job is completed instead of waiting for the next allocation to happen. Cause then you don't need to check if a bunch of fences might possible be signaled and instead just get a proper signal that resources can be deallocated.

Also if you really want to keep the irq context out of the drivers upper layers, it should be quite easy to modify the code so that the callback won't happen from there.

Christian.

maintainer
#16 lore raw
Quoted 35 lines · Christian König
Quoted 12 lines · Jerome Glisse
Quoted 10 lines · On Wed, May 2, 2012 at 12:00 AM,<[email protected]>  wrote:

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Quoted 8 lines
Quoted 3 lines

Cheers,
Jerome

Before i forget, the big issue with doing work from irq handler is that we never know in middle of what other part can be. I believe it's lot better to have irq process only update fence (signaled/not signaled). and have the actual work happening on behalf of the process wether through sa alloc path or ttm path.

Disagree.

Why should it be better to delay work outside of the interrupt context if proper locking can make the driver much more responsive and easier to implement?

I don't want to call into TTM or stuff like that, just want make it possible to release the resources acquired for a job immediately after the job is completed instead of waiting for the next allocation to happen. Cause then you don't need to check if a bunch of fences might possible be signaled and instead just get a proper signal that resources can be deallocated.

Quoted 3 lines

Also if you really want to keep the irq context out of the drivers upper layers, it should be quite easy to modify the code so that the callback won't happen from there.

as a general rule try an minimise how much work we do in irq context, the locking gets very messy once you have to use a mutex somewhere else in the future.

Dave.

#17 lore raw
Quoted 34 lines · Dave Airlie
Quoted 32 lines · Christian König
Quoted 10 lines · Jerome Glisse
Quoted 9 lines · On Wed, May 2, 2012 at 12:00 AM,<[email protected]> wrote:

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Quoted 8 lines
Quoted 3 lines

Cheers,
Jerome

Before i forget, the big issue with doing work from irq handler is that we never know in middle of what other part can be. I believe it's lot better to have irq process only update fence (signaled/not signaled). and have the actual work happening on behalf of the process wether through sa alloc path or ttm path.

Disagree.

Why should it be better to delay work outside of the interrupt context if proper locking can make the driver much more responsive and easier to implement?

I don't want to call into TTM or stuff like that, just want make it possible to release the resources acquired for a job immediately after the job is completed instead of waiting for the next allocation to happen. Cause then you don't need to check if a bunch of fences might possible be signaled and instead just get a proper signal that resources can be deallocated.

Quoted 6 lines
Quoted 3 lines

Also if you really want to keep the irq context out of the drivers upper layers, it should be quite easy to modify the code so that the callback won't happen from there.

as a general rule try an minimise how much work we do in irq context, the locking gets very messy once you have to use a mutex somewhere else in the future.

Akk, that sounds reasonable, but I still think that a fence should signal it's completion by itself. Because that releases us from the burden to walk the list of emitted fences and heuristically check if any of them is already signaled.

Also it is pretty easy to move the callback outside of interrupt context, but first things first. I'm going to write together a patchset with everything that is already accepted, so we can stop mailing around actually unrelated patches.

Thanks for the comments,
Christian.

#18 lore raw
Quoted 56 lines · Christian König
Quoted 42 lines · Dave Airlie
Quoted 39 lines · Christian König
Quoted 12 lines · Jerome Glisse
Quoted 10 lines · On Wed, May 2, 2012 at 12:00 AM,<[email protected]>    wrote:

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Quoted 8 lines
Quoted 3 lines

Cheers,
Jerome

Before i forget, the big issue with doing work from irq handler is that we never know in middle of what other part can be. I believe it's lot better to have irq process only update fence (signaled/not signaled). and have the actual work happening on behalf of the process wether through sa alloc path or ttm path.

Disagree.

Why should it be better to delay work outside of the interrupt context if proper locking can make the driver much more responsive and easier to implement?

I don't want to call into TTM or stuff like that, just want make it possible
to release the resources acquired for a job immediately after the job is completed instead of waiting for the next allocation to happen. Cause then
you don't need to check if a bunch of fences might possible be signaled and
instead just get a proper signal that resources can be deallocated.

Quoted 7 lines
Quoted 3 lines

Also if you really want to keep the irq context out of the drivers upper layers, it should be quite easy to modify the code so that the callback won't happen from there.

as a general rule try an minimise how much work we do in irq context, the locking gets very messy once you have to use a mutex somewhere else in the future.

Akk, that sounds reasonable, but I still think that a fence should signal it's completion by itself. Because that releases us from the burden to walk the list of emitted fences and heuristically check if any of them is already signaled.

Quoted 8 lines

Also it is pretty easy to move the callback outside of interrupt context, but first things first.  I'm going to write together a patchset with everything that is already accepted, so we can stop mailing around actually unrelated patches.

Thanks for the comments,
Christian.

Yes i agree, the fence should check for itself, irq process should only write a per
ring seq_last value (probably good to use an atomic one for this) and when querying fence status the signaling should happen. There is 2 possibilities there, either
we keep 32bits seq and keep list. Or we move toward 64bit seq and use arithmetic to know if a fence is signaled or not (assuming that we will never wrap around 64bits
fence counter in up time).

But i am still against callback it's just make locking a mess. As discussed previously
i think we should be able to have at most 4 lock:
dispatch lock (all ring all gpu related activities)
ttm lock
temporary memory alloc lock
fence lock (that one can go away if we don't keep a list of fence anymore) idea is that either
ttm path or temporary memory path might call in fence checking.

Cheers,
Jerome Glisse

Cheers,
Jerome

#19 lore raw
In reply to Christian König

2012/5/2 Christian König <[email protected]>:

Quoted 29 lines · Jerome Glisse
Quoted 12 lines · On Wed, May 2, 2012 at 12:00 AM,<[email protected]>  wrote:
Quoted 10 lines

Ok so i reread stuff and the :
drm/radeon: add general purpose fence signaled callback is a big NAK actually. It change the paradigm. Moving most of the handling into the irq process which is something i am intimatly convinced we should avoid.

Here is the patchset up to ib pool cleanup. I have yet rebase the other patches as i am tracking done some issue in the sa allocation.

Quoted 8 lines
Quoted 3 lines

Cheers,
Jerome

Before i forget, the big issue with doing work from irq handler is that we never know in middle of what other part can be. I believe it's lot better to have irq process only update fence (signaled/not signaled). and have the actual work happening on behalf of the process wether through sa alloc path or ttm path.

Disagree.

Why should it be better to delay work outside of the interrupt context if proper locking can make the driver much more responsive and easier to implement?

Quoted 5 lines

I don't want to call into TTM or stuff like that, just want make it possible to release the resources acquired for a job immediately after the job is completed instead of waiting for the next allocation to happen. Cause then you don't need to check if a bunch of fences might possible be signaled and instead just get a proper signal that resources can be deallocated.

We use two fences per IB, one for the command buffer itself and the other for the actual IB allocations. That way the the IB can be re-used without waiting for the fence after the synchronization. I'm not sure it's worth the extra complexity though.

Alex