Skip to content

Commit

Permalink
Fix[dc]: Move usages of sync to where they are supposed to be
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Nov 19, 2023
1 parent 982163c commit 58f9318
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/android_stub/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if with_android_stub
stub_libs = []

foreach lib : ['hardware', 'log', 'nativewindow', 'sync']
foreach lib : ['hardware', 'log', 'nativewindow']
stub_libs += shared_library(
lib,
files(lib + '_stub.cpp'),
Expand Down
53 changes: 52 additions & 1 deletion src/gallium/drivers/panfrost/pan_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include "util/macros.h"
#include "util/format/u_format.h"
#include "util/libsync.h"
#include "util/u_inlines.h"
#include "util/u_upload_mgr.h"
#include "util/u_memory.h"
Expand Down Expand Up @@ -890,6 +889,58 @@ panfrost_create_fence_fd(struct pipe_context *pctx,
*pfence = panfrost_fence_from_fd(pan_context(pctx), fd, type);
}

struct sync_merge_data {
char name[32];
int32_t fd2;
int32_t fence;
uint32_t flags;
uint32_t pad;
};

#define SYNC_IOC_MAGIC '>'
#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data)

static inline int sync_merge(const char *name, int fd1, int fd2)
{
struct sync_merge_data data = {{0}};
int ret;

data.fd2 = fd2;
strncpy(data.name, name, sizeof(data.name));

do {
ret = ioctl(fd1, SYNC_IOC_MERGE, &data);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));

if (ret < 0)
return ret;

return data.fence;
}

static inline int sync_accumulate(const char *name, int *fd1, int fd2)
{
int ret;

assert(fd2 >= 0);

if (*fd1 < 0) {
*fd1 = dup(fd2);
return 0;
}

ret = sync_merge(name, *fd1, fd2);
if (ret < 0) {
/* leave *fd1 as it is */
return ret;
}

close(*fd1);
*fd1 = ret;

return 0;
}

static void
panfrost_fence_server_sync(struct pipe_context *pctx,
struct pipe_fence_handle *f)
Expand Down

0 comments on commit 58f9318

Please sign in to comment.