diff mbox series

drm/vmwgfx: Don't memcmp equivalent pointers

Message ID 20240328190716.27367-1-ian.forbes@broadcom.com (mailing list archive)
State New, archived
Headers show
Series drm/vmwgfx: Don't memcmp equivalent pointers | expand

Commit Message

Ian Forbes March 28, 2024, 7:07 p.m. UTC
These pointers are frequently the same and memcmp does not compare the pointers
before comparing their contents so this was wasting cycles comparing 16 KiB of
memory which will always be equal.

Fixes: bb6780aa5a1d9 ("drm/vmwgfx: Diff cursors when using cmds")
Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Zack Rusin March 29, 2024, 1:22 a.m. UTC | #1
On Thu, Mar 28, 2024 at 3:31 PM Ian Forbes <ian.forbes@broadcom.com> wrote:
>
> These pointers are frequently the same and memcmp does not compare the pointers
> before comparing their contents so this was wasting cycles comparing 16 KiB of
> memory which will always be equal.
>
> Fixes: bb6780aa5a1d9 ("drm/vmwgfx: Diff cursors when using cmds")
> Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index cd4925346ed4..fbcce84e2f4c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -216,7 +216,7 @@ static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps,
>         new_image = vmw_du_cursor_plane_acquire_image(new_vps);
>
>         changed = false;
> -       if (old_image && new_image)
> +       if (old_image && new_image && (old_image != new_image))
>                 changed = memcmp(old_image, new_image, size) != 0;
>
>         return changed;
> --
> 2.34.1
>

The patch looks good but please use "dim checkpatch" and fix the
issues it found. For the "Fixes:" line you also want to use "dim
fixes".

z
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index cd4925346ed4..fbcce84e2f4c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -216,7 +216,7 @@  static bool vmw_du_cursor_plane_has_changed(struct vmw_plane_state *old_vps,
 	new_image = vmw_du_cursor_plane_acquire_image(new_vps);
 
 	changed = false;
-	if (old_image && new_image)
+	if (old_image && new_image && (old_image != new_image))
 		changed = memcmp(old_image, new_image, size) != 0;
 
 	return changed;