diff mbox series

[4/4] drm/i915: Throw away the BIOS fb if has the wrong depth/bpp

Message ID 20190607162611.23514-4-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/fb-helper: Do not assume drm_mode_create_from_cmdline_mode() can't fail | expand

Commit Message

Ville Syrjälä June 7, 2019, 4:26 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Respect the user's choice of depth/bpp for the fbdev framebuffer
and throw out the fb we inherited from the BIOS if it doesn't
match.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_fbdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Daniel Vetter June 7, 2019, 6:43 p.m. UTC | #1
On Fri, Jun 07, 2019 at 07:26:11PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Respect the user's choice of depth/bpp for the fbdev framebuffer
> and throw out the fb we inherited from the BIOS if it doesn't
> match.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I guess we're going boom right now, which is maybe a bit much? i.e.
Cc: stable@vger.kernel.org

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

> ---
>  drivers/gpu/drm/i915/intel_fbdev.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> index 0d3a6fa674e6..1a935dc74d23 100644
> --- a/drivers/gpu/drm/i915/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> @@ -199,6 +199,17 @@ static int intelfb_create(struct drm_fb_helper *helper,
>  		drm_framebuffer_put(&intel_fb->base);
>  		intel_fb = ifbdev->fb = NULL;
>  	}
> +	if (intel_fb &&
> +	    (sizes->surface_depth != intel_fb->base.format->depth ||
> +	     sizes->surface_bpp != intel_fb->base.format->cpp[0] * 8)) {

Bikeshed: A little helper that does all these checks with debug output,
and just one "throw bios fb away" path would look a lot neater.
-Daniel

> +		DRM_DEBUG_KMS("BIOS fb using wrong depth/bpp (%d/%d), we require (%d/%d),"
> +			      " releasing it\n",
> +			      intel_fb->base.format->depth,
> +			      intel_fb->base.format->cpp[0] * 8,
> +			      sizes->surface_depth, sizes->surface_bpp);
> +		drm_framebuffer_put(&intel_fb->base);
> +		intel_fb = ifbdev->fb = NULL;
> +	}
>  	if (!intel_fb || WARN_ON(!intel_fb_obj(&intel_fb->base))) {
>  		DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
>  		ret = intelfb_alloc(helper, sizes);
> -- 
> 2.21.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Ville Syrjälä June 11, 2019, 5:51 p.m. UTC | #2
On Fri, Jun 07, 2019 at 08:43:56PM +0200, Daniel Vetter wrote:
> On Fri, Jun 07, 2019 at 07:26:11PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Respect the user's choice of depth/bpp for the fbdev framebuffer
> > and throw out the fb we inherited from the BIOS if it doesn't
> > match.
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I guess we're going boom right now, which is maybe a bit much? i.e.
> Cc: stable@vger.kernel.org

I think currently it just ignores whatever the user said.
I didn't see any explosions.

> 
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> > ---
> >  drivers/gpu/drm/i915/intel_fbdev.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
> > index 0d3a6fa674e6..1a935dc74d23 100644
> > --- a/drivers/gpu/drm/i915/intel_fbdev.c
> > +++ b/drivers/gpu/drm/i915/intel_fbdev.c
> > @@ -199,6 +199,17 @@ static int intelfb_create(struct drm_fb_helper *helper,
> >  		drm_framebuffer_put(&intel_fb->base);
> >  		intel_fb = ifbdev->fb = NULL;
> >  	}
> > +	if (intel_fb &&
> > +	    (sizes->surface_depth != intel_fb->base.format->depth ||
> > +	     sizes->surface_bpp != intel_fb->base.format->cpp[0] * 8)) {
> 
> Bikeshed: A little helper that does all these checks with debug output,
> and just one "throw bios fb away" path would look a lot neater.
> -Daniel
> 
> > +		DRM_DEBUG_KMS("BIOS fb using wrong depth/bpp (%d/%d), we require (%d/%d),"
> > +			      " releasing it\n",
> > +			      intel_fb->base.format->depth,
> > +			      intel_fb->base.format->cpp[0] * 8,
> > +			      sizes->surface_depth, sizes->surface_bpp);
> > +		drm_framebuffer_put(&intel_fb->base);
> > +		intel_fb = ifbdev->fb = NULL;
> > +	}
> >  	if (!intel_fb || WARN_ON(!intel_fb_obj(&intel_fb->base))) {
> >  		DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
> >  		ret = intelfb_alloc(helper, sizes);
> > -- 
> > 2.21.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 0d3a6fa674e6..1a935dc74d23 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -199,6 +199,17 @@  static int intelfb_create(struct drm_fb_helper *helper,
 		drm_framebuffer_put(&intel_fb->base);
 		intel_fb = ifbdev->fb = NULL;
 	}
+	if (intel_fb &&
+	    (sizes->surface_depth != intel_fb->base.format->depth ||
+	     sizes->surface_bpp != intel_fb->base.format->cpp[0] * 8)) {
+		DRM_DEBUG_KMS("BIOS fb using wrong depth/bpp (%d/%d), we require (%d/%d),"
+			      " releasing it\n",
+			      intel_fb->base.format->depth,
+			      intel_fb->base.format->cpp[0] * 8,
+			      sizes->surface_depth, sizes->surface_bpp);
+		drm_framebuffer_put(&intel_fb->base);
+		intel_fb = ifbdev->fb = NULL;
+	}
 	if (!intel_fb || WARN_ON(!intel_fb_obj(&intel_fb->base))) {
 		DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
 		ret = intelfb_alloc(helper, sizes);