From: Frediano Ziglio <fziglio@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: David Airlie <airlied@linux.ie>,
open list <linux-kernel@vger.kernel.org>,
dri-devel@lists.freedesktop.org,
"open list:DRM DRIVER FOR QXL VIRTUAL GPU"
<virtualization@lists.linux-foundation.org>,
Daniel Vetter <daniel@ffwll.ch>, Dave Airlie <airlied@redhat.com>,
"open list:DRM DRIVER FOR QXL VIRTUAL GPU"
<spice-devel@lists.freedesktop.org>
Subject: Re: [PATCH 1/3] drm/qxl: add mode/framebuffer check functions
Date: Wed, 16 Jan 2019 04:24:51 -0500 (EST) [thread overview]
Message-ID: <636470684.58090538.1547630691403.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20190116083521.22673-2-kraxel@redhat.com>
>
> Add a helper functions to check video modes. Also add a helper to check
> framebuffer buffer objects, using the former for consistency. That way
> we should not fail in qxl_primary_atomic_check() because video modes
> which are too big will not be added to the mode list in the first place.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> drivers/gpu/drm/qxl/qxl_display.c | 37 +++++++++++++++++++------------------
> 1 file changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_display.c
> b/drivers/gpu/drm/qxl/qxl_display.c
> index 1f8fddcc34..07a37d52c4 100644
> --- a/drivers/gpu/drm/qxl/qxl_display.c
> +++ b/drivers/gpu/drm/qxl/qxl_display.c
> @@ -191,6 +191,21 @@ void qxl_display_read_client_monitors_config(struct
> qxl_device *qdev)
> }
> }
>
> +static int qxl_check_mode(struct qxl_device *qdev,
> + unsigned int width,
> + unsigned int height)
> +{
> + if (width * height * 4 > qdev->vram_size)
Is someone checking for integer overflows already?
> + return -ENOMEM;
> + return 0;
> +}
> +
> +static int qxl_check_framebuffer(struct qxl_device *qdev,
> + struct qxl_bo *bo)
> +{
> + return qxl_check_mode(qdev, bo->surf.width, bo->surf.height);
> +}
> +
> static int qxl_add_monitors_config_modes(struct drm_connector *connector,
> unsigned *pwidth,
> unsigned *pheight)
> @@ -466,12 +481,7 @@ static int qxl_primary_atomic_check(struct drm_plane
> *plane,
>
> bo = gem_to_qxl_bo(state->fb->obj[0]);
>
> - if (bo->surf.stride * bo->surf.height > qdev->vram_size) {
> - DRM_ERROR("Mode doesn't fit in vram size (vgamem)");
> - return -EINVAL;
> - }
> -
> - return 0;
> + return qxl_check_framebuffer(qdev, bo);
> }
>
> static int qxl_primary_apply_cursor(struct drm_plane *plane)
> @@ -941,20 +951,11 @@ static enum drm_mode_status qxl_conn_mode_valid(struct
> drm_connector *connector,
> {
> struct drm_device *ddev = connector->dev;
> struct qxl_device *qdev = ddev->dev_private;
> - int i;
>
> - /* TODO: is this called for user defined modes? (xrandr --add-mode)
> - * TODO: check that the mode fits in the framebuffer */
> + if (qxl_check_mode(qdev, mode->hdisplay, mode->vdisplay) != 0)
> + return MODE_BAD;
>
> - if (qdev->monitors_config_width == mode->hdisplay &&
> - qdev->monitors_config_height == mode->vdisplay)
> - return MODE_OK;
> -
> - for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
> - if (common_modes[i].w == mode->hdisplay && common_modes[i].h ==
> mode->vdisplay)
> - return MODE_OK;
> - }
> - return MODE_BAD;
> + return MODE_OK;
> }
>
> static struct drm_encoder *qxl_best_encoder(struct drm_connector *connector)
Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel
next prev parent reply other threads:[~2019-01-16 9:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 8:35 [PATCH 0/3] drm/qxl: video mode tweaks Gerd Hoffmann
2019-01-16 8:35 ` [PATCH 1/3] drm/qxl: add mode/framebuffer check functions Gerd Hoffmann
2019-01-16 9:24 ` Frediano Ziglio [this message]
2019-01-16 11:28 ` [Spice-devel] " Gerd Hoffmann
2019-01-16 13:21 ` Daniel Vetter
2019-01-16 8:35 ` [PATCH 2/3] drm/qxl: add qxl_add_mode helper function Gerd Hoffmann
2019-01-16 8:35 ` [PATCH 3/3] drm/qxl: use kernel mode db Gerd Hoffmann
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=636470684.58090538.1547630691403.JavaMail.zimbra@redhat.com \
--to=fziglio@redhat.com \
--cc=airlied@linux.ie \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=spice-devel@lists.freedesktop.org \
--cc=virtualization@lists.linux-foundation.org \
/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