All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/fbdev: Clamp fbdev surface size if too large
@ 2021-10-04  8:15 Thomas Zimmermann
  2021-10-04  8:23 ` Ville Syrjälä
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Zimmermann @ 2021-10-04  8:15 UTC (permalink / raw)
  To: daniel, airlied, mripard, maarten.lankhorst, kernel,
	dirty.ice.hu, michael+lkml
  Cc: dri-devel, Thomas Zimmermann, Daniel Vetter, Maxime Ripard, stable

Clamp the fbdev surface size of the available maximum height to avoid
failing to init console emulation. An example error is shown below.

  bad framebuffer height 2304, should be >= 768 && <= 768
  [drm] Initialized simpledrm 1.0.0 20200625 for simple-framebuffer.0 on minor 0
  simple-framebuffer simple-framebuffer.0: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-22)

This is especially a problem with drivers that have very small screen
sizes and cannot over-allocate at all.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
Reported-by: Amanoel Dawod <kernel@amanoeldawod.com>
Reported-by: Zoltán Kővágó <dirty.ice.hu@gmail.com>
Reported-by: Michael Stapelberg <michael+lkml@stapelberg.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v5.14+
---
 drivers/gpu/drm/drm_fb_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 6860223f0068..364f11900b37 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1508,6 +1508,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
 {
 	struct drm_client_dev *client = &fb_helper->client;
 	struct drm_device *dev = fb_helper->dev;
+	struct drm_mode_config *config = &dev->mode_config;
 	int ret = 0;
 	int crtc_count = 0;
 	struct drm_connector_list_iter conn_iter;
@@ -1665,6 +1666,11 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
 	/* Handle our overallocation */
 	sizes.surface_height *= drm_fbdev_overalloc;
 	sizes.surface_height /= 100;
+	if (sizes.surface_height > config->max_height) {
+		drm_warn(dev, "Fbdev over-allocation too large; clamping height to %d\n",
+			 config->max_height);
+		sizes.surface_height = config->max_height;
+	}

 	/* push down into drivers */
 	ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
--
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/fbdev: Clamp fbdev surface size if too large
  2021-10-04  8:15 [PATCH] drm/fbdev: Clamp fbdev surface size if too large Thomas Zimmermann
@ 2021-10-04  8:23 ` Ville Syrjälä
  2021-10-05  6:52   ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Ville Syrjälä @ 2021-10-04  8:23 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: daniel, airlied, mripard, maarten.lankhorst, kernel,
	dirty.ice.hu, michael+lkml, dri-devel, Daniel Vetter,
	Maxime Ripard, stable

On Mon, Oct 04, 2021 at 10:15:06AM +0200, Thomas Zimmermann wrote:
> Clamp the fbdev surface size of the available maximum height to avoid
> failing to init console emulation. An example error is shown below.
> 
>   bad framebuffer height 2304, should be >= 768 && <= 768
>   [drm] Initialized simpledrm 1.0.0 20200625 for simple-framebuffer.0 on minor 0
>   simple-framebuffer simple-framebuffer.0: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-22)
> 
> This is especially a problem with drivers that have very small screen
> sizes and cannot over-allocate at all.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
> Reported-by: Amanoel Dawod <kernel@amanoeldawod.com>
> Reported-by: Zoltán Kővágó <dirty.ice.hu@gmail.com>
> Reported-by: Michael Stapelberg <michael+lkml@stapelberg.ch>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Maxime Ripard <maxime@cerno.tech>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v5.14+
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 6860223f0068..364f11900b37 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -1508,6 +1508,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>  {
>  	struct drm_client_dev *client = &fb_helper->client;
>  	struct drm_device *dev = fb_helper->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
>  	int ret = 0;
>  	int crtc_count = 0;
>  	struct drm_connector_list_iter conn_iter;
> @@ -1665,6 +1666,11 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>  	/* Handle our overallocation */
>  	sizes.surface_height *= drm_fbdev_overalloc;
>  	sizes.surface_height /= 100;
> +	if (sizes.surface_height > config->max_height) {
> +		drm_warn(dev, "Fbdev over-allocation too large; clamping height to %d\n",
> +			 config->max_height);

drm_warn() seems a bit excessive. drm_info()?

Or could just have no printk and use a simple min() perhaps.

> +		sizes.surface_height = config->max_height;
> +	}
> 
>  	/* push down into drivers */
>  	ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
> --
> 2.33.0

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/fbdev: Clamp fbdev surface size if too large
  2021-10-04  8:23 ` Ville Syrjälä
@ 2021-10-05  6:52   ` Thomas Zimmermann
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2021-10-05  6:52 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: daniel, airlied, mripard, maarten.lankhorst, kernel,
	dirty.ice.hu, michael+lkml, dri-devel, Daniel Vetter,
	Maxime Ripard, stable


[-- Attachment #1.1: Type: text/plain, Size: 2826 bytes --]

Hi

Am 04.10.21 um 10:23 schrieb Ville Syrjälä:
> On Mon, Oct 04, 2021 at 10:15:06AM +0200, Thomas Zimmermann wrote:
>> Clamp the fbdev surface size of the available maximum height to avoid
>> failing to init console emulation. An example error is shown below.
>>
>>    bad framebuffer height 2304, should be >= 768 && <= 768
>>    [drm] Initialized simpledrm 1.0.0 20200625 for simple-framebuffer.0 on minor 0
>>    simple-framebuffer simple-framebuffer.0: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-22)
>>
>> This is especially a problem with drivers that have very small screen
>> sizes and cannot over-allocate at all.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
>> Reported-by: Amanoel Dawod <kernel@amanoeldawod.com>
>> Reported-by: Zoltán Kővágó <dirty.ice.hu@gmail.com>
>> Reported-by: Michael Stapelberg <michael+lkml@stapelberg.ch>
>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Cc: Maxime Ripard <maxime@cerno.tech>
>> Cc: dri-devel@lists.freedesktop.org
>> Cc: <stable@vger.kernel.org> # v5.14+
>> ---
>>   drivers/gpu/drm/drm_fb_helper.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
>> index 6860223f0068..364f11900b37 100644
>> --- a/drivers/gpu/drm/drm_fb_helper.c
>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>> @@ -1508,6 +1508,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>>   {
>>   	struct drm_client_dev *client = &fb_helper->client;
>>   	struct drm_device *dev = fb_helper->dev;
>> +	struct drm_mode_config *config = &dev->mode_config;
>>   	int ret = 0;
>>   	int crtc_count = 0;
>>   	struct drm_connector_list_iter conn_iter;
>> @@ -1665,6 +1666,11 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
>>   	/* Handle our overallocation */
>>   	sizes.surface_height *= drm_fbdev_overalloc;
>>   	sizes.surface_height /= 100;
>> +	if (sizes.surface_height > config->max_height) {
>> +		drm_warn(dev, "Fbdev over-allocation too large; clamping height to %d\n",
>> +			 config->max_height);
> 
> drm_warn() seems a bit excessive. drm_info()?
> 
> Or could just have no printk and use a simple min() perhaps.

The framebuffer code uses debug_kms for this kind of message. I guess, 
I'll go with that.

Best regards
Thamas

> 
>> +		sizes.surface_height = config->max_height;
>> +	}
>>
>>   	/* push down into drivers */
>>   	ret = (*fb_helper->funcs->fb_probe)(fb_helper, &sizes);
>> --
>> 2.33.0
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-05  6:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04  8:15 [PATCH] drm/fbdev: Clamp fbdev surface size if too large Thomas Zimmermann
2021-10-04  8:23 ` Ville Syrjälä
2021-10-05  6:52   ` Thomas Zimmermann

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.