From patchwork Wed Mar 8 09:19:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9610695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A05BD60414 for ; Wed, 8 Mar 2017 09:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F88728567 for ; Wed, 8 Mar 2017 09:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61B5228576; Wed, 8 Mar 2017 09:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2136D28567 for ; Wed, 8 Mar 2017 09:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ZtQovLmhGxbXJdEJadHXsg4wcjAE5h29pCrt1tzFKgA=; b=i3p3FaERVXdn97Ks5fzLq4SURK uYZCm/GoZSG+2jVyulSkBlOpEneGQnkppKyAjUoo5tv6SRfL/XYHbcYU1EYJADJGVyq8tOYE7L8DD yPTbbdUBRlxeuOhyAeThZufAJCQCRP9E/Z8xpnXF5PPRtFyjkdBVnGfbEkByB8d+iKYZeeUMxnNrf h6VUG/vrCcDVnd2hslPUzQOtICc6B3TVMt82q7AQiA1R0hVIRc0JmJCu8SU8RRMGOJaN5CO9LHFOT 04bbkLZBo2YEQyhMUhgFooqUahCBHyzn3FOfWwlXXAGKRs0ZdC1XcPROjX5pBpsbhM+OmZh0Dr/Cu SKb8mVVg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clXr1-0002wH-CZ; Wed, 08 Mar 2017 09:25:55 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clXmI-0006Qu-Ru; Wed, 08 Mar 2017 09:21:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LvbkRyY3m2O0D3qmrou/N/M6E3uLSSouR9//XEE2JTg=; b=D5zz7jbY5wLltmITkBHlT7EWp n7pKg5ToxALHsAiuBzFteOiF7cjndKGJejLos473MQvo0M0cUY4fS0PCfx6sxTX7JEwylTosTDtJ5 LLQYyJOWDqM4lJNbeWPkDcq62u7lNddweenfaAyTz8ULOoQF75viJD4iqugGw6vGEzr9+XeBj4Yiv 11UsYb8ptb0QGz9xvG+qYlV+7PTbWTz5l5h3waFoNiXbm1SiGaORaDBVK+oCpefkoBYDw8zFHTy8V /FAWQD5Y4qCSeNTjzSlfeTi37p52kfrYxguy23iYJuphMZKeGzawPKntH0hJq2J/fX8taqUFoAuJG szhO3aiDA==; Received: from mx1.redhat.com ([209.132.183.28]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clXmD-0003IB-HB; Wed, 08 Mar 2017 09:21:01 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A7733D942; Wed, 8 Mar 2017 09:19:59 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v289JwDI013716; Wed, 8 Mar 2017 04:19:58 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 56CF980B58; Wed, 8 Mar 2017 10:19:55 +0100 (CET) From: Gerd Hoffmann To: linux-rpi-kernel@lists.infradead.org Subject: [PATCH 4/4] qxl: fix qxl_conn_get_modes Date: Wed, 8 Mar 2017 10:19:08 +0100 Message-Id: <1488964751-22763-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1488964751-22763-1-git-send-email-kraxel@redhat.com> References: <1488964751-22763-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 08 Mar 2017 09:20:00 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170308_092057_923705_E86EE63F X-CRM114-Status: GOOD ( 17.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, ulf.hansson@linaro.org, David Airlie , catalin.marinas@arm.com, will.deacon@arm.com, "open list:DRM DRIVERS" , "open list:DRM DRIVER FOR QXL VIRTUAL GPU" , eric@anholt.net, Gerd Hoffmann , stefan.wahren@i2se.com, f.fainelli@gmail.com, lee@kernel.org, linux@armlinux.org.uk, bcm-kernel-feedback-list@broadcom.com, Dave Airlie , 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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }