Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2 Work out sync file construction API.
details: https://anonhg.NetBSD.org/src/rev/8f7fe71b0d43
branches: trunk
changeset: 1027858:8f7fe71b0d43
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 00:58:42 2021 +0000
description:
Work out sync file construction API.
diffstat:
sys/external/bsd/drm2/dist/drm/drm_atomic_uapi.c | 42 ++++++++++++++++++++++-
sys/external/bsd/drm2/include/linux/file.h | 13 ++++++-
sys/external/bsd/drm2/include/linux/sync_file.h | 9 ++++-
3 files changed, 59 insertions(+), 5 deletions(-)
diffs (132 lines):
diff -r 20a26ebdb953 -r 8f7fe71b0d43 sys/external/bsd/drm2/dist/drm/drm_atomic_uapi.c
--- a/sys/external/bsd/drm2/dist/drm/drm_atomic_uapi.c Sun Dec 19 00:58:30 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_atomic_uapi.c Sun Dec 19 00:58:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_atomic_uapi.c,v 1.2 2021/12/18 23:44:57 riastradh Exp $ */
+/* $NetBSD: drm_atomic_uapi.c,v 1.3 2021/12/19 00:58:42 riastradh Exp $ */
/*
* Copyright (C) 2014 Red Hat
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_atomic_uapi.c,v 1.2 2021/12/18 23:44:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_atomic_uapi.c,v 1.3 2021/12/19 00:58:42 riastradh Exp $");
#include <drm/drm_atomic_uapi.h>
#include <drm/drm_atomic.h>
@@ -1091,6 +1091,38 @@
static int setup_out_fence(struct drm_out_fence_state *fence_state,
struct dma_fence *fence)
{
+#ifdef __NetBSD__
+ int fd = -1;
+ struct file *fp = NULL;
+ int ret;
+
+ /* Allocate a file descriptor. */
+ /* XXX errno NetBSD->Linux */
+ ret = -fd_allocfile(&fp, &fd);
+ if (ret)
+ goto out;
+
+ /* Prepare to transmit it to user. */
+ /* XXX errno NetBSD->Linux */
+ ret = -copyout(&fence_state->fd, &fd, sizeof fd);
+ if (ret)
+ goto out;
+
+ /* Create sync file. */
+ fence_state->sync_file = sync_file_create(fence, fp);
+ if (fence_state->sync_file == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ fp = NULL; /* sync_file consumes */
+
+out: if (fp != NULL) {
+ fd_abort(curproc, fp, fd);
+ fd = -1;
+ }
+ fence_state->fd = fd;
+ return ret;
+#else
fence_state->fd = get_unused_fd_flags(O_CLOEXEC);
if (fence_state->fd < 0)
return fence_state->fd;
@@ -1103,6 +1135,7 @@
return -ENOMEM;
return 0;
+#endif
}
static int prepare_signaling(struct drm_device *dev,
@@ -1264,10 +1297,15 @@
return;
for (i = 0; i < num_fences; i++) {
+#ifdef __NetBSD__
+ if (fd_getfile(fence_state[i].fd))
+ (void)fd_close(fence_state[i].fd);
+#else
if (fence_state[i].sync_file)
fput(fence_state[i].sync_file->file);
if (fence_state[i].fd >= 0)
put_unused_fd(fence_state[i].fd);
+#endif
/* If this fails log error to the user */
if (fence_state[i].out_fence_ptr &&
diff -r 20a26ebdb953 -r 8f7fe71b0d43 sys/external/bsd/drm2/include/linux/file.h
--- a/sys/external/bsd/drm2/include/linux/file.h Sun Dec 19 00:58:30 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/file.h Sun Dec 19 00:58:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: file.h,v 1.2 2014/03/18 18:20:43 riastradh Exp $ */
+/* $NetBSD: file.h,v 1.3 2021/12/19 00:58:42 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,15 @@
#ifndef _LINUX_FILE_H_
#define _LINUX_FILE_H_
+#include <sys/filedesc.h>
+#include <sys/proc.h>
+
+struct file;
+
+static inline void
+fd_install(int fd, struct file *fp)
+{
+ fd_affix(curproc, fp, fd);
+}
+
#endif /* _LINUX_FILE_H_ */
diff -r 20a26ebdb953 -r 8f7fe71b0d43 sys/external/bsd/drm2/include/linux/sync_file.h
--- a/sys/external/bsd/drm2/include/linux/sync_file.h Sun Dec 19 00:58:30 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/sync_file.h Sun Dec 19 00:58:42 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sync_file.h,v 1.2 2021/12/19 00:54:36 riastradh Exp $ */
+/* $NetBSD: sync_file.h,v 1.3 2021/12/19 00:58:42 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,10 +33,15 @@
#define _LINUX_SYNC_FILE_H_
struct dma_fence;
+struct file;
struct sync_file;
+struct sync_file {
+ struct file *file;
+};
+
struct sync_file *
- sync_file_create(struct dma_fence *);
+ sync_file_create(struct dma_fence *, struct file *);
struct dma_fence *
sync_file_get_fence(int);
Home |
Main Index |
Thread Index |
Old Index