summaryrefslogtreecommitdiff
path: root/lib/libdrm/freedreno/freedreno_pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libdrm/freedreno/freedreno_pipe.c')
-rw-r--r--lib/libdrm/freedreno/freedreno_pipe.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libdrm/freedreno/freedreno_pipe.c b/lib/libdrm/freedreno/freedreno_pipe.c
index 1540474bd..30d231c7d 100644
--- a/lib/libdrm/freedreno/freedreno_pipe.c
+++ b/lib/libdrm/freedreno/freedreno_pipe.c
@@ -26,10 +26,6 @@
* Rob Clark <robclark@freedesktop.org>
*/
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include "freedreno_drmif.h"
#include "freedreno_priv.h"
@@ -61,6 +57,7 @@ fd_pipe_new2(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio)
pipe->dev = dev;
pipe->id = id;
+ atomic_set(&pipe->refcnt, 1);
fd_pipe_get_param(pipe, FD_GPU_ID, &val);
pipe->gpu_id = val;
@@ -74,8 +71,16 @@ fd_pipe_new(struct fd_device *dev, enum fd_pipe_id id)
return fd_pipe_new2(dev, id, 1);
}
+struct fd_pipe * fd_pipe_ref(struct fd_pipe *pipe)
+{
+ atomic_inc(&pipe->refcnt);
+ return pipe;
+}
+
void fd_pipe_del(struct fd_pipe *pipe)
{
+ if (!atomic_dec_and_test(&pipe->refcnt))
+ return;
pipe->funcs->destroy(pipe);
}