[16/37] drm/virtio: Call drm_helper_mode_fill_fb_struct() before drm_framebuffer_init()
diff mbox

Message ID 1479498793-31021-17-git-send-email-ville.syrjala@linux.intel.com
State New
Headers show

Commit Message

Ville Syrjälä Nov. 18, 2016, 7:52 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

We want framebuffers to be mostly useable already before
drm_framebuffer_init() get called, and so we will start demanding that
all the interesting format/size/etc. information be filled in before
drm_framebuffer_init(). drm_helper_mode_fill_fb_struct() will do that
for us, so let's make sure it gets called before drm_framebuffer_init().

Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel Vetter Nov. 30, 2016, 3:32 p.m. UTC | #1
On Fri, Nov 18, 2016 at 09:52:52PM +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> We want framebuffers to be mostly useable already before
> drm_framebuffer_init() get called, and so we will start demanding that
> all the interesting format/size/etc. information be filled in before
> drm_framebuffer_init(). drm_helper_mode_fill_fb_struct() will do that
> for us, so let's make sure it gets called before drm_framebuffer_init().
> 
> Cc: Dave Airlie <airlied@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Yup, kernel-doc even says that drm_framebuffer_init() must be the very
last thing or races. I've done a full audit, and qxl&virtio are the only
two offenders. On both patches:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/virtio/virtgpu_display.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
> index 8b80fdd0e0a8..fad5a1cc5903 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_display.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
> @@ -88,12 +88,13 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
>  
>  	bo = gem_to_virtio_gpu_obj(obj);
>  
> +	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
> +
>  	ret = drm_framebuffer_init(dev, &vgfb->base, &virtio_gpu_fb_funcs);
>  	if (ret) {
>  		vgfb->obj = NULL;
>  		return ret;
>  	}
> -	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
>  
>  	spin_lock_init(&vgfb->dirty_lock);
>  	vgfb->x1 = vgfb->y1 = INT_MAX;
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 8b80fdd0e0a8..fad5a1cc5903 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -88,12 +88,13 @@  virtio_gpu_framebuffer_init(struct drm_device *dev,
 
 	bo = gem_to_virtio_gpu_obj(obj);
 
+	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
+
 	ret = drm_framebuffer_init(dev, &vgfb->base, &virtio_gpu_fb_funcs);
 	if (ret) {
 		vgfb->obj = NULL;
 		return ret;
 	}
-	drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
 
 	spin_lock_init(&vgfb->dirty_lock);
 	vgfb->x1 = vgfb->y1 = INT_MAX;