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>
fd_pipe_get_param
fd_pipe_new
fd_pipe_new2
+fd_pipe_ref
fd_pipe_wait
fd_pipe_wait_timeout
fd_ringbuffer_cmd_count
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);
pipe->dev = dev;
pipe->id = id;
+ atomic_set(&pipe->refcnt, 1);
fd_pipe_get_param(pipe, FD_GPU_ID, &val);
pipe->gpu_id = val;
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);
}
struct fd_device *dev;
enum fd_pipe_id id;
uint32_t gpu_id;
+ atomic_t refcnt;
const struct fd_pipe_funcs *funcs;
};