linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: dri-devel@lists.freedesktop.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	Dave Airlie <airlied@redhat.com>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>,
	virtualization@lists.linux-foundation.org (open list:DRM DRIVER
	FOR QXL VIRTUAL GPU),
	spice-devel@lists.freedesktop.org (open list:DRM DRIVER FOR QXL
	VIRTUAL GPU), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v3 15/23] drm/qxl: use qxl_num_crtc directly
Date: Fri, 18 Jan 2019 13:20:12 +0100	[thread overview]
Message-ID: <20190118122020.27596-16-kraxel@redhat.com> (raw)
In-Reply-To: <20190118122020.27596-1-kraxel@redhat.com>

qdev->monitors_config->max_allowed is effectively set by the
qxl.num_heads module parameter, stored in the qxl_num_crtc variable.
Lets get rid of the indirection and use the variable qxl_num_crtc
directly.  The kernel doesn't need to dereference pointers each time it
needs the value, and when reading the code you don't have to trace where
and why qdev->monitors_config->max_allowed is set.

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

diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index d9de43e5fd..ef832f98ab 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -80,10 +80,10 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)
 		DRM_DEBUG_KMS("no client monitors configured\n");
 		return status;
 	}
-	if (num_monitors > qdev->monitors_config->max_allowed) {
+	if (num_monitors > qxl_num_crtc) {
 		DRM_DEBUG_KMS("client monitors list will be truncated: %d < %d\n",
-			      qdev->monitors_config->max_allowed, num_monitors);
-		num_monitors = qdev->monitors_config->max_allowed;
+			      qxl_num_crtc, num_monitors);
+		num_monitors = qxl_num_crtc;
 	} else {
 		num_monitors = qdev->rom->client_monitors_config.count;
 	}
@@ -96,8 +96,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)
 		return status;
 	}
 	/* we copy max from the client but it isn't used */
-	qdev->client_monitors_config->max_allowed =
-				qdev->monitors_config->max_allowed;
+	qdev->client_monitors_config->max_allowed = qxl_num_crtc;
 	for (i = 0 ; i < qdev->client_monitors_config->count ; ++i) {
 		struct qxl_urect *c_rect =
 			&qdev->rom->client_monitors_config.heads[i];
@@ -204,7 +203,7 @@ static int qxl_add_monitors_config_modes(struct drm_connector *connector,
 
 	if (!qdev->monitors_config)
 		return 0;
-	if (h >= qdev->monitors_config->max_allowed)
+	if (h >= qxl_num_crtc)
 		return 0;
 	if (!qdev->client_monitors_config)
 		return 0;
@@ -307,8 +306,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 		return;
 	}
 
-	if (!qdev->monitors_config ||
-	    qdev->monitors_config->max_allowed <= i)
+	if (!qdev->monitors_config || qxl_num_crtc <= i)
 		return;
 
 	head.id = i;
@@ -350,9 +348,10 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc,
 	if (oldcount != qdev->monitors_config->count)
 		DRM_DEBUG_KMS("active heads %d -> %d (%d total)\n",
 			      oldcount, qdev->monitors_config->count,
-			      qdev->monitors_config->max_allowed);
+			      qxl_num_crtc);
 
 	qdev->monitors_config->heads[i] = head;
+	qdev->monitors_config->max_allowed = qxl_num_crtc;
 	qxl_send_monitors_config(qdev);
 }
 
@@ -1146,9 +1145,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev)
 {
 	int ret;
 	struct drm_gem_object *gobj;
-	int max_allowed = qxl_num_crtc;
 	int monitors_config_size = sizeof(struct qxl_monitors_config) +
-		max_allowed * sizeof(struct qxl_head);
+		qxl_num_crtc * sizeof(struct qxl_head);
 
 	ret = qxl_gem_object_create(qdev, monitors_config_size, 0,
 				    QXL_GEM_DOMAIN_VRAM,
@@ -1170,9 +1168,8 @@ int qxl_create_monitors_object(struct qxl_device *qdev)
 		qxl_bo_physical_address(qdev, qdev->monitors_config_bo, 0);
 
 	memset(qdev->monitors_config, 0, monitors_config_size);
-	qdev->monitors_config->max_allowed = max_allowed;
-
-	qdev->dumb_heads = kcalloc(max_allowed, sizeof(qdev->dumb_heads[0]), GFP_KERNEL);
+	qdev->dumb_heads = kcalloc(qxl_num_crtc, sizeof(qdev->dumb_heads[0]),
+				   GFP_KERNEL);
 	return 0;
 }
 
-- 
2.9.3


  parent reply	other threads:[~2019-01-18 12:22 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190118122020.27596-1-kraxel@redhat.com>
2019-01-18 12:19 ` [PATCH v3 01/23] drm/qxl: drop ttm_mem_reg arg from qxl_hw_surface_alloc() Gerd Hoffmann
2019-01-25 15:44   ` Noralf Trønnes
2019-01-18 12:19 ` [PATCH v3 02/23] drm/qxl: drop unused qxl_fb_virtual_address Gerd Hoffmann
2019-01-25 15:44   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 03/23] drm/qxl: simplify slot management Gerd Hoffmann
2019-01-25 15:52   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 04/23] drm/qxl: change the way slot is detected Gerd Hoffmann
2019-01-25 15:52   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 05/23] drm/qxl: drop unused fields from struct qxl_device Gerd Hoffmann
2019-01-25 15:53   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 06/23] drm/qxl: use separate offset spaces for the two slots / ttm memory types Gerd Hoffmann
2019-01-25 15:57   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 07/23] drm/qxl: allow both PRIV and VRAM placement for QXL_GEM_DOMAIN_SURFACE Gerd Hoffmann
2019-01-25 15:58   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 08/23] drm/qxl: use QXL_GEM_DOMAIN_SURFACE for shadow bo Gerd Hoffmann
2019-01-25 15:58   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 09/23] drm/qxl: use QXL_GEM_DOMAIN_SURFACE for dumb gem objects Gerd Hoffmann
2019-01-25 15:59   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 10/23] drm/qxl: move qxl_primary_apply_cursor to correct place Gerd Hoffmann
2019-01-25 16:09   ` Noralf Trønnes
2019-01-28  8:10     ` Gerd Hoffmann
2019-01-28 10:38       ` Noralf Trønnes
2019-01-28 11:40         ` Gerd Hoffmann
2019-01-18 12:20 ` [PATCH v3 11/23] drm/qxl: drop unused offset parameter from qxl_io_create_primary() Gerd Hoffmann
2019-01-25 16:10   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 12/23] drm/qxl: track primary bo Gerd Hoffmann
2019-01-25 16:11   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 13/23] drm/qxl: use shadow bo directly Gerd Hoffmann
2019-01-25 16:59   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 14/23] drm/qxl: cover all crtcs in shadow bo Gerd Hoffmann
2019-01-25 17:08   ` Noralf Trønnes
2019-01-18 12:20 ` Gerd Hoffmann [this message]
2019-01-25 17:12   ` [PATCH v3 15/23] drm/qxl: use qxl_num_crtc directly Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 16/23] drm/qxl: implement prime kmap/kunmap Gerd Hoffmann
2019-01-25 17:19   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 17/23] drm/qxl: use generic fbdev emulation Gerd Hoffmann
2019-01-25 17:25   ` Noralf Trønnes
2019-01-28  8:59     ` Gerd Hoffmann
2019-01-28 10:39       ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 18/23] drm/qxl: remove dead qxl fbdev emulation code Gerd Hoffmann
2019-01-25 17:25   ` Noralf Trønnes
2019-01-25 18:10     ` Sam Ravnborg
2019-01-25 18:44       ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 19/23] drm/qxl: implement qxl_gem_prime_(un)pin Gerd Hoffmann
2019-01-25 17:26   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 20/23] drm/qxl: add mode/framebuffer check functions Gerd Hoffmann
2019-01-25 17:30   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 21/23] drm/qxl: add qxl_add_mode helper function Gerd Hoffmann
2019-01-25 17:34   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 22/23] drm/qxl: use kernel mode db Gerd Hoffmann
2019-01-25 17:35   ` Noralf Trønnes
2019-01-18 12:20 ` [PATCH v3 23/23] drm/qxl: add overflow checks to qxl_mode_dumb_create() Gerd Hoffmann
2019-01-18 15:49   ` Daniel Vetter
2019-01-18 16:32     ` Ville Syrjälä
2019-01-18 17:15       ` Daniel Vetter

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=20190118122020.27596-16-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --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;
as well as URLs for NNTP newsgroup(s).