es preemption.” - By tying `KFD_UNMAP_LATENCY_MS` to `queue_preemption_timeout_ms`, the SDMA preemption budget scales consistently with the CP fence wait, avoiding premature timeouts and improving reliability. - Where the new value is used - Programmed into MES/PM4 packets (units of 100 ms): `packet->bitfields2.unmap_latency = KFD_UNMAP_LATENCY_MS / 100;` in `drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_vi.c:129` and `drivers/gpu/drm/amd/amdkfd/kfd_packet_manager_v9.c:205`. - Passed as the timeout when destroying MQDs (preempt/unmap paths): calls to `mqd_mgr->destroy_mqd(..., KFD_UNMAP_LATENCY_MS, ...)` in `drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:884`, `drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:996`, and `drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:1175`. - Used for resetting hung queues via `hqd_reset(..., KFD_UNMAP_LATENCY_MS)` in `drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2230`. - Stable criteria assessment - Fixes a real-world reliability issue (timeouts/mismatched budgets) that affects users, especially on slow systems and when `queue_preemption_timeout_ms` is tuned. - Change is small, contained to a single macro in one header (`kfd_priv.h`) with clear rationale and no architectural refactoring. - Side effects are minimal: default behavior remains effectively unchanged (for 9000 ms, `KFD_UNMAP_LATENCY_MS` becomes ~4050 ms; when quantized to 100 ms units it still programs 40), while non- default configurations become consistent and safer. - Touches KFD/amdgpu preemption logic but only adjusts a timeout parameter already designed to be user-configurable; no new features introduced. Given the above, this is a low-risk, correctness-improving timeout alignment and a good candidate for backporting to stable. drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 67694bcd94646..d01ef5ac07666 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -111,7 +111,14 @@ #define KFD_KERNEL_QUEUE_SIZE 2048 -#define KFD_UNMAP_LATENCY_MS (4000) +/* KFD_UNMAP_LATENCY_MS is the timeout CP waiting for SDMA preemption. One XCC + * can be associated to 2 SDMA engines. queue_preemption_timeout_ms is the time + * driver waiting for CP returning the UNMAP_QUEUE fence. Thus the math is + * queue_preemption_timeout_ms = sdma_preemption_time * 2 + cp workload + * The format here makes CP workload 10% of total timeout + */ +#define KFD_UNMAP_LATENCY_MS \ + ((queue_preemption_timeout_ms - queue_preemption_timeout_ms / 10) >> 1) #define KFD_MAX_SDMA_QUEUES 128 -- 2.51.0[PATCH AUTOSEL 6.17-5.4] drm/amdkfd: Tie UNMAP_LATENCY to queue_preemptionSasha Levin undefinedpatches@lists.linux.dev, stable@vger.kernel.org undefined undefined undefined undefined undefined undefined undefinedKm