mirror of
https://github.com/termux-pacman/glibc-packages.git
synced 2024-11-27 06:08:57 +00:00
466c8a979f
gpkg/binutils-libs gpkg/mesa + (added patches by @xMeM that customize freedreno) gpkg/python gpkg/git gpkg/linux-api-headers gpkg/spirv-headers gpkg/spirv-tools gpkg/cmake gpkg/glslang gpkg/libarchive gpkg/libuv gpkg/libtool gpkg/libxi gpkg/rhash gpkg/xtrans gpkg/libclc gpkg/glmark2 gpkg/libnettle gpkg/libssh2 gpkg/libunistring gpkg/libtirpc gpkg/libdav1d gpkg/vulkan-headers gpkg/vulkan-icd-loader gpkg/vulkan-tools
267 lines
9.2 KiB
Diff
267 lines
9.2 KiB
Diff
From 57893e7b96505c1ca8c30970e8b801f86f910ffe Mon Sep 17 00:00:00 2001
|
|
From: Lucas Fryzek <lfryzek@igalia.com>
|
|
Date: Mon, 27 Feb 2023 14:50:39 -0500
|
|
Subject: [PATCH 2/2] freedreno/drm: Add more APIs to per backend API
|
|
|
|
Add bo_map, bo_from_dmabuf, and bo_close_handle to the per backend
|
|
APIs for freedreno/drm. These changes are required to implement
|
|
a KGSL backend as part of freedreno/drm.
|
|
---
|
|
src/freedreno/drm/freedreno_device.c | 36 +++++++++++++------
|
|
src/freedreno/drm/freedreno_drmif.h | 15 ++++++++
|
|
src/freedreno/drm/freedreno_pipe.c | 6 ++++
|
|
src/freedreno/drm/freedreno_priv.h | 2 ++
|
|
.../drivers/freedreno/freedreno_context.c | 30 ++++++++++++----
|
|
.../drivers/freedreno/freedreno_screen.c | 5 +++
|
|
6 files changed, 77 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/src/freedreno/drm/freedreno_device.c b/src/freedreno/drm/freedreno_device.c
|
|
index ce95c9f5e0a..0d0998eb265 100644
|
|
--- a/src/freedreno/drm/freedreno_device.c
|
|
+++ b/src/freedreno/drm/freedreno_device.c
|
|
@@ -41,6 +41,9 @@ struct fd_device *msm_device_new(int fd, drmVersionPtr version);
|
|
#ifdef HAVE_FREEDRENO_VIRTIO
|
|
struct fd_device *virtio_device_new(int fd, drmVersionPtr version);
|
|
#endif
|
|
+#ifdef HAVE_FREEDRENO_KGSL
|
|
+struct fd_device *kgsl_device_new(int fd);
|
|
+#endif
|
|
|
|
uint64_t os_page_size = 4096;
|
|
|
|
@@ -48,19 +51,20 @@ struct fd_device *
|
|
fd_device_new(int fd)
|
|
{
|
|
struct fd_device *dev = NULL;
|
|
- drmVersionPtr version;
|
|
+ drmVersionPtr version = NULL;
|
|
bool use_heap = false;
|
|
+ bool support_use_heap = true;
|
|
|
|
os_get_page_size(&os_page_size);
|
|
|
|
+#ifdef HAVE_LIBDRM
|
|
/* figure out if we are kgsl or msm drm driver: */
|
|
version = drmGetVersion(fd);
|
|
- if (!version) {
|
|
- ERROR_MSG("cannot get version: %s", strerror(errno));
|
|
- return NULL;
|
|
- }
|
|
+ if (!version)
|
|
+ DEBUG_MSG("cannot get version: %s", strerror(errno));
|
|
+#endif
|
|
|
|
- if (!strcmp(version->name, "msm")) {
|
|
+ if (version && !strcmp(version->name, "msm")) {
|
|
DEBUG_MSG("msm DRM device");
|
|
if (version->version_major != 1) {
|
|
ERROR_MSG("unsupported version: %u.%u.%u", version->version_major,
|
|
@@ -70,7 +74,7 @@ fd_device_new(int fd)
|
|
|
|
dev = msm_device_new(fd, version);
|
|
#ifdef HAVE_FREEDRENO_VIRTIO
|
|
- } else if (!strcmp(version->name, "virtio_gpu")) {
|
|
+ } else if (version && !strcmp(version->name, "virtio_gpu")) {
|
|
DEBUG_MSG("virtio_gpu DRM device");
|
|
dev = virtio_device_new(fd, version);
|
|
/* Only devices that support a hypervisor are a6xx+, so avoid the
|
|
@@ -78,10 +82,14 @@ fd_device_new(int fd)
|
|
*/
|
|
use_heap = true;
|
|
#endif
|
|
-#if HAVE_FREEDRENO_KGSL
|
|
- } else if (!strcmp(version->name, "kgsl")) {
|
|
- DEBUG_MSG("kgsl DRM device");
|
|
+#ifdef HAVE_FREEDRENO_KGSL
|
|
+ } else {
|
|
+ /* If drm driver not detected assume this is KGSL */
|
|
dev = kgsl_device_new(fd);
|
|
+ /* Userspace fences are not supported with KGSL */
|
|
+ support_use_heap = false;
|
|
+ if (dev)
|
|
+ goto out;
|
|
#endif
|
|
}
|
|
|
|
@@ -129,7 +137,7 @@ out:
|
|
fd_pipe_del(pipe);
|
|
}
|
|
|
|
- if (use_heap) {
|
|
+ if (support_use_heap && use_heap) {
|
|
dev->ring_heap = fd_bo_heap_new(dev, RING_FLAGS);
|
|
dev->default_heap = fd_bo_heap_new(dev, 0);
|
|
}
|
|
@@ -248,6 +256,12 @@ fd_dbg(void)
|
|
return debug_get_option_libgl();
|
|
}
|
|
|
|
+uint32_t
|
|
+fd_get_features(struct fd_device *dev)
|
|
+{
|
|
+ return dev->features;
|
|
+}
|
|
+
|
|
bool
|
|
fd_has_syncobj(struct fd_device *dev)
|
|
{
|
|
diff --git a/src/freedreno/drm/freedreno_drmif.h b/src/freedreno/drm/freedreno_drmif.h
|
|
index dd073f201c2..3a5d852d082 100644
|
|
--- a/src/freedreno/drm/freedreno_drmif.h
|
|
+++ b/src/freedreno/drm/freedreno_drmif.h
|
|
@@ -67,6 +67,13 @@ enum fd_param_id {
|
|
FD_VA_SIZE, /* GPU virtual address size */
|
|
};
|
|
|
|
+enum fd_reset_status {
|
|
+ FD_RESET_NO_ERROR,
|
|
+ FD_RESET_GUILTY,
|
|
+ FD_RESET_INNOCENT,
|
|
+ FD_RESET_UNKNOWN,
|
|
+};
|
|
+
|
|
/**
|
|
* Helper for fence/seqno comparisions which deals properly with rollover.
|
|
* Returns true if fence 'a' is before fence 'b'
|
|
@@ -197,8 +204,15 @@ enum fd_version {
|
|
};
|
|
enum fd_version fd_device_version(struct fd_device *dev);
|
|
|
|
+enum fd_features {
|
|
+ FD_FEATURE_DIRECT_RESET = 1,
|
|
+ FD_FEATURE_IMPORT_DMABUF = 2,
|
|
+};
|
|
+
|
|
+uint32_t fd_get_features(struct fd_device *dev);
|
|
bool fd_has_syncobj(struct fd_device *dev);
|
|
|
|
+
|
|
/* pipe functions:
|
|
*/
|
|
|
|
@@ -218,6 +232,7 @@ int fd_pipe_wait(struct fd_pipe *pipe, const struct fd_fence *fence);
|
|
/* timeout in nanosec */
|
|
int fd_pipe_wait_timeout(struct fd_pipe *pipe, const struct fd_fence *fence,
|
|
uint64_t timeout);
|
|
+int fd_pipe_get_reset_status(struct fd_pipe *pipe, enum fd_reset_status *status);
|
|
|
|
/* buffer-object functions:
|
|
*/
|
|
diff --git a/src/freedreno/drm/freedreno_pipe.c b/src/freedreno/drm/freedreno_pipe.c
|
|
index 362e6966376..ea14976545e 100644
|
|
--- a/src/freedreno/drm/freedreno_pipe.c
|
|
+++ b/src/freedreno/drm/freedreno_pipe.c
|
|
@@ -225,6 +225,12 @@ fd_pipe_emit_fence(struct fd_pipe *pipe, struct fd_ringbuffer *ring)
|
|
return fence;
|
|
}
|
|
|
|
+int
|
|
+fd_pipe_get_reset_status(struct fd_pipe *pipe, enum fd_reset_status *status)
|
|
+{
|
|
+ return pipe->funcs->reset_status(pipe, status);
|
|
+}
|
|
+
|
|
struct fd_fence *
|
|
fd_fence_new(struct fd_pipe *pipe, bool use_fence_fd)
|
|
{
|
|
diff --git a/src/freedreno/drm/freedreno_priv.h b/src/freedreno/drm/freedreno_priv.h
|
|
index b2e7604026b..e5ec8442ea5 100644
|
|
--- a/src/freedreno/drm/freedreno_priv.h
|
|
+++ b/src/freedreno/drm/freedreno_priv.h
|
|
@@ -209,6 +209,7 @@ struct fd_device {
|
|
int fd;
|
|
enum fd_version version;
|
|
int32_t refcnt;
|
|
+ uint32_t features;
|
|
|
|
/* tables to keep track of bo's, to avoid "evil-twin" fd_bo objects:
|
|
*
|
|
@@ -312,6 +313,7 @@ struct fd_pipe_funcs {
|
|
struct fd_ringbuffer *(*ringbuffer_new_object)(struct fd_pipe *pipe,
|
|
uint32_t size);
|
|
struct fd_submit *(*submit_new)(struct fd_pipe *pipe);
|
|
+ int (*reset_status)(struct fd_pipe *pipe, enum fd_reset_status *status);
|
|
|
|
/**
|
|
* Flush any deferred submits (if deferred submits are supported by
|
|
diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
|
|
index ea2a45a2a3c..35c3488ede1 100644
|
|
--- a/src/gallium/drivers/freedreno/freedreno_context.c
|
|
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
|
|
@@ -497,6 +497,22 @@ fd_get_device_reset_status(struct pipe_context *pctx)
|
|
return status;
|
|
}
|
|
|
|
+static enum pipe_reset_status
|
|
+fd_get_device_reset_status_direct(struct pipe_context *pctx)
|
|
+{
|
|
+ struct fd_context *ctx = fd_context(pctx);
|
|
+ enum pipe_reset_status status_list[] = {
|
|
+ [FD_RESET_NO_ERROR] = PIPE_NO_RESET,
|
|
+ [FD_RESET_GUILTY] = PIPE_GUILTY_CONTEXT_RESET,
|
|
+ [FD_RESET_INNOCENT] = PIPE_INNOCENT_CONTEXT_RESET,
|
|
+ [FD_RESET_UNKNOWN] = PIPE_UNKNOWN_CONTEXT_RESET,
|
|
+ };
|
|
+ enum fd_reset_status fd_status;
|
|
+ ASSERTED int ret = fd_pipe_get_reset_status(ctx->pipe, &fd_status);
|
|
+ assert(!ret);
|
|
+ return status_list[fd_status];
|
|
+}
|
|
+
|
|
static void
|
|
fd_trace_record_ts(struct u_trace *ut, void *cs, void *timestamps,
|
|
unsigned idx, uint32_t flags)
|
|
@@ -662,11 +678,6 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
|
|
|
|
ctx->in_fence_fd = -1;
|
|
|
|
- if (fd_device_version(screen->dev) >= FD_VERSION_ROBUSTNESS) {
|
|
- ctx->context_reset_count = fd_get_reset_count(ctx, true);
|
|
- ctx->global_reset_count = fd_get_reset_count(ctx, false);
|
|
- }
|
|
-
|
|
simple_mtx_init(&ctx->gmem_lock, mtx_plain);
|
|
|
|
/* need some sane default in case gallium frontends don't
|
|
@@ -681,13 +692,20 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
|
|
pctx->flush = fd_context_flush;
|
|
pctx->emit_string_marker = fd_emit_string_marker;
|
|
pctx->set_debug_callback = fd_set_debug_callback;
|
|
- pctx->get_device_reset_status = fd_get_device_reset_status;
|
|
pctx->create_fence_fd = fd_create_pipe_fence_fd;
|
|
pctx->fence_server_sync = fd_pipe_fence_server_sync;
|
|
pctx->fence_server_signal = fd_pipe_fence_server_signal;
|
|
pctx->texture_barrier = fd_texture_barrier;
|
|
pctx->memory_barrier = fd_memory_barrier;
|
|
|
|
+ if (fd_get_features(screen->dev) & FD_FEATURE_DIRECT_RESET) {
|
|
+ pctx->get_device_reset_status = fd_get_device_reset_status_direct;
|
|
+ } else if(fd_device_version(screen->dev) >= FD_VERSION_ROBUSTNESS) {
|
|
+ ctx->context_reset_count = fd_get_reset_count(ctx, true);
|
|
+ ctx->global_reset_count = fd_get_reset_count(ctx, false);
|
|
+ pctx->get_device_reset_status = fd_get_device_reset_status;
|
|
+ }
|
|
+
|
|
pctx->stream_uploader = u_upload_create_default(pctx);
|
|
if (!pctx->stream_uploader)
|
|
goto fail;
|
|
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
|
|
index 64a28e955f4..51f1b61b9da 100644
|
|
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
|
|
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
|
|
@@ -629,6 +629,11 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
|
return 0;
|
|
case PIPE_CAP_THROTTLE:
|
|
return screen->driconf.enable_throttling;
|
|
+ case PIPE_CAP_DMABUF:
|
|
+ if (fd_get_features(screen->dev) & FD_FEATURE_IMPORT_DMABUF)
|
|
+ return DRM_PRIME_CAP_IMPORT;
|
|
+ /* Fallthough to default case */
|
|
+ FALLTHROUGH;
|
|
default:
|
|
return u_pipe_screen_get_param_defaults(pscreen, param);
|
|
}
|
|
--
|
|
2.46.0
|
|
|