The doorbells in AMDGPU drivers are currently managed by different users in a scattered way, across the driver. The existing clients are: - AMDGPU graphics driver for kernel level doorbell writes. - AMDGPU MES module for kernel level doorbell write (MES ring test). - AMDGPU MES modules for kernel level aggregated doorbell writes. - AMDGPU MES module for MES process doorbell writes. - AMDKFD module for KFD/KIQ kernel doorbell writes. - AMDKFD module for KFD process doorbell writes. - AMDGPU usermode queues for usermode doorbell writes (upcoming).
This patch series introduces Doorbell-manager to keep the doorbell handling at a central place. The fundamental changes are: - Introduce and accommodate a new GEM domain for doorbells. - Prepare the AMDGPU ttm backend for handling doorbell allocation. - Introduce doorbell-manager functions to allocate, free and index doorbells in one unique way. - Create doorbell BOs for kernel-level and process level doorbell opertations, and place it in existing structures. - Modify the existing graphics, KFD and MES code to use the doorbell-manager functions. - Remove the existing doorbell management code in KFD/MES. PS: This series has been sanity tested with kfd_test_suit to ensure it is not introducing any regressions due to kfd doorbell changes. The idea is that: - a kernel client can call doorbell manager functions to allocate/free doorbell pages. - a usermode app can directly allocate a page from the doorbell bar just like a GEM object and use it for different usermode queues. Alex Deucher (2): drm/amdgpu: add UAPI for allocating doorbell memory drm/amdgpu: accommodate DOMAIN/PL_DOORBELL Shashank Sharma (14): drm/amdgpu: rename num_doorbells drm/amdgpu: include protection for doobell.h drm/amdgpu: create a new file for doorbell manager drm/amdgpu: don't modify num_doorbells for mes drm/amdgpu: add helper to create doorbell pages drm/amdgpu: initialize ttm for doorbells drm/amdgpu: create kernel doorbell page drm/amdgpu: validate doorbell read/write drm/amdgpu: get absolute offset from doorbell index drm/amdgpu: use doorbell manager for kfd kernel doorbells drm/amdgpu: use doorbell manager for kfd process doorbells drm/amdgpu: remove ununsed functions and variables drm/amdgpu: use doorbell mgr for MES kernel doorbells drm/amdgpu: user doorbell mgr for MES process doorbells drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 164 ---------- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 102 +++++- .../gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c | 304 ++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 165 +++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 17 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 +- .../gpu/drm/amd/amdgpu/amdgpu_res_cursor.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 31 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 1 + drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 13 - drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 +- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +- drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c | 198 ++++-------- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 23 +- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 26 +- .../amd/amdkfd/kfd_process_queue_manager.c | 16 +- include/uapi/drm/amdgpu_drm.h | 7 +- 19 files changed, 636 insertions(+), 472 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell_mgr.c -- 2.40.0