mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
On 241 a request that waited on a GPU ring that had stopped ran on the one thread DriverKit delivers every client's calls on: every client froze, and the driver could not take its own Stop after the GPU was powered off. Every Linux-file request that can sleep now runs on a worker of the client's process and completes through AsyncCompletion: - mlg_lx_cmd_sleeps (lx_describe.c, shared by the client library and the driver) names the few requests that provably do not sleep: VERSION, GET_CAP, SET_CLIENT_CAP, the syncobj create, destroy, export, import, reset, signal, timeline signal, query and eventfd requests, a syncobj wait that only polls, and KFD GET_VERSION. Everything else is async, AMDGPU_CS, INFO, GEM and context requests included. - LX_IOCTL runs only those, through rt_lx_ioctl_nosleep; any other is refused without running (kIOReturnNotPermitted) and logged with the request and the process. - LX_CALL_ASYNC (selector 105) runs open, close, mmap and munmap on a worker; the synchronous selectors 96, 97, 101 and 103 are retired. - A Linux-file client's Stop hands its process's exit to a thread of its own (rt_lx_client_retire) instead of waiting for its calls on the incoming-call thread; a session close waits for those exits (rt_lx_retire_drain) before the driver goes. On an unplug the Stop has already begun removal, which completes the GPU's fences, so the exits finish. - An async call holds one of MLG_LX_MAX_ASYNC slots until its result is delivered: with the completion (the slot frees before it is sent) or by LX_RESULT, whose result is in place before the completion goes out. The client library keeps its calls within the limit, waiting on its own thread. A worker still sending a completion holds no slot, so a call queues for it instead of failing. - The transport revision is MLG_LX_ABI 2: libmlg_drm's dylib compatibility version, and the text MLG_LX_ABI_TAG in the library for launchers to check. A client library older than this driver fails at its first sleeping request or open, with the reason in the driver log. Events reach the unified log; routine lines stay in the retained ring. The dext logged every line through os_log, and nothing from it reached the unified log in the boot where 241 hung (probably quarantined for volume), so the hang's cause was lost with the dext. Now only events go there, prefixed "mac.linuxgpu: EVENT ": driver start, probe outcome, removal, quarantine and release, session close, DMA mapping failures, printk at error level and above (ring timeouts among them), and the head of a device coredump, which dev_coredumpm now logs before freeing it. Read them with log show --predicate 'eventMessage BEGINSWITH "mac.linuxgpu: EVENT"' Tests: test_lx_files covers the table, the synchronous refusal, the operations on workers, inline and fetched results and the new slot rules. blocked_call_check (test-cs-selftest) blocks a client's AMDGPU_CS behind amdgpu_sched_jobs submissions on a held compute engine and checks that every call returns at once, the blocked client's non-sleeping request runs and its sleeping one is refused synchronously, another client opens, allocates and completes SDMA work, the blocked client's Stop returns at once and its exit finishes when the engine runs, and, during the surprise removal check, that removal ends a blocked submission and the client's exit completes.
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/* linuxu: SHIM (third_party/linux/include/linux/devcoredump.h) */
|
|
#ifndef __LINUX_DEVCOREDUMP_H
|
|
#define __LINUX_DEVCOREDUMP_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/device.h>
|
|
|
|
struct devcd_info {
|
|
const void *data;
|
|
size_t size;
|
|
struct device *dev;
|
|
int (*release)(struct device *dev, struct devcd_info *info);
|
|
};
|
|
|
|
static inline void devcd_set_release(struct devcd_info *info,
|
|
int (*release)(struct device *,
|
|
struct devcd_info *))
|
|
{
|
|
info->release = release;
|
|
}
|
|
|
|
static inline int devcoredump(struct device *dev, const void *data,
|
|
size_t size, gfp_t gfp)
|
|
{
|
|
(void)dev; (void)data; (void)size; (void)gfp;
|
|
return 0;
|
|
}
|
|
|
|
static inline void devcd_free(struct devcd_info *info)
|
|
{
|
|
(void)info;
|
|
}
|
|
|
|
/* No exporter retains the payload: its head (the device, the ring and
|
|
* process that hung) goes to the kernel log at error level, which reaches
|
|
* the unified log as events (linuxu/src/shims/dev_coredump.c); then the
|
|
* transferred ownership is honored. */
|
|
void dev_coredumpm(struct device *dev, struct module *owner,
|
|
void *data, size_t datalen, gfp_t gfp,
|
|
ssize_t (*read)(char *buffer, loff_t offset, size_t count,
|
|
void *data, size_t datalen),
|
|
void (*free)(void *data));
|
|
|
|
#endif /* __LINUX_DEVCOREDUMP_H */
|