devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: linux-rpi-kernel@lists.infradead.org
Cc: mark.rutland@arm.com, ulf.hansson@linaro.org,
	catalin.marinas@arm.com, will.deacon@arm.com,
	"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
	"open list:DRM DRIVER FOR QXL VIRTUAL GPU"
	<virtualization@lists.linux-foundation.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	stefan.wahren@i2se.com, f.fainelli@gmail.com, lee@kernel.org,
	linux@armlinux.org.uk, bcm-kernel-feedback-list@broadcom.com,
	Dave Airlie <airlied@redhat.com>,
	devicetree@vger.kernel.org, rjui@broadcom.com,
	robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org,
	sbranden@broadcom.com, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] qxl: fix qxl_conn_get_modes
Date: Wed,  8 Mar 2017 10:19:08 +0100	[thread overview]
Message-ID: <1488964751-22763-9-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1488964751-22763-1-git-send-email-kraxel@redhat.com>

Call qxl_add_monitors_config_modes() unconditionally.  Do all sanity
checks in that function.

Fix sanity checks.  monitors_config is the current monitor
configuration, whereas client_monitors_config is the configuration
requested by the spice client.  So when filling the mode list, based on
the spice client request, we need to look at
client_monitors_config->count not monitors_config->count.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_display.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index cf99ace..9548bb5 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -202,9 +202,17 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,
 	struct drm_display_mode *mode = NULL;
 	struct qxl_head *head;
 
+	if (!qdev->monitors_config)
+		return 0;
+	if (h >= qdev->monitors_config->max_allowed)
+		return 0;
 	if (!qdev->client_monitors_config)
 		return 0;
+	if (h >= qdev->client_monitors_config->count)
+		return 0;
+
 	head = &qdev->client_monitors_config->heads[h];
+	DRM_DEBUG_KMS("head %d is %dx%d\n", h, head->width, head->height);
 
 	mode = drm_cvt_mode(dev, head->width, head->height, 60, false, false,
 			    false);
@@ -911,19 +919,13 @@ static void qxl_enc_mode_set(struct drm_encoder *encoder,
 
 static int qxl_conn_get_modes(struct drm_connector *connector)
 {
-	int ret = 0;
-	struct qxl_device *qdev = connector->dev->dev_private;
 	unsigned pwidth = 1024;
 	unsigned pheight = 768;
+	int ret = 0;
 
-	DRM_DEBUG_KMS("monitors_config=%p\n", qdev->monitors_config);
-	/* TODO: what should we do here? only show the configured modes for the
-	 * device, or allow the full list, or both? */
-	if (qdev->monitors_config && qdev->monitors_config->count) {
-		ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
-		if (ret < 0)
-			return ret;
-	}
+	ret = qxl_add_monitors_config_modes(connector, &pwidth, &pheight);
+	if (ret < 0)
+		return ret;
 	ret += qxl_add_common_modes(connector, pwidth, pheight);
 	return ret;
 }
-- 
1.8.3.1

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

  parent reply	other threads:[~2017-03-08  9:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08  9:19 [PATCH v4 0/7] mmc: bcm2835: Add new driver for the sdhost controller Gerd Hoffmann
2017-03-08  9:19 ` [PATCH v4 1/7] dt-bindings: Add binding for brcm,bcm2835-sdhost Gerd Hoffmann
2017-03-08  9:19 ` [PATCH 1/4] qxl: drop mode_info.modes & related code Gerd Hoffmann
2017-03-08  9:19 ` [PATCH v4 2/7] mmc: bcm2835: Add new driver for the sdhost controller Gerd Hoffmann
2017-03-08  9:19 ` [PATCH 2/4] qxl: limit monitor config read retries Gerd Hoffmann
2017-03-08  9:19 ` [PATCH v4 3/7] mmc: bcm2835: add sdhost controller to devicetree Gerd Hoffmann
2017-03-08 12:11   ` Stefan Wahren
2017-03-08  9:19 ` [PATCH 3/4] qxl: read monitors config at boot Gerd Hoffmann
2017-03-08  9:19 ` [PATCH v4 4/7] arm: set CONFIG_MMC_BCM2835=y in bcm2835_defconfig and multi_v7_defconfig Gerd Hoffmann
2017-03-08  9:19 ` Gerd Hoffmann [this message]
2017-03-08  9:19 ` [PATCH v4 5/7] arm64: set CONFIG_MMC_BCM2835=y in defconfig Gerd Hoffmann
2017-03-18  0:07   ` Eric Anholt
2017-03-08  9:19 ` [PATCH v4 6/7] arm: dts: bcm283x: switch from &sdhci to &sdhost Gerd Hoffmann
2017-03-08  9:19 ` [PATCH v4 7/7] arm64: dts: bcm2837: add &sdhci and &sdhost Gerd Hoffmann
2017-03-08  9:34 ` [PATCH v4 0/7] mmc: bcm2835: Add new driver for the sdhost controller Gerd Hoffmann
2017-03-16 18:32 ` Eric Anholt
     [not found]   ` <87r31xysw9.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2017-03-17  7:55     ` Ulf Hansson
2017-03-17  7:51 ` Ulf Hansson

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=1488964751-22763-9-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=airlied@redhat.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=f.fainelli@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=stefan.wahren@i2se.com \
    --cc=ulf.hansson@linaro.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).