From: Zack Rusin <zack@kde.org>
To: dri-devel@lists.freedesktop.org
Cc: krastevm@vmware.com, banackm@vmware.com, mombasawalam@vmware.com
Subject: [PATCH v2 09/16] drm/vmwgfx: Diff cursors when using cmds
Date: Wed, 19 Oct 2022 23:41:24 -0400 [thread overview]
Message-ID: <20221020034131.491973-10-zack@kde.org> (raw)
In-Reply-To: <20221020034131.491973-1-zack@kde.org>
From: Michael Banack <banackm@vmware.com>
Extend the cursor diffing support to support the command-path.
Signed-off-by: Michael Banack <banackm@vmware.com>
Signed-off-by: Zack Rusin <zackr@vmware.com>
---
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 120 ++++++++++++++--------------
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 +
2 files changed, 62 insertions(+), 60 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 6c41c5b5a913..ff79668ad334 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -53,8 +53,10 @@ void vmw_du_cleanup(struct vmw_display_unit *du)
*/
static int vmw_du_cursor_plane_unmap_cm(struct vmw_plane_state *vps);
-static void vmw_cursor_write_mobid(struct vmw_private *dev_priv,
- struct vmw_plane_state *vps);
+static void vmw_cursor_update_mob(struct vmw_private *dev_priv,
+ struct vmw_plane_state *vps,
+ u32 *image, u32 width, u32 height,
+ u32 hotspotX, u32 hotspotY);
struct vmw_svga_fifo_cmd_define_cursor {
u32 cmd;
@@ -118,7 +120,10 @@ static void vmw_cursor_update_image(struct vmw_private *dev_priv,
u32 hotspotX, u32 hotspotY)
{
if (vps->cursor.bo)
- vmw_cursor_write_mobid(dev_priv, vps);
+ vmw_cursor_update_mob(dev_priv, vps, image,
+ vps->base.crtc_w, vps->base.crtc_h,
+ hotspotX, hotspotY);
+
else
vmw_send_define_cursor_cmd(dev_priv, image, width, height,
hotspotX, hotspotY);
@@ -163,61 +168,58 @@ static void vmw_cursor_update_mob(struct vmw_private *dev_priv,
alpha_header->height = height;
memcpy(header + 1, image, image_size);
-}
-
-
-/**
- * vmw_cursor_write_mobid - Update cursor via CursorMob mechanism
- *
- * Called from inside vmw_du_cursor_plane_atomic_update to actually
- * make the cursor-image live.
- *
- * @dev_priv: device to work with
- * @vps: DRM plane_state
- */
-static void vmw_cursor_write_mobid(struct vmw_private *dev_priv,
- struct vmw_plane_state *vps)
-{
vmw_write(dev_priv, SVGA_REG_CURSOR_MOBID,
vps->cursor.bo->resource->start);
}
+
static u32 vmw_du_cursor_mob_size(u32 w, u32 h)
{
return w * h * sizeof(u32) + sizeof(SVGAGBCursorHeader);
}
-
-static bool vmw_du_cursor_plane_mob_has_changed(struct vmw_plane_state *old_vps,
- struct vmw_plane_state *new_vps)
+/**
+ * vmw_du_cursor_plane_acquire_image -- Acquire the image data
+ * @vps: cursor plane state
+ */
+static u32 *vmw_du_cursor_plane_acquire_image(struct vmw_plane_state *vps)
{
- void *old_mob;
- void *new_mob;
bool dummy;
- u32 size;
-
- // If either of them aren't using CursorMobs, assume changed.
- if (!old_vps->cursor.bo || !new_vps->cursor.bo)
- return true;
+ if (vps->surf) {
+ if (vps->surf_mapped)
+ return vmw_bo_map_and_cache(vps->surf->res.backup);
+ return vps->surf->snooper.image;
+ } else if (vps->bo)
+ return ttm_kmap_obj_virtual(&vps->bo->map, &dummy);
+ return NULL;
+}
- // If either of them failed to map, assume changed.
- if (!old_vps->cursor.mapped || !new_vps->cursor.mapped)
- return true;
+static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps,
+ struct vmw_plane_state *new_vps)
+{
+ void *old_image;
+ void *new_image;
+ u32 size;
+ bool changed;
if (old_vps->base.crtc_w != new_vps->base.crtc_w ||
old_vps->base.crtc_h != new_vps->base.crtc_h)
return true;
- size = vmw_du_cursor_mob_size(new_vps->base.crtc_w,
- new_vps->base.crtc_h);
+ if (old_vps->cursor.hotspot_x != new_vps->cursor.hotspot_x ||
+ old_vps->cursor.hotspot_y != new_vps->cursor.hotspot_y)
+ return true;
- old_mob = ttm_kmap_obj_virtual(&old_vps->cursor.map, &dummy);
- new_mob = ttm_kmap_obj_virtual(&new_vps->cursor.map, &dummy);
+ size = new_vps->base.crtc_w * new_vps->base.crtc_h * sizeof(u32);
- if (memcmp(old_mob, new_mob, size) != 0)
- return true;
+ old_image = vmw_du_cursor_plane_acquire_image(old_vps);
+ new_image = vmw_du_cursor_plane_acquire_image(new_vps);
- return false;
+ changed = false;
+ if (old_image && new_image)
+ changed = memcmp(old_image, new_image, size) != 0;
+
+ return changed;
}
static void vmw_du_destroy_cursor_mob(struct ttm_buffer_object **bo)
@@ -745,6 +747,7 @@ vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,
return -ENOMEM;
} else if (vps->surf && !vps->bo && vps->surf->res.backup) {
+ WARN_ON(vps->surf->snooper.image);
ret = ttm_bo_reserve(&vps->surf->res.backup->base, true, false,
NULL);
if (unlikely(ret != 0))
@@ -778,7 +781,6 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
struct vmw_plane_state *old_vps = vmw_plane_state_to_vps(old_state);
s32 hotspot_x, hotspot_y;
bool dummy;
- void *image;
hotspot_x = du->hotspot_x;
hotspot_y = du->hotspot_y;
@@ -796,36 +798,34 @@ vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
return;
}
+ vps->cursor.hotspot_x = hotspot_x;
+ vps->cursor.hotspot_y = hotspot_y;
+
if (vps->surf) {
du->cursor_age = du->cursor_surface->snooper.age;
- image = vps->surf->snooper.image;
- if (vps->surf_mapped)
- image = vmw_bo_map_and_cache(vps->surf->res.backup);
- } else
- image = ttm_kmap_obj_virtual(&vps->bo->map, &dummy);
-
- if (vps->cursor.bo)
- vmw_cursor_update_mob(dev_priv, vps, image,
- new_state->crtc_w,
- new_state->crtc_h,
- hotspot_x, hotspot_y);
+ }
- if (!vmw_du_cursor_plane_mob_has_changed(old_vps, vps)) {
+ if (!vmw_du_cursor_plane_has_changed(old_vps, vps)) {
/*
* If it hasn't changed, avoid making the device do extra
- * work by keeping the old mob active.
+ * work by keeping the old cursor active.
*/
struct vmw_cursor_plane_state tmp = old_vps->cursor;
old_vps->cursor = vps->cursor;
vps->cursor = tmp;
- } else if (image)
- vmw_cursor_update_image(dev_priv, vps, image,
- new_state->crtc_w,
- new_state->crtc_h,
- hotspot_x, hotspot_y);
-
- if (image && vps->bo)
- atomic_dec(&vps->bo->base_mapped_count);
+ } else {
+ void *image = vmw_du_cursor_plane_acquire_image(vps);
+ if (image)
+ vmw_cursor_update_image(dev_priv, vps, image,
+ new_state->crtc_w,
+ new_state->crtc_h,
+ hotspot_x, hotspot_y);
+ }
+
+ if (vps->bo) {
+ if (ttm_kmap_obj_virtual(&vps->bo->map, &dummy))
+ atomic_dec(&vps->bo->base_mapped_count);
+ }
du->cursor_x = new_state->crtc_x + du->set_gui_x;
du->cursor_y = new_state->crtc_y + du->set_gui_y;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index c5e4665a956c..13a265ffd9f8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -276,6 +276,8 @@ struct vmw_cursor_plane_state {
struct ttm_buffer_object *bo;
struct ttm_bo_kmap_obj map;
bool mapped;
+ s32 hotspot_x;
+ s32 hotspot_y;
};
/**
--
2.34.1
next prev parent reply other threads:[~2022-10-20 3:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 3:41 [PATCH v2 00/16] drm/vmwgfx: fb, cursors and hashtable refactor Zack Rusin
2022-10-20 3:41 ` [PATCH v2 01/16] drm/vmwgfx: Write the driver id registers Zack Rusin
2022-10-20 3:41 ` [PATCH v2 02/16] drm/vmwgfx: Fix frame-size warning in vmw_mksstat_add_ioctl Zack Rusin
2022-10-20 3:41 ` [PATCH v2 03/16] drm/vmwgfx: Refactor resource manager's hashtable to use linux/hashtable implementation Zack Rusin
2022-10-20 3:41 ` [PATCH v2 04/16] drm/vmwgfx: Remove ttm object hashtable Zack Rusin
2022-10-20 3:41 ` [PATCH v2 05/16] drm/vmwgfx: Refactor resource validation hashtable to use linux/hashtable implementation Zack Rusin
2022-10-20 3:41 ` [PATCH v2 06/16] drm/vmwgfx: Clean up cursor mobs Zack Rusin
2022-10-20 3:41 ` [PATCH v2 07/16] drm/vmwgfx: Start diffing new mob cursors against old ones Zack Rusin
2022-10-20 3:41 ` [PATCH v2 08/16] drm/vmwgfx: Support cursor surfaces with mob cursor Zack Rusin
2022-10-20 3:41 ` Zack Rusin [this message]
2022-10-20 3:41 ` [PATCH v2 10/16] drm/vmwgfx: Refactor ttm reference object hashtable to use linux/hashtable Zack Rusin
2022-10-20 3:41 ` [PATCH v2 11/16] drm/vmwgfx: Remove vmwgfx_hashtab Zack Rusin
2022-10-20 3:41 ` [PATCH v2 12/16] drm/vmwgfx: Do not allow invalid bpp's for dumb buffers Zack Rusin
2022-10-20 3:41 ` [PATCH v2 13/16] drm/vmwgfx: Port the framebuffer code to drm fb helpers Zack Rusin
2022-10-20 9:06 ` Thomas Zimmermann
2022-10-20 18:37 ` Zack Rusin
2022-10-21 7:06 ` Thomas Zimmermann
2022-10-20 3:41 ` [PATCH v2 14/16] drm/vmwgfx: Remove explicit and broken vblank handling Zack Rusin
2022-10-20 3:41 ` [PATCH v2 15/16] drm/vmwgfx: Add a mksstat counter for cotable resizes Zack Rusin
2022-10-20 3:41 ` [PATCH v2 16/16] drm/vmwgfx: Optimize initial sizes of cotables Zack Rusin
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=20221020034131.491973-10-zack@kde.org \
--to=zack@kde.org \
--cc=banackm@vmware.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=krastevm@vmware.com \
--cc=mombasawalam@vmware.com \
--cc=zackr@vmware.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