Skip to contentSkip to conversation

drm/drm_exec: remove contention for num_objects is 0

PATCH Christian König 1 participant 1 message Sep 8 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

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

Quoted 5 lines · Sunil Khatri

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.

Quoted 5 lines

Add an additional check during prepare when num_objects is zero resolved this infinite loop.

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

Quoted 9 lines
---
 drivers/gpu/drm/drm_exec.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_exec.c +0 -0
index 7988f5e7d56a..cd360f0c903a 100644

drivers/gpu/drm/drm_exec.c int drm_exec_prepare_array(struct drm_exec *exec, · line 327

Quoted 6 lines
drivers/gpu/drm/drm_exec.c +3 -0
@@ -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.

Quoted 3 lines
drivers/gpu/drm/drm_exec.c +0 -0
 	for (unsigned int i = 0; i < num_objects; ++i) {
 		ret = drm_exec_prepare_obj(exec, objects[i], num_fences);
 		if (unlikely(ret))