summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@armlinux.org.uk>2017-02-12 21:34:01 +0000
committerRussell King <rmk@armlinux.org.uk>2017-02-12 23:23:06 +0000
commit77f88d4a1f54cd3a4fd34f8aa738cb7ea1084dbc (patch)
treeff5d414c66158a0977be3240fb0974943442a56e
parent32d4b641bcf7c27257154b7c744f151de20b05ec (diff)
etnaviv: cleanup etnaviv pixmap memory management
Group all etnaviv pixmap memory management functions into one place, combining the contents of etnaviv_put_vpix() with etnaviv_free_vpix(), since it is now only called from within etnaviv_put_vpix(). This also ensures that the refcounting can't be accidentally bypassed. Signed-off-by: Russell King <rmk@armlinux.org.uk>
-rw-r--r--etnaviv/etnaviv.c80
1 files changed, 38 insertions, 42 deletions
diff --git a/etnaviv/etnaviv.c b/etnaviv/etnaviv.c
index c7aa682..c7ec66b 100644
--- a/etnaviv/etnaviv.c
+++ b/etnaviv/etnaviv.c
@@ -61,28 +61,6 @@ const OptionInfoRec etnaviv_options[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
-static void etnaviv_free_vpix(struct etnaviv *etnaviv,
- struct etnaviv_pixmap *vPix)
-{
- if (vPix->etna_bo) {
- struct etna_bo *etna_bo = vPix->etna_bo;
-
- if (!vPix->bo && vPix->state & ST_CPU_RW)
- etna_bo_cpu_fini(etna_bo);
- etna_bo_del(etnaviv->conn, etna_bo, NULL);
- }
- if (vPix->bo)
- drm_armada_bo_put(vPix->bo);
- free(vPix);
-}
-
-static void etnaviv_put_vpix(struct etnaviv *etnaviv,
- struct etnaviv_pixmap *vPix)
-{
- if (--vPix->refcnt == 0)
- etnaviv_free_vpix(etnaviv, vPix);
-}
-
void etnaviv_finish_fences(struct etnaviv *etnaviv, uint32_t fence)
{
uint32_t last;
@@ -125,26 +103,6 @@ static CARD32 etnaviv_cache_expire(OsTimerPtr timer, CARD32 time, pointer arg)
return 0;
}
-static void etnaviv_free_pixmap(PixmapPtr pixmap)
-{
- struct etnaviv_pixmap *vPix = etnaviv_get_pixmap_priv(pixmap);
-
- if (vPix) {
- struct etnaviv *etnaviv;
-
- etnaviv_set_pixmap_priv(pixmap, NULL);
-
- etnaviv = etnaviv_get_screen_priv(pixmap->drawable.pScreen);
-
- /*
- * Put the pixmap - if it's on one of the batch or fence
- * lists, they will hold a refcount, which will be dropped
- * once the GPU operation is complete.
- */
- etnaviv_put_vpix(etnaviv, vPix);
- }
-}
-
/*
* We are about to respond to a client. Ensure that all pending rendering
* is flushed to the GPU prior to the response being delivered.
@@ -159,6 +117,24 @@ static void etnaviv_flush_callback(CallbackListPtr *list, pointer user_data,
etnaviv_commit(etnaviv, FALSE);
}
+/* Etnaviv pixmap memory management */
+static void etnaviv_put_vpix(struct etnaviv *etnaviv,
+ struct etnaviv_pixmap *vPix)
+{
+ if (--vPix->refcnt == 0) {
+ if (vPix->etna_bo) {
+ struct etna_bo *etna_bo = vPix->etna_bo;
+
+ if (!vPix->bo && vPix->state & ST_CPU_RW)
+ etna_bo_cpu_fini(etna_bo);
+ etna_bo_del(etnaviv->conn, etna_bo, NULL);
+ }
+ if (vPix->bo)
+ drm_armada_bo_put(vPix->bo);
+ free(vPix);
+ }
+}
+
static void etnaviv_retire_vpix_fence(struct etnaviv_fence_head *fh,
struct etnaviv_fence *f)
{
@@ -186,6 +162,26 @@ static struct etnaviv_pixmap *etnaviv_alloc_pixmap(PixmapPtr pixmap,
return vpix;
}
+static void etnaviv_free_pixmap(PixmapPtr pixmap)
+{
+ struct etnaviv_pixmap *vPix = etnaviv_get_pixmap_priv(pixmap);
+
+ if (vPix) {
+ struct etnaviv *etnaviv;
+
+ etnaviv_set_pixmap_priv(pixmap, NULL);
+
+ etnaviv = etnaviv_get_screen_priv(pixmap->drawable.pScreen);
+
+ /*
+ * Put the pixmap - if it's on one of the batch or fence
+ * lists, they will hold a refcount, which will be dropped
+ * once the GPU operation is complete.
+ */
+ etnaviv_put_vpix(etnaviv, vPix);
+ }
+}
+
/* Determine whether this GC and target Drawable can be accelerated */
static Bool etnaviv_GC_can_accel(GCPtr pGC, DrawablePtr pDrawable)