mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
freedreno/drm: Combine fd_fence and fd_submit_fence
Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20263>
This commit is contained in:
parent
803df07d9e
commit
c1a621813b
14 changed files with 38 additions and 43 deletions
|
|
@ -281,7 +281,7 @@ main(int argc, char **argv)
|
|||
|
||||
backend->emit_grid(kernel, grid, submit);
|
||||
|
||||
struct fd_submit_fence fence = {};
|
||||
struct fd_fence fence = {};
|
||||
util_queue_fence_init(&fence.ready);
|
||||
|
||||
fd_submit_flush(submit, -1, &fence);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "util/bitset.h"
|
||||
#include "util/list.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_queue.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -83,6 +84,10 @@ fd_fence_after(uint32_t a, uint32_t b)
|
|||
}
|
||||
|
||||
/**
|
||||
* Encapsulates submit out-fence(s), which consist of a 'timestamp' (per-
|
||||
* pipe (submitqueue) sequence number) and optionally, if requested, an
|
||||
* out-fence-fd
|
||||
*
|
||||
* Per submit, there are actually two fences:
|
||||
* 1) The userspace maintained fence, which is used to optimistically
|
||||
* avoid kernel ioctls to query if specific rendering is completed
|
||||
|
|
@ -94,8 +99,21 @@ fd_fence_after(uint32_t a, uint32_t b)
|
|||
* fd_pipe_wait(). So this struct encapsulates the two.
|
||||
*/
|
||||
struct fd_fence {
|
||||
/**
|
||||
* The ready fence is signaled once the submit is actually flushed down
|
||||
* to the kernel, and fence/fence_fd are populated. You must wait for
|
||||
* this fence to be signaled before reading fence/fence_fd.
|
||||
*/
|
||||
struct util_queue_fence ready;
|
||||
|
||||
uint32_t kfence; /* kernel fence */
|
||||
uint32_t ufence; /* userspace fence */
|
||||
|
||||
/**
|
||||
* Optional dma_fence fd, returned by submit if use_fence_fd is true
|
||||
*/
|
||||
int fence_fd;
|
||||
bool use_fence_fd;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ struct fd_submit_funcs {
|
|||
uint32_t size,
|
||||
enum fd_ringbuffer_flags flags);
|
||||
int (*flush)(struct fd_submit *submit, int in_fence_fd,
|
||||
struct fd_submit_fence *out_fence);
|
||||
struct fd_fence *out_fence);
|
||||
void (*destroy)(struct fd_submit *submit);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ fd_submit_ref(struct fd_submit *submit)
|
|||
|
||||
int
|
||||
fd_submit_flush(struct fd_submit *submit, int in_fence_fd,
|
||||
struct fd_submit_fence *out_fence)
|
||||
struct fd_fence *out_fence)
|
||||
{
|
||||
submit->fence = fd_pipe_emit_fence(submit->pipe, submit->primary);
|
||||
return submit->funcs->flush(submit, in_fence_fd, out_fence);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
#include <stdio.h>
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_queue.h"
|
||||
|
||||
#include "adreno_common.xml.h"
|
||||
#include "adreno_pm4.xml.h"
|
||||
|
|
@ -93,33 +92,11 @@ struct fd_ringbuffer *fd_submit_new_ringbuffer(struct fd_submit *submit,
|
|||
uint32_t size,
|
||||
enum fd_ringbuffer_flags flags);
|
||||
|
||||
/**
|
||||
* Encapsulates submit out-fence(s), which consist of a 'timestamp' (per-
|
||||
* pipe (submitqueue) sequence number) and optionally, if requested, an
|
||||
* out-fence-fd
|
||||
*/
|
||||
struct fd_submit_fence {
|
||||
/**
|
||||
* The ready fence is signaled once the submit is actually flushed down
|
||||
* to the kernel, and fence/fence_fd are populated. You must wait for
|
||||
* this fence to be signaled before reading fence/fence_fd.
|
||||
*/
|
||||
struct util_queue_fence ready;
|
||||
|
||||
struct fd_fence fence;
|
||||
|
||||
/**
|
||||
* Optional dma_fence fd, returned by submit if use_fence_fd is true
|
||||
*/
|
||||
int fence_fd;
|
||||
bool use_fence_fd;
|
||||
};
|
||||
|
||||
/* in_fence_fd: -1 for no in-fence, else fence fd
|
||||
* out_fence can be NULL if no output fence is required
|
||||
*/
|
||||
int fd_submit_flush(struct fd_submit *submit, int in_fence_fd,
|
||||
struct fd_submit_fence *out_fence);
|
||||
struct fd_fence *out_fence);
|
||||
|
||||
struct fd_ringbuffer;
|
||||
struct fd_reloc;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ fd_submit_sp_new_ringbuffer(struct fd_submit *submit, uint32_t size,
|
|||
*/
|
||||
static bool
|
||||
fd_submit_sp_flush_prep(struct fd_submit *submit, int in_fence_fd,
|
||||
struct fd_submit_fence *out_fence)
|
||||
struct fd_fence *out_fence)
|
||||
{
|
||||
struct fd_submit_sp *fd_submit = to_fd_submit_sp(submit);
|
||||
bool has_shared = false;
|
||||
|
|
@ -268,7 +268,7 @@ should_defer(struct fd_submit *submit)
|
|||
|
||||
static int
|
||||
fd_submit_sp_flush(struct fd_submit *submit, int in_fence_fd,
|
||||
struct fd_submit_fence *out_fence)
|
||||
struct fd_fence *out_fence)
|
||||
{
|
||||
struct fd_device *dev = submit->pipe->dev;
|
||||
struct fd_pipe *pipe = submit->pipe;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ struct fd_submit_sp {
|
|||
* of submits to merge:
|
||||
*/
|
||||
int in_fence_fd;
|
||||
struct fd_submit_fence *out_fence;
|
||||
struct fd_fence *out_fence;
|
||||
|
||||
/* State for enqueued submits:
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ handle_stateobj_relocs(struct msm_submit *submit, struct msm_ringbuffer *ring)
|
|||
|
||||
static int
|
||||
msm_submit_flush(struct fd_submit *submit, int in_fence_fd,
|
||||
struct fd_submit_fence *out_fence)
|
||||
struct fd_fence *out_fence)
|
||||
{
|
||||
struct msm_submit *msm_submit = to_msm_submit(submit);
|
||||
struct msm_pipe *msm_pipe = to_msm_pipe(submit->pipe);
|
||||
|
|
@ -370,8 +370,8 @@ msm_submit_flush(struct fd_submit *submit, int in_fence_fd,
|
|||
ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));
|
||||
msm_dump_submit(&req);
|
||||
} else if (!ret && out_fence) {
|
||||
out_fence->fence.kfence = req.fence;
|
||||
out_fence->fence.ufence = submit->fence;
|
||||
out_fence->kfence = req.fence;
|
||||
out_fence->ufence = submit->fence;
|
||||
out_fence->fence_fd = req.fence_fd;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ flush_submit_list(struct list_head *submit_list)
|
|||
ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));
|
||||
msm_dump_submit(&req);
|
||||
} else if (!ret && fd_submit->out_fence) {
|
||||
fd_submit->out_fence->fence.kfence = req.fence;
|
||||
fd_submit->out_fence->fence.ufence = fd_submit->base.fence;
|
||||
fd_submit->out_fence->kfence = req.fence;
|
||||
fd_submit->out_fence->ufence = fd_submit->base.fence;
|
||||
fd_submit->out_fence->fence_fd = req.fence_fd;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,12 +174,12 @@ flush_submit_list(struct list_head *submit_list)
|
|||
memcpy(req->payload, submit_bos, bos_len);
|
||||
memcpy(req->payload + bos_len, cmds, cmd_len);
|
||||
|
||||
struct fd_submit_fence *out_fence = fd_submit->out_fence;
|
||||
struct fd_fence *out_fence = fd_submit->out_fence;
|
||||
int *out_fence_fd = NULL;
|
||||
|
||||
if (out_fence) {
|
||||
out_fence->fence.kfence = kfence;
|
||||
out_fence->fence.ufence = fd_submit->base.fence;
|
||||
out_fence->kfence = kfence;
|
||||
out_fence->ufence = fd_submit->base.fence;
|
||||
/* Even if gallium driver hasn't requested a fence-fd, request one.
|
||||
* This way, if we have to block waiting for the fence, we can do
|
||||
* it in the guest, rather than in the single-threaded host.
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ FreedrenoDriver::configure_counters(bool reset, bool wait)
|
|||
for (const auto &countable : countables)
|
||||
countable.configure(ring, reset);
|
||||
|
||||
struct fd_submit_fence fence = {};
|
||||
struct fd_fence fence = {};
|
||||
util_queue_fence_init(&fence.ready);
|
||||
|
||||
fd_submit_flush(submit, -1, &fence);
|
||||
|
|
@ -423,7 +423,7 @@ FreedrenoDriver::configure_counters(bool reset, bool wait)
|
|||
fd_submit_del(submit);
|
||||
|
||||
if (wait)
|
||||
fd_pipe_wait(pipe, &fence.fence);
|
||||
fd_pipe_wait(pipe, &fence);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ flush_ring(void)
|
|||
if (!dev.submit)
|
||||
return;
|
||||
|
||||
struct fd_submit_fence fence = {};
|
||||
struct fd_fence fence = {};
|
||||
util_queue_fence_init(&fence.ready);
|
||||
|
||||
ret = fd_submit_flush(dev.submit, -1, &fence);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ fd_fence_finish(struct pipe_screen *pscreen, struct pipe_context *pctx,
|
|||
return ret == 0;
|
||||
}
|
||||
|
||||
if (fd_pipe_wait_timeout(fence->pipe, &fence->submit_fence.fence, timeout))
|
||||
if (fd_pipe_wait_timeout(fence->pipe, &fence->submit_fence, timeout))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ struct pipe_fence_handle {
|
|||
struct fd_context *ctx;
|
||||
struct fd_pipe *pipe;
|
||||
struct fd_screen *screen;
|
||||
struct fd_submit_fence submit_fence;
|
||||
struct fd_fence submit_fence;
|
||||
uint32_t syncobj;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue