[PATCH v14 37/41] compositor-drm: Add test-only mode to state application

Philipp Zabel p.zabel at pengutronix.de
Wed Jan 3 17:53:06 UTC 2018


On Wed, 2017-12-20 at 12:26 +0000, Daniel Stone wrote:
> @@ -2424,9 +2453,16 @@ drm_pending_state_apply_atomic(struct drm_pending_state *pending_state,
>  	case DRM_STATE_APPLY_ASYNC:
>  		flags |= DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_NONBLOCK;
>  		break;
> +	case DRM_STATE_TEST_ONLY:
> +		flags |= DRM_MODE_ATOMIC_TEST_ONLY;
> +		break;
>  	}
>  
>  	ret = drmModeAtomicCommit(b->drm.fd, req, flags, b);
> +
> +	if (mode == DRM_STATE_TEST_ONLY)
> +		return ret;

This leaks req, which is allocated at the beginning of this function.
The return could be changed to "goto out;" instead.

> +
>  	if (ret != 0) {
>  		weston_log("atomic: couldn't commit new state: %m\n");
>  		goto out;
> @@ -2446,6 +2482,22 @@ out:
>  }
>  #endif
>  
> +static int
> +drm_pending_state_test(struct drm_pending_state *pending_state)

Contrary to (as far as I understand) drm_pending_state_apply and
drm_pending_state_apply_sync, drm_pending_state_test does not take
ownership of pending_state and is not supposed to free it. Is this
something that should be documented with a comment?

> +{
> +#ifdef HAVE_DRM_ATOMIC
> +	struct drm_backend *b = pending_state->backend;
> +
> +	if (b->atomic_modeset)
> +		return drm_pending_state_apply_atomic(pending_state,
> +						      DRM_STATE_TEST_ONLY);
> +#endif
> +
> +	/* We have no way to test state before application on the legacy
> +	 * modesetting API, so just claim it succeeded. */
> +	return 0;
> +}
> +
>  static int
>  drm_pending_state_apply(struct drm_pending_state *pending_state)
>  {

regards
Philipp


More information about the wayland-devel mailing list