mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
Mesa's amdgpu drivers reach the kernel through libdrm's core API, through libdrm_amdgpu (devices, buffers, GPU virtual address ranges) and through a few system calls on the DRM descriptors. libmlg_drm/libdrm provides the part of xf86drm.h, amdgpu.h and libsync.h they use, over libmlg_drm, with libdrm's names, types and return conventions, so RADV's stock amdgpu winsys and Mesa's native ac_linux_drm path build and run unchanged. The driver's files live in the dext's per-client Linux process. Each one the library hands out (an opened render node, and every syncobj, sync_file and dma-buf descriptor a request returns) is represented by one end of a socket pair, the library keeping the other end: close, dup, fcntl and fork work on it as on any descriptor, and when the last copy is closed a watcher thread sees end-of-file and closes the driver's file, the lifetime a kernel file has. Requests carrying descriptors are translated both ways, with O_CLOEXEC in Linux's value. drmFileOpen, drmFileStat, drmFileMmap and drmFileMunmap, declared under LIBDRM_FILE_OPS, stand in for the system calls that cannot reach the driver. sync_wait and sync_merge work through temporary syncobjs of an open render node. The amdgpu part follows libdrm_amdgpu (MIT), from which its VA manager and buffer handling are derived: device deduplication, the PRT half-range reservation, dma-buf import by GEM_OP rather than lseek, no userptr. LIBDRM_MLG_DEBUG=1 reports refused requests and descriptor lifetimes. make libdrm-mlg installs build/libdrm-mlg with the uapi headers as the kernel installs them and libdrm.pc and libdrm_amdgpu.pc for Meson. test-libdrm-mlg runs it end to end against the CS fixture device. The Makefile's depfile search now skips the Meson and CMake trees the Vulkan builds will put under build/.
30 lines
1.0 KiB
C
30 lines
1.0 KiB
C
/* libdrm for mac_linuxgpu: libdrm's sync_file helpers (libsync.h).
|
|
*
|
|
* A sync_file here is a DRM descriptor of this library standing for a
|
|
* sync_file of the driver's Linux process (xf86drm.h, "DRM files"): poll(2)
|
|
* and SYNC_IOC_MERGE cannot reach it, so these are functions that do the
|
|
* same through the driver, with libdrm's names and return conventions. */
|
|
#ifndef MLG_LIBSYNC_H
|
|
#define MLG_LIBSYNC_H
|
|
|
|
#if defined(__cplusplus)
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Wait until the fence signals: 0, or -1 with errno ETIME after @timeout
|
|
* milliseconds (negative: forever), EINVAL for a descriptor that is not a
|
|
* sync_file of this library. */
|
|
int sync_wait(int fd, int timeout);
|
|
/* A new sync_file that signals when both have: its descriptor, or -1 with
|
|
* errno set. */
|
|
int sync_merge(const char *name, int fd1, int fd2);
|
|
/* Accumulate @fd2 into *@fd1: dup(@fd2) when *@fd1 < 0, else replace *@fd1
|
|
* (closing it) with the merge of both. 0, or the failed merge's result. */
|
|
int sync_accumulate(const char *name, int *fd1, int fd2);
|
|
|
|
#if defined(__cplusplus)
|
|
}
|
|
#endif
|
|
|
|
#endif
|