On 5/26/26 04:58, Prike Liang wrote:
> 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 <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
> index f4be19223588..63771d6d466e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c
> @@ -175,14 +175,15 @@ int amdgpu_seq64_alloc(struct amdgpu_device *adev, u64 
> *va,
>  {
>       unsigned long bit_pos;
>  
> -     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);

bit_pos is uninitialized for the first look here.

>               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);
>  

Reply via email to