dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Menzel <paulepanter@users.sourceforge.net>
To: Christopher Harvey <charvey@matrox.com>
Cc: Julia Lemire <jlemire@matrox.com>,
	Mathieu Larouche <mathieu.larouche@matrox.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/mgag200: Reject modes that are too big for VRAM
Date: Wed, 27 Feb 2013 00:34:56 +0100	[thread overview]
Message-ID: <1361921696.6140.34.camel@mattotaupa> (raw)
In-Reply-To: <20130226155544.GA18661@harvey-pc.matrox.com>


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

Am Dienstag, den 26.02.2013, 10:55 -0500 schrieb Christopher Harvey:
> A monitor or a user could request a resolution greater than the
> available VRAM for the backing framebuffer. This change checks the
> required framebuffer size against the max VRAM size and rejects modes
> if they are too big. This change can also remove a mode request passed
> in via the video= parameter.
> 
> Signed-off-by: Christopher Harvey <charvey@matrox.com>
> ---
>  drivers/gpu/drm/mgag200/mgag200_mode.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
> index 3abf197..6b5db83 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -1405,6 +1405,14 @@ static int mga_vga_get_modes(struct drm_connector *connector)
>  static int mga_vga_mode_valid(struct drm_connector *connector,
>  				 struct drm_display_mode *mode)
>  {
> +	struct drm_device *dev = connector->dev;
> +	struct mga_device *mdev = (struct mga_device*)dev->dev_private;
> +	struct mga_fbdev *mfbdev = mdev->mfbdev;
> +	struct drm_fb_helper *fb_helper = &mfbdev->helper;
> +	struct drm_fb_helper_connector *fb_helper_conn = NULL;
> +	int bpp = 32;
> +	int i = 0;

It is initialized in the for loop again.

> +
>  	/* FIXME: Add bandwidth and g200se limitations */
>  
>  	if (mode->crtc_hdisplay > 2048 || mode->crtc_hsync_start > 4096 ||
> @@ -1414,6 +1422,25 @@ static int mga_vga_mode_valid(struct drm_connector *connector,
>  		return MODE_BAD;
>  	}
>  
> +	/* Validate the mode input by the user */
> +	for (i = 0; i < fb_helper->connector_count; i++) {
> +		if (fb_helper->connector_info[i]->connector == connector) {
> +			/* Found the helper for this connector */
> +			fb_helper_conn = fb_helper->connector_info[i];
> +			if (fb_helper_conn->cmdline_mode.specified) {
> +				if (fb_helper_conn->cmdline_mode.bpp_specified) {
> +					bpp = fb_helper_conn->cmdline_mode.bpp;
> +				}
> +			}
> +		}
> +	}

Is such a function not used somewhere else already? Like get
user_parameters or so?

> +
> +	if ((mode->hdisplay * mode->vdisplay * (bpp/8)) > mdev->mc.vram_size) {
> +		if (fb_helper_conn)
> +			fb_helper_conn->cmdline_mode.specified = false;

A debug message specifying that this is due to VRAM size would be
helpful I guess.

> +		return MODE_BAD;

I guess that will print the requested mode so it does not need to be
specified above.

> +	}
> +
>  	return MODE_OK;
>  }
>  


Thanks,

Paul

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2013-02-26 23:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 15:52 [PATCH] mgag200: some cleanup and a fix for corrupted output Christopher Harvey
2013-02-26 15:53 ` [PATCH] drm/mgag200: Cleanup: Remove pointless call to drm_fb_get_bpp_depth Christopher Harvey
2013-02-26 23:22   ` Paul Menzel
2013-02-26 15:54 ` [PATCH] drm/mgag200: Cleanup: 'fbdev_list' in 'struct mga_fbdev' is not used Christopher Harvey
2013-02-26 15:54 ` [PATCH] drm/mgag200: Cleanup: Pass driver specific mga_device in driver functions Christopher Harvey
2013-02-26 23:25   ` Paul Menzel
2013-02-26 15:55 ` [PATCH] drm/mgag200: Cleanup: Remove extra variable assigns Christopher Harvey
2013-02-26 23:28   ` Paul Menzel
2013-02-26 15:55 ` [PATCH] drm/mgag200: Reject modes that are too big for VRAM Christopher Harvey
2013-02-26 23:34   ` Paul Menzel [this message]
2013-03-07  0:38   ` Dave Airlie
2013-03-06 18:51 ` [PATCH] mgag200: some cleanup and a fix for corrupted output Christopher Harvey
2013-03-06 21:02   ` Dave Airlie

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=1361921696.6140.34.camel@mattotaupa \
    --to=paulepanter@users.sourceforge.net \
    --cc=charvey@matrox.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jlemire@matrox.com \
    --cc=mathieu.larouche@matrox.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox