]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: improve the userq seq BO free bit lookup
authorPrike Liang <Prike.Liang@amd.com>
Tue, 26 May 2026 02:25:26 +0000 (10:25 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 3 Jun 2026 18:55:31 +0000 (14:55 -0400)
Use find_next_zero_bit() to locate the next free seq slot bit
instead of the current walk, for more efficient bitmap scanning.

Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ff905a9b6228de9eedd0db71ecb1bdde91fb898d)

drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c

index f4be19223588975a8acf06a31542989afd6123b5..21a225b0116a9c9b108e90938b344f8f7354259f 100644 (file)
@@ -173,16 +173,17 @@ error:
 int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 *va,
                       u64 *gpu_addr, u64 **cpu_addr)
 {
-       unsigned long bit_pos;
+       unsigned long bit_pos = 0;
 
-       for (;;) {
-               bit_pos = find_first_zero_bit(adev->seq64.used, adev->seq64.num_sem);
+       do {
+               bit_pos = find_next_zero_bit(adev->seq64.used,
+                                    adev->seq64.num_sem, bit_pos);
                if (bit_pos >= adev->seq64.num_sem)
                        return -ENOSPC;
-
                if (!test_and_set_bit(bit_pos, adev->seq64.used))
                        break;
-       }
+               bit_pos++;
+       } while (1);
 
        *va = bit_pos * sizeof(u64) + amdgpu_seq64_get_va_base(adev);