From: Paul Kocialkowski <paul.kocialkowski@bootlin.com> To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, James Hilliard <james.hilliard1@gmail.com>, Paul Kocialkowski <paul.kocialkowski@bootlin.com> Subject: [PATCH] drm/gma500: Fixup fbdev stolen size usage evaluation Date: Thu, 7 Nov 2019 16:30:48 +0100 [thread overview] Message-ID: <20191107153048.843881-1-paul.kocialkowski@bootlin.com> (raw) 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: Paul Kocialkowski <paul.kocialkowski@bootlin.com> --- drivers/gpu/drm/gma500/framebuffer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index 218f3bb15276..90237abee088 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -462,6 +462,7 @@ static int psbfb_probe(struct drm_fb_helper *helper, container_of(helper, struct psb_fbdev, psb_fb_helper); struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; struct drm_psb_private *dev_priv = dev->dev_private; + unsigned int fb_size; int bytespp; bytespp = sizes->surface_bpp / 8; @@ -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 a console on full resolution. The X mode setting server will allocate its own 32bit GEM framebuffer */ - if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height > - dev_priv->vram_stolen_size) { + fb_size = ALIGN(sizes->surface_width * bytespp, 64) * + sizes->surface_height; + fb_size = ALIGN(fb_size, PAGE_SIZE); + + if (fb_size > dev_priv->vram_stolen_size) { sizes->surface_bpp = 16; sizes->surface_depth = 16; } -- 2.23.0
WARNING: multiple messages have this Message-ID (diff)
From: Paul Kocialkowski <paul.kocialkowski@bootlin.com> To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: David Airlie <airlied@linux.ie>, Paul Kocialkowski <paul.kocialkowski@bootlin.com>, James Hilliard <james.hilliard1@gmail.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com> Subject: [PATCH] drm/gma500: Fixup fbdev stolen size usage evaluation Date: Thu, 7 Nov 2019 16:30:48 +0100 [thread overview] Message-ID: <20191107153048.843881-1-paul.kocialkowski@bootlin.com> (raw) Message-ID: <20191107153048.apkBkCSj8D4x-PPaK38tkMLrPxmvPav9RtU_9QgOZHw@z> (raw) 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: Paul Kocialkowski <paul.kocialkowski@bootlin.com> --- drivers/gpu/drm/gma500/framebuffer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index 218f3bb15276..90237abee088 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -462,6 +462,7 @@ static int psbfb_probe(struct drm_fb_helper *helper, container_of(helper, struct psb_fbdev, psb_fb_helper); struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; struct drm_psb_private *dev_priv = dev->dev_private; + unsigned int fb_size; int bytespp; bytespp = sizes->surface_bpp / 8; @@ -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 a console on full resolution. The X mode setting server will allocate its own 32bit GEM framebuffer */ - if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height > - dev_priv->vram_stolen_size) { + fb_size = ALIGN(sizes->surface_width * bytespp, 64) * + sizes->surface_height; + fb_size = ALIGN(fb_size, PAGE_SIZE); + + if (fb_size > dev_priv->vram_stolen_size) { sizes->surface_bpp = 16; sizes->surface_depth = 16; } -- 2.23.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2019-11-07 15:31 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-07 15:30 Paul Kocialkowski [this message] 2019-11-07 15:30 ` [PATCH] drm/gma500: Fixup fbdev stolen size usage evaluation Paul Kocialkowski 2019-11-12 10:20 ` Patrik Jakobsson 2019-11-12 10:20 ` Patrik Jakobsson 2019-11-12 15:11 ` Paul Kocialkowski 2019-11-12 15:11 ` Paul Kocialkowski 2019-11-12 15:50 ` Paul Kocialkowski 2019-11-12 15:50 ` Paul Kocialkowski 2019-11-13 10:04 ` Patrik Jakobsson 2019-11-13 10:04 ` Patrik Jakobsson 2019-11-19 14:11 ` Paul Kocialkowski 2019-11-19 14:11 ` Paul Kocialkowski 2019-11-19 20:46 ` Patrik Jakobsson 2019-11-19 20:46 ` Patrik Jakobsson
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191107153048.843881-1-paul.kocialkowski@bootlin.com \ --to=paul.kocialkowski@bootlin.com \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=james.hilliard1@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=patrik.r.jakobsson@gmail.com \ --cc=thomas.petazzoni@bootlin.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.