[PATCH] drm/atomic-helper: Do not assume vblank is always present

Javier Martinez Canillas javierm at redhat.com
Wed Apr 5 07:35:45 UTC 2023


Hello Zack,

Thanks for your patch.

Zack Rusin <zack at kde.org> writes:

> From: Zack Rusin <zackr at vmware.com>
>
> Many drivers (in particular all of the virtualized drivers) do not
> implement vblank handling. Assuming vblank is always present
> leads to crashes.
>
> Fix the crashes by making sure the device supports vblank before using
> it.
>

[...]

> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 299fa2a19a90..6438aeb1c65f 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -997,12 +997,16 @@ int drm_crtc_next_vblank_start(struct drm_crtc *crtc, ktime_t *vblanktime)
>  {
>  	unsigned int pipe = drm_crtc_index(crtc);
>  	struct drm_vblank_crtc *vblank = &crtc->dev->vblank[pipe];
> -	struct drm_display_mode *mode = &vblank->hwmode;
> +	struct drm_display_mode *mode;
>  	u64 vblank_start;
>  
> +	if (!drm_dev_has_vblank(crtc->dev))
> +		return -EINVAL;
> +
>  	if (!vblank->framedur_ns || !vblank->linedur_ns)
>  		return -EINVAL;
>  
> +	mode = &vblank->hwmode;
>  	if (!drm_crtc_get_last_vbltimestamp(crtc, vblanktime, false))
>  		return -EINVAL;
>  

Rob already posted more or less the same fix:

https://lore.kernel.org/lkml/CAF6AEGsdT95-uAKcv2+hdMLKd2xwfPeN+FMuDTRMc-Ps7WbRjw@mail.gmail.com/T/

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat



More information about the dri-devel mailing list