The subject line should be something like "fix contention when num_objects is 
0" to actually note that this is an important bug fix.

On 9/7/26 17:38, Sunil Khatri wrote:
> Drivers that chain multiple drm_exec_prepare_array()
> calls per drm_exec_until_all_locked() iteration could
> pass num_objects as 0 in one prepare array under
> contention could lead to infinite retry to lock loop
> check as contention is never reset in loop with 0 objects.

That needs a bit more description. I know what it is all about but somebody not 
familiar with the problem won't get why this can cause an endless loop.

> 
> Add an additional check during prepare when num_objects is
> zero resolved this infinite loop.
> 
> Signed-off-by: Sunil Khatri <[email protected]>

That needs CC: stable and Fixes tag. Potentially the patch when 
drm_exec_prepare_array() was added.

> ---
>  drivers/gpu/drm/drm_exec.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_exec.c b/drivers/gpu/drm/drm_exec.c
> index 7988f5e7d56a..cd360f0c903a 100644
> --- a/drivers/gpu/drm/drm_exec.c
> +++ b/drivers/gpu/drm/drm_exec.c
> @@ -322,6 +322,9 @@ int drm_exec_prepare_array(struct drm_exec *exec,
>  {
>       int ret;
>  
> +     if (!num_objects)
> +             return drm_exec_lock_contended(exec);
> +

We need a comment here explaining why that is important to have.

Something like:

/**
 * Make sure to clear look contention when no objects are handled to avoid 
endless loop in patterns like:
 * ret = drm_exec_prepare_array(exec, objs, num_objects); with num_objects = 0
 * drm_exec_retry_on_contention(exec);
 */

Regards,
Christian.

>       for (unsigned int i = 0; i < num_objects; ++i) {
>               ret = drm_exec_prepare_obj(exec, objects[i], num_fences);
>               if (unlikely(ret))

Reply via email to