public inbox for linux-kernel@vger.kernel.org
 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 13/23] drm/qxl: use shadow bo directly
Date: Fri, 18 Jan 2019 13:20:10 +0100	[thread overview]
Message-ID: <20190118122020.27596-14-kraxel@redhat.com> (raw)
In-Reply-To: <20190118122020.27596-1-kraxel@redhat.com>

Pass the shadow bo to qxl_io_create_primary() instead of expecting
qxl_io_create_primary to check bo->shadow.  Set is_primary flag on the
shadow bo.  Move the is_primary tracking into qxl_io_create_primary()
and qxl_io_destroy_primary() functions.

That simplifies primary surface tracking and the workflow in
qxl_primary_atomic_update().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

qxl_io_create/destroy_primary: primary_bo tracking [fixup]
---
 drivers/gpu/drm/qxl/qxl_cmd.c     | 10 +++++-----
 drivers/gpu/drm/qxl/qxl_display.c | 33 +++++++++++----------------------
 2 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index 8e64127259..0a2e51af12 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -374,6 +374,8 @@ void qxl_io_flush_surfaces(struct qxl_device *qdev)
 void qxl_io_destroy_primary(struct qxl_device *qdev)
 {
 	wait_for_io_cmd(qdev, 0, QXL_IO_DESTROY_PRIMARY_ASYNC);
+	qdev->primary_bo->is_primary = false;
+	drm_gem_object_put_unlocked(&qdev->primary_bo->gem_base);
 	qdev->primary_bo = NULL;
 }
 
@@ -390,11 +392,7 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo)
 	create->width = bo->surf.width;
 	create->height = bo->surf.height;
 	create->stride = bo->surf.stride;
-	if (bo->shadow) {
-		create->mem = qxl_bo_physical_address(qdev, bo->shadow, 0);
-	} else {
-		create->mem = qxl_bo_physical_address(qdev, bo, 0);
-	}
+	create->mem = qxl_bo_physical_address(qdev, bo, 0);
 
 	DRM_DEBUG_DRIVER("mem = %llx, from %p\n", create->mem, bo->kptr);
 
@@ -403,6 +401,8 @@ void qxl_io_create_primary(struct qxl_device *qdev, struct qxl_bo *bo)
 
 	wait_for_io_cmd(qdev, 0, QXL_IO_CREATE_PRIMARY_ASYNC);
 	qdev->primary_bo = bo;
+	qdev->primary_bo->is_primary = true;
+	drm_gem_object_get(&qdev->primary_bo->gem_base);
 }
 
 void qxl_io_memslot_add(struct qxl_device *qdev, uint8_t id)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index d3215eac9b..ff13bc6a4a 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -401,13 +401,15 @@ static int qxl_framebuffer_surface_dirty(struct drm_framebuffer *fb,
 	struct qxl_device *qdev = fb->dev->dev_private;
 	struct drm_clip_rect norect;
 	struct qxl_bo *qobj;
+	bool is_primary;
 	int inc = 1;
 
 	drm_modeset_lock_all(fb->dev);
 
 	qobj = gem_to_qxl_bo(fb->obj[0]);
 	/* if we aren't primary surface ignore this */
-	if (!qobj->is_primary) {
+	is_primary = qobj->shadow ? qobj->shadow->is_primary : qobj->is_primary;
+	if (!is_primary) {
 		drm_modeset_unlock_all(fb->dev);
 		return 0;
 	}
@@ -526,14 +528,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
 {
 	struct qxl_device *qdev = plane->dev->dev_private;
 	struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
-	struct qxl_bo *bo_old;
+	struct qxl_bo *bo_old, *primary;
 	struct drm_clip_rect norect = {
 	    .x1 = 0,
 	    .y1 = 0,
 	    .x2 = plane->state->fb->width,
 	    .y2 = plane->state->fb->height
 	};
-	bool same_shadow = false;
 
 	if (old_state->fb) {
 		bo_old = gem_to_qxl_bo(old_state->fb->obj[0]);
@@ -541,26 +542,13 @@ static void qxl_primary_atomic_update(struct drm_plane *plane,
 		bo_old = NULL;
 	}
 
-	if (bo == bo_old)
-		return;
+	primary = bo->shadow ? bo->shadow : bo;
 
-	if (bo_old && bo_old->shadow && bo->shadow &&
-	    bo_old->shadow == bo->shadow) {
-		same_shadow = true;
-	}
-
-	if (bo_old && bo_old->is_primary) {
-		if (!same_shadow)
+	if (!primary->is_primary) {
+		if (qdev->primary_bo)
 			qxl_io_destroy_primary(qdev);
-		bo_old->is_primary = false;
-	}
-
-	if (!bo->is_primary) {
-		if (!same_shadow) {
-			qxl_io_create_primary(qdev, bo);
-			qxl_primary_apply_cursor(plane);
-		}
-		bo->is_primary = true;
+		qxl_io_create_primary(qdev, primary);
+		qxl_primary_apply_cursor(plane);
 	}
 
 	qxl_draw_dirty_fb(qdev, plane->state->fb, bo, 0, 0, &norect, 1, 1);
@@ -756,6 +744,7 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane,
 			qxl_bo_create(qdev, user_bo->gem_base.size,
 				      true, true, QXL_GEM_DOMAIN_SURFACE, NULL,
 				      &user_bo->shadow);
+			user_bo->shadow->surf = user_bo->surf;
 		}
 	}
 
@@ -784,7 +773,7 @@ static void qxl_plane_cleanup_fb(struct drm_plane *plane,
 	user_bo = gem_to_qxl_bo(obj);
 	qxl_bo_unpin(user_bo);
 
-	if (user_bo->shadow && !user_bo->is_primary) {
+	if (user_bo->shadow && !user_bo->shadow->is_primary) {
 		drm_gem_object_put_unlocked(&user_bo->shadow->gem_base);
 		user_bo->shadow = NULL;
 	}
-- 
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 ` Gerd Hoffmann [this message]
2019-01-25 16:59   ` [PATCH v3 13/23] drm/qxl: use shadow bo directly 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 ` [PATCH v3 15/23] drm/qxl: use qxl_num_crtc directly Gerd Hoffmann
2019-01-25 17:12   ` 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-14-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