Commit fd1a5e52 authored by Paul Kocialkowski's avatar Paul Kocialkowski Committed by Patrik Jakobsson

drm/gma500: Fixup fbdev stolen size usage evaluation

psbfb_probe performs an evaluation of the required size from the stolen
GTT memory, but gets it wrong in two distinct ways:
- The resulting size must be page-size-aligned;
- The size to allocate is derived from the surface dimensions, not the fb
  dimensions.

When two connectors are connected with different modes, the smallest will
be stored in the fb dimensions, but the size that needs to be allocated must
match the largest (surface) dimensions. This is what is used in the actual
allocation code.

Fix this by correcting the evaluation to conform to the two points above.
It allows correctly switching to 16bpp when one connector is e.g. 1920x1080
and the other is 1024x768.
Signed-off-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: default avatarPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191107153048.843881-1-paul.kocialkowski@bootlin.com
parent f597c208
...@@ -462,6 +462,7 @@ static int psbfb_probe(struct drm_fb_helper *helper, ...@@ -462,6 +462,7 @@ static int psbfb_probe(struct drm_fb_helper *helper,
container_of(helper, struct psb_fbdev, psb_fb_helper); container_of(helper, struct psb_fbdev, psb_fb_helper);
struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; struct drm_device *dev = psb_fbdev->psb_fb_helper.dev;
struct drm_psb_private *dev_priv = dev->dev_private; struct drm_psb_private *dev_priv = dev->dev_private;
unsigned int fb_size;
int bytespp; int bytespp;
bytespp = sizes->surface_bpp / 8; bytespp = sizes->surface_bpp / 8;
...@@ -471,8 +472,11 @@ static int psbfb_probe(struct drm_fb_helper *helper, ...@@ -471,8 +472,11 @@ static int psbfb_probe(struct drm_fb_helper *helper,
/* If the mode will not fit in 32bit then switch to 16bit to get /* If the mode will not fit in 32bit then switch to 16bit to get
a console on full resolution. The X mode setting server will a console on full resolution. The X mode setting server will
allocate its own 32bit GEM framebuffer */ allocate its own 32bit GEM framebuffer */
if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height > fb_size = ALIGN(sizes->surface_width * bytespp, 64) *
dev_priv->vram_stolen_size) { sizes->surface_height;
fb_size = ALIGN(fb_size, PAGE_SIZE);
if (fb_size > dev_priv->vram_stolen_size) {
sizes->surface_bpp = 16; sizes->surface_bpp = 16;
sizes->surface_depth = 16; sizes->surface_depth = 16;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment