OSDN Git Service

freedreno: add fd_pipe refcounting
authorRob Clark <robclark@freedesktop.org>
Wed, 9 May 2018 11:40:29 +0000 (07:40 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 9 May 2018 11:40:29 +0000 (07:40 -0400)
In mesa/gallium, a pipe_fence can outlive the pipe_context it was
created from.  But to wait on the fence we need to know the submit-
queue (ie. the fd_pipe).

The most straightforward way to fix this is to add reference counting
to the fd_pipe and let the fence hold a reference to the pipe (rather
than hanging on to the context, which might have been destroyed before
the fence).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/freedreno-symbol-check
freedreno/freedreno_drmif.h
freedreno/freedreno_pipe.c
freedreno/freedreno_priv.h

index 3b11952..e6e5719 100755 (executable)
@@ -36,6 +36,7 @@ fd_pipe_del
 fd_pipe_get_param
 fd_pipe_new
 fd_pipe_new2
+fd_pipe_ref
 fd_pipe_wait
 fd_pipe_wait_timeout
 fd_ringbuffer_cmd_count
index 2711518..c95c21b 100644 (file)
@@ -104,6 +104,7 @@ enum fd_version fd_device_version(struct fd_device *dev);
 
 struct fd_pipe * fd_pipe_new(struct fd_device *dev, enum fd_pipe_id id);
 struct fd_pipe * fd_pipe_new2(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio);
+struct fd_pipe * fd_pipe_ref(struct fd_pipe *pipe);
 void fd_pipe_del(struct fd_pipe *pipe);
 int fd_pipe_get_param(struct fd_pipe *pipe, enum fd_param_id param,
                uint64_t *value);
index 77b160e..30d231c 100644 (file)
@@ -57,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;
@@ -70,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);
 }
 
index 6c9e509..b0a48ad 100644 (file)
@@ -125,6 +125,7 @@ struct fd_pipe {
        struct fd_device *dev;
        enum fd_pipe_id id;
        uint32_t gpu_id;
+       atomic_t refcnt;
        const struct fd_pipe_funcs *funcs;
 };