mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
When a definite PCI transport fault is recorded, admission closes. From then on nothing this driver waits for on the GPU completes. Fences, eviction copies and MES requests all wait forever, and they hold the session queue, which is also where the driver's Stop runs. The three 248 instances from today's hangs never exited after the GPU was power-cycled, and the upgrade to 249 waited on them until the user killed them. - The first fault logs where it came from: the frame-pointer return addresses above it and record_fault's own address, so atos places them in the dext binary. This is what named amdgpu_gmc_set_pte_pde. It runs only on that fault. - dext_pci_set_fault_hook: the session layer reacts once, on the faulting thread. transport_lost calls rt_device_lost. That does what a removal does: the DRM device counts as unplugged, there is no hardware access, and every ring's fences are force-completed with -ECANCELED, now and from a thread every 5 ms. So no wait outlives the fault. Unlike a removal, the PCI device is not marked disconnected (rt_removal_active stays false), so what the GPU may still reach stays retained by the fault's DMA quarantine. - With the GPU unreachable, the last client's leaving closes the session. The close quarantines, naming the PCI fault. When the device then leaves the bus, the removal releases the session and the driver stops. rt_removal_end also stops the lost device's thread, and a new session starts with s_deviceLost clear. session shutdown transport-fault-removal: a fault while a program and the display run, with one hook reaction even when it fires twice. The program leaves, the close quarantines on the fault, the power cycle removes the device, and the instance finishes and stops.
76 lines
3.7 KiB
C
76 lines
3.7 KiB
C
/* Surprise removal of the GPU (a Thunderbolt unplug): the device left the
|
|
* bus while the driver, its sessions and clients still run.
|
|
*
|
|
* Linux handles this in two halves. The PCI core marks the device
|
|
* disconnected (pci_dev_set_disconnected), so pci_dev_is_disconnected()
|
|
* holds and amdgpu's removal takes its hot-unplug branches; then it calls
|
|
* amdgpu_pci_remove, which unplugs the DRM device first (drm_dev_unplug:
|
|
* drm_dev_enter() fails from then on, so upstream skips every guarded
|
|
* hardware access, GART table writes among them), finishes the hardware
|
|
* without waiting for it (amdgpu_fence_driver_hw_fini force-completes every
|
|
* ring's fences with -ECANCELED instead of waiting), tears KFD down early
|
|
* (amdgpu_amdkfd_device_fini_sw) and unmaps MMIO.
|
|
*
|
|
* In the dext the sessions and client processes still have to close before
|
|
* amdgpu_pci_remove runs, and they wait on GPU work: fences of submitted
|
|
* jobs, MES acknowledgements, copies. rt_removal_begin puts the device in
|
|
* the state the Linux removal path establishes, from the start:
|
|
* - the PCI device is marked disconnected (linuxu_pci_mark_removed);
|
|
* - adev->no_hw_access: register and doorbell accesses are skipped, as
|
|
* amdgpu_device_halt does;
|
|
* - the DRM device counts as unplugged for drm_dev_enter, so guarded
|
|
* paths skip the hardware and render-node ioctls fail with -ENODEV;
|
|
* - every ring's fences are force-completed with -ECANCELED, as
|
|
* amdgpu_fence_driver_hw_fini does for an unplugged device, and keep
|
|
* being so (a removal thread, every RT_REMOVAL_TICK_MS) for work
|
|
* submitted while the sessions close: no wait for the GPU outlives the
|
|
* removal, and a MES request fails at once instead of after its timeout.
|
|
* A device that is gone cannot reach host memory: nothing the sessions
|
|
* kept for a GPU that might still run needs keeping once removal began
|
|
* (rt_removal_active). rt_removal_end stops the removal thread; call it
|
|
* after the sessions closed and before amdgpu_pci_remove (whose own
|
|
* hardware finish completes what is left).
|
|
*
|
|
* Runtime: linuxu/src/amdgpu-rt/removal.c. */
|
|
#ifndef LINUXU_RT_REMOVAL_H
|
|
#define LINUXU_RT_REMOVAL_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct pci_dev;
|
|
struct amdgpu_device;
|
|
|
|
#define RT_REMOVAL_TICK_MS 5u
|
|
|
|
/* Begin the removal of the device bound to @pdev (or of @pdev alone when
|
|
* no amdgpu device is bound). Idempotent; 0, or -ENOMEM when the removal
|
|
* thread could not start (fences are still force-completed once). */
|
|
int rt_removal_begin(struct pci_dev *pdev);
|
|
/* The device bound to @pdev no longer answers this driver (a definite PCI
|
|
* transport fault closed admission) while it may still be on the bus: as
|
|
* for a removal, the DRM device counts as unplugged, hardware access stops
|
|
* and every ring's fences are force-completed with -ECANCELED from now on
|
|
* (the removal thread), so no wait for GPU work blocks forever. Unlike a
|
|
* removal the PCI device is not marked disconnected (rt_removal_active
|
|
* stays false): the GPU may still reach host memory, so what it was given
|
|
* stays retained. Idempotent; any thread; rt_removal_end stops it. */
|
|
int rt_device_lost(struct pci_dev *pdev, const char *why);
|
|
/* rt_device_lost for the device the runtime serves now (none: 0). */
|
|
int rt_device_lost_active(const char *why);
|
|
/* Stop the removal thread (fences are completed a last time). */
|
|
void rt_removal_end(void);
|
|
/* Whether @adev's device was removed (rt_removal_begin, or a device that no
|
|
* longer answers configuration reads). */
|
|
bool rt_removal_active(struct amdgpu_device *adev);
|
|
/* Fence completions the removal forced so far (diagnostics, tests). */
|
|
unsigned long rt_removal_completions(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|