ac/drm: store a util_sync_provider in ac_drm_device
util_sync_provider provides a wrapper to manipulate syncobjs. This allows replacing direct ioctl usages with other functions, and is going to be used to support vpipe. Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Acked-by: Rob Clark <robdclark@chromium.org> Acked-by: Marek Olšák <marek.olsak@amd.com> Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34470>
This commit is contained in:
committed by
Marge Bot
parent
80985767cb
commit
62b9c3eafc
@@ -6,6 +6,7 @@
|
||||
#include "util/os_drm.h"
|
||||
#include "ac_linux_drm.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_sync_provider.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
@@ -22,6 +23,7 @@ struct ac_drm_device {
|
||||
amdvgpu_device_handle vdev;
|
||||
#endif
|
||||
};
|
||||
struct util_sync_provider *p;
|
||||
int fd;
|
||||
bool is_virtio;
|
||||
};
|
||||
@@ -38,12 +40,14 @@ int ac_drm_device_initialize(int fd, bool is_virtio,
|
||||
|
||||
#ifdef HAVE_AMDGPU_VIRTIO
|
||||
if (is_virtio) {
|
||||
struct util_sync_provider *p;
|
||||
amdvgpu_device_handle vdev;
|
||||
r = amdvgpu_device_initialize(fd, major_version, minor_version,
|
||||
&vdev);
|
||||
&vdev, &p);
|
||||
if (r == 0) {
|
||||
(*dev)->vdev = vdev;
|
||||
(*dev)->fd = amdvgpu_device_get_fd(vdev);
|
||||
(*dev)->p = p;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
@@ -54,6 +58,7 @@ int ac_drm_device_initialize(int fd, bool is_virtio,
|
||||
if (r == 0) {
|
||||
(*dev)->adev = adev;
|
||||
(*dev)->fd = amdgpu_device_get_fd(adev);
|
||||
(*dev)->p = util_sync_provider_drm((*dev)->fd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +70,11 @@ int ac_drm_device_initialize(int fd, bool is_virtio,
|
||||
return r;
|
||||
}
|
||||
|
||||
struct util_sync_provider *ac_drm_device_get_sync_provider(ac_drm_device *dev)
|
||||
{
|
||||
return dev->p;
|
||||
}
|
||||
|
||||
uintptr_t ac_drm_device_get_cookie(ac_drm_device *dev)
|
||||
{
|
||||
return (uintptr_t) dev->adev;
|
||||
@@ -72,6 +82,8 @@ uintptr_t ac_drm_device_get_cookie(ac_drm_device *dev)
|
||||
|
||||
void ac_drm_device_deinitialize(ac_drm_device *dev)
|
||||
{
|
||||
dev->p->finalize(dev->p);
|
||||
|
||||
#ifdef HAVE_AMDGPU_VIRTIO
|
||||
if (dev->is_virtio)
|
||||
amdvgpu_device_deinitialize(dev->vdev);
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef void* amdgpu_va_handle;
|
||||
|
||||
struct ac_drm_device;
|
||||
typedef struct ac_drm_device ac_drm_device;
|
||||
struct util_sync_provider;
|
||||
|
||||
typedef union ac_drm_bo {
|
||||
#ifdef _WIN32
|
||||
@@ -59,9 +60,11 @@ struct ac_drm_bo_import_result {
|
||||
uint64_t alloc_size;
|
||||
};
|
||||
|
||||
|
||||
PROC int ac_drm_device_initialize(int fd, bool is_virtio,
|
||||
uint32_t *major_version, uint32_t *minor_version,
|
||||
ac_drm_device **device_handle) TAIL;
|
||||
PROC struct util_sync_provider *ac_drm_device_get_sync_provider(ac_drm_device *dev) TAILPTR;
|
||||
PROC uintptr_t ac_drm_device_get_cookie(ac_drm_device *dev) TAIL;
|
||||
PROC void ac_drm_device_deinitialize(ac_drm_device *dev) TAILV;
|
||||
PROC int ac_drm_device_get_fd(ac_drm_device *dev) TAIL;
|
||||
|
||||
@@ -12,13 +12,16 @@ struct amdvgpu_context;
|
||||
typedef struct amdvgpu_device* amdvgpu_device_handle;
|
||||
typedef struct amdvgpu_bo* amdvgpu_bo_handle;
|
||||
|
||||
struct util_sync_provider;
|
||||
|
||||
struct amdvgpu_bo_import_result {
|
||||
amdvgpu_bo_handle buf_handle;
|
||||
uint64_t alloc_size;
|
||||
};
|
||||
|
||||
int amdvgpu_device_initialize(int fd, uint32_t *drm_major, uint32_t *drm_minor,
|
||||
amdvgpu_device_handle* dev);
|
||||
amdvgpu_device_handle* dev,
|
||||
struct util_sync_provider **p);
|
||||
int amdvgpu_device_deinitialize(amdvgpu_device_handle dev);
|
||||
int amdvgpu_bo_va_op_raw(amdvgpu_device_handle dev,
|
||||
uint32_t res_id,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "util/log.h"
|
||||
#include "util/os_file.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_sync_provider.h"
|
||||
|
||||
#include <xf86drm.h>
|
||||
|
||||
@@ -94,7 +95,8 @@ int amdvgpu_device_deinitialize(amdvgpu_device_handle dev) {
|
||||
}
|
||||
|
||||
int amdvgpu_device_initialize(int fd, uint32_t *drm_major, uint32_t *drm_minor,
|
||||
amdvgpu_device_handle* dev_out) {
|
||||
amdvgpu_device_handle* dev_out,
|
||||
struct util_sync_provider **p) {
|
||||
simple_mtx_lock(&dev_mutex);
|
||||
amdvgpu_device_handle dev;
|
||||
|
||||
@@ -108,7 +110,7 @@ int amdvgpu_device_initialize(int fd, uint32_t *drm_major, uint32_t *drm_minor,
|
||||
*drm_major = dev->vdev->caps.version_major;
|
||||
*drm_minor = dev->vdev->caps.version_minor;
|
||||
simple_mtx_unlock(&dev_mutex);
|
||||
return 0;
|
||||
goto init_sync_provider;
|
||||
}
|
||||
|
||||
/* fd is owned by the amdgpu_screen_winsys that called this function.
|
||||
@@ -184,5 +186,10 @@ int amdvgpu_device_initialize(int fd, uint32_t *drm_major, uint32_t *drm_minor,
|
||||
*drm_major = dev->vdev->caps.version_major;
|
||||
*drm_minor = dev->vdev->caps.version_minor;
|
||||
|
||||
init_sync_provider:
|
||||
*p = vdrm_vpipe_get_sync(dev->vdev);
|
||||
if (!(*p))
|
||||
*p = util_sync_provider_drm(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user