summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-12-14 19:27:53 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-12-14 19:38:36 +0000
commit95cceb5ae5503af0ac50a923fa47e134f0da8743 (patch)
tree932319110fcf60412f1126740ee1fe8b86a0e189
parente7f4b7fd91a41cac77e5eb1cb4f185141b09a09e (diff)
sna: Fix DBG crash whilst pruning inactive GPU buffers
Don't attempt to dereference the NULL gpu_bo after having just freed it. Here in lies the folly of trying to blindly silence the compiler. Instead we should heed the error return as it means that we didn't decouple the pixmap from the inactive list and so we choose to place it back on the active list to purge again in the near future. Reported-by: Paul Neumann <paul104x@yahoo.de References: https://bugs.freedesktop.org/show_bug.cgi?id=43716 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_accel.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index c4256b37..6789c347 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -8746,7 +8746,8 @@ static void sna_accel_inactive(struct sna *sna)
count = bytes = 0;
list_for_each_entry(priv, &sna->inactive_clock[1], inactive)
- count++, bytes += priv->gpu_bo->size;
+ if (!priv->pinned)
+ count++, bytes += priv->gpu_bo->size;
DBG(("%s: trimming %d inactive GPU buffers, %d bytes\n",
__FUNCTION__, count, bytes));
@@ -8782,19 +8783,17 @@ static void sna_accel_inactive(struct sna *sna)
priv = list_first_entry(&sna->inactive_clock[1],
struct sna_pixmap,
inactive);
- if (priv->pinned) {
- list_del(&priv->inactive);
- } else {
- bool ret = sna_pixmap_move_to_cpu(priv->pixmap, true);
- DBG(("%s: discarding GPU bo handle=%d (success? %d)\n",
- __FUNCTION__, priv->gpu_bo->handle, ret));
- (void)ret;
- }
-
/* XXX Rather than discarding the GPU buffer here, we
* could mark it purgeable and allow the shrinker to
* reap its storage only under memory pressure.
*/
+ list_del(&priv->inactive);
+ if (!priv->pinned) {
+ DBG(("%s: discarding inactive GPU bo handle=%d\n",
+ __FUNCTION__, priv->gpu_bo->handle));
+ if (!sna_pixmap_move_to_cpu(priv->pixmap, true))
+ list_add(&priv->inactive, &preserve);
+ }
}
/* Age the current inactive pixmaps */