drm/amdgpu: optimize queue reset and stop logic for sdma_v5_0
authorJesse.zhang@amd.com <Jesse.zhang@amd.com>
Wed, 16 Apr 2025 06:03:02 +0000 (14:03 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 21 Apr 2025 14:57:04 +0000 (10:57 -0400)
commit574f4b5562cc11da7beb8c14b51a846da8263f89
tree673c48443740085c6741070c44b02282bce88061
parent47454f2dc0bf6774c8dbe7226bcf50ba24a788a8
drm/amdgpu: optimize queue reset and stop logic for sdma_v5_0

This patch refactors the SDMA v5.0 queue reset and stop logic to improve
code readability, maintainability, and performance. The key changes include:

1. **Generalized `sdma_v5_0_gfx_stop` Function**:
   - Added an `inst_mask` parameter to allow stopping specific SDMA instances
     instead of all instances. This is useful for resetting individual queues.

2. **Simplified `sdma_v5_0_reset_queue` Function**:
   - Removed redundant loops and checks by directly using the `ring->me` field
     to identify the SDMA instance.
   - Reused the `sdma_v5_0_gfx_stop` function to stop the queue, reducing code
     duplication.

v1: The general coding style is to declare variables like "i" or "r" last. E.g. longest lines first and short lasts. (Chritian)

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c