Skip to contentSkip to conversation

uvc_ctrl_commit() not rolling back / restoring UVC_CTRL_DATA_BACKUP of not yet processed entities on errors

DISCUSSION Hans de Goede 2 participants 2 messages Dec 2, 2024 – Dec 10, 2024 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hi All,

While reviewing Ricardo's "[PATCH v4 0/4] media: uvcvideo: Two fixes for async controls" series I noticed that uvc_ctrl_commit() stops processing entities on an error:

	list_for_each_entry(entity, &chain->entities, chain) {
		ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
					     &err_ctrl);
		if (ret < 0) {
			if (ctrls)
				ctrls->error_idx =
					uvc_ctrl_find_ctrl_idx(entity, ctrls,
							       err_ctrl);
			goto done;
		}
	}

This means that if there are further entities with changed ctrls in the chain, not only do the new ctrl values not get committed which is expected. But the new values do get kept in the drivers cached ctrl values.

I believe that what needs to happen instead is that the loop over all entities is continued, but for the other entities uvc_ctrl_commit_entity() needs to be called with rollback = 1 after the error.

Regards,

Hans

#1 lore raw

Hi Hans

Quoted 24 lines · Hans de Goede

Hi All,

While reviewing Ricardo's "[PATCH v4 0/4] media: uvcvideo: Two fixes for async controls" series I noticed that uvc_ctrl_commit() stops processing entities on an error:

        list_for_each_entry(entity, &chain->entities, chain) {
                ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
                                             &err_ctrl);
                if (ret < 0) {
                        if (ctrls)
                                ctrls->error_idx =
                                        uvc_ctrl_find_ctrl_idx(entity, ctrls,
                                                               err_ctrl);
                        goto done;
                }
        }

This means that if there are further entities with changed ctrls in the chain, not only do the new ctrl values not get committed which is expected. But the new values do get kept in the drivers cached ctrl values.

Quoted 5 lines

I believe that what needs to happen instead is that the loop over all entities is continued, but for the other entities uvc_ctrl_commit_entity() needs to be called with rollback = 1 after the error.

I believe that you are correct. Check out this patchset:
https://lore.kernel.org/linux-media/[email protected]/T/#t

Regards!

Quoted 7 lines

Regards,

Hans

Signature · 1 line
Ricardo Ribalda