From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Menzel Subject: Re: [PATCH] drm/mgag200: Reject modes that are too big for VRAM Date: Wed, 27 Feb 2013 00:34:56 +0100 Message-ID: <1361921696.6140.34.camel@mattotaupa> References: <20130226155544.GA18661@harvey-pc.matrox.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0121041012==" Return-path: Received: from mail.gw90.de (mail.gw90.de [188.40.100.199]) by gabe.freedesktop.org (Postfix) with ESMTP id A1489E5D2B for ; Tue, 26 Feb 2013 15:34:59 -0800 (PST) In-Reply-To: <20130226155544.GA18661@harvey-pc.matrox.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Christopher Harvey Cc: Julia Lemire , Mathieu Larouche , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0121041012== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-dYifsDeycy3orDQqFv1q" --=-dYifsDeycy3orDQqFv1q Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3D parameter. >=20 > Signed-off-by: Christopher Harvey > --- > drivers/gpu/drm/mgag200/mgag200_mode.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) >=20 > diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mga= g200/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 =3D connector->dev; > + struct mga_device *mdev =3D (struct mga_device*)dev->dev_private; > + struct mga_fbdev *mfbdev =3D mdev->mfbdev; > + struct drm_fb_helper *fb_helper =3D &mfbdev->helper; > + struct drm_fb_helper_connector *fb_helper_conn =3D NULL; > + int bpp =3D 32; > + int i =3D 0; It is initialized in the for loop again. > + > /* FIXME: Add bandwidth and g200se limitations */ > =20 > 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; > } > =20 > + /* Validate the mode input by the user */ > + for (i =3D 0; i < fb_helper->connector_count; i++) { > + if (fb_helper->connector_info[i]->connector =3D=3D connector) { > + /* Found the helper for this connector */ > + fb_helper_conn =3D fb_helper->connector_info[i]; > + if (fb_helper_conn->cmdline_mode.specified) { > + if (fb_helper_conn->cmdline_mode.bpp_specified) { > + bpp =3D 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 =3D 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; > } > =20 Thanks, Paul --=-dYifsDeycy3orDQqFv1q Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEABECAAYFAlEtRqAACgkQPX1aK2wOHViJZQCfctl8gXsPf6uzPI90TjdbO0aj PDoAn1qwu/KYFkslPMo5FtUJ2SHmFizY =iemV -----END PGP SIGNATURE----- --=-dYifsDeycy3orDQqFv1q-- --===============0121041012== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============0121041012==--