lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 31 May 2020 22:12:37 +0900
From:   Sidong Yang <realwakka@...il.com>
To:     Daniel Vetter <daniel@...ll.ch>
Cc:     Sidong Yang <realwakka@...il.com>,
        Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>,
        Haneen Mohammed <hamohammed.sa@...il.com>,
        David Airlie <airlied@...ux.ie>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/vkms: Optimize compute_crc(), blend()

Optimize looping pixels in compute_crc() and blend(). Calculate
src_offset in start of looping horizontally and increase it.
It's better than calculating in every pixels.

Cc: Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>
Cc: David Airlie <airlied@...ux.ie>
Cc: dri-devel@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Sidong Yang <realwakka@...il.com>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 32 +++++++++++++++-------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 4af2f19480f4..9d2a765ca1fb 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -28,14 +28,14 @@ static uint32_t compute_crc(void *vaddr_out, struct vkms_composer *composer)
 	u32 crc = 0;
 
 	for (i = y_src; i < y_src + h_src; ++i) {
-		for (j = x_src; j < x_src + w_src; ++j) {
-			src_offset = composer->offset
-				     + (i * composer->pitch)
-				     + (j * composer->cpp);
+		src_offset = composer->offset + (i * composer->pitch)
+				+ (x_src * composer->cpp);
+		for (j = 0 ; j < w_src; ++j) {
 			/* XRGB format ignores Alpha channel */
 			memset(vaddr_out + src_offset + 24, 0,  8);
 			crc = crc32_le(crc, vaddr_out + src_offset,
 				       sizeof(u32));
+			src_offset += composer->cpp;
 		}
 	}
 
@@ -61,7 +61,7 @@ static void blend(void *vaddr_dst, void *vaddr_src,
 		  struct vkms_composer *dest_composer,
 		  struct vkms_composer *src_composer)
 {
-	int i, j, j_dst, i_dst;
+	int i, j, i_dst;
 	int offset_src, offset_dst;
 
 	int x_src = src_composer->src.x1 >> 16;
@@ -73,21 +73,23 @@ static void blend(void *vaddr_dst, void *vaddr_src,
 	int w_dst = drm_rect_width(&src_composer->dst);
 
 	int y_limit = y_src + h_dst;
-	int x_limit = x_src + w_dst;
 
-	for (i = y_src, i_dst = y_dst; i < y_limit; ++i) {
-		for (j = x_src, j_dst = x_dst; j < x_limit; ++j) {
-			offset_dst = dest_composer->offset
-				     + (i_dst * dest_composer->pitch)
-				     + (j_dst++ * dest_composer->cpp);
-			offset_src = src_composer->offset
-				     + (i * src_composer->pitch)
-				     + (j * src_composer->cpp);
+	for (i = y_src, i_dst = y_dst; i < y_limit; ++i, ++i_dst) {
+		offset_dst = dest_composer->offset
+		     + (i_dst * dest_composer->pitch)
+		     + (x_dst * dest_composer->cpp);
 
+		offset_src = src_composer->offset
+		     + (i * src_composer->pitch)
+		     + (x_src * src_composer->cpp);
+
+		for (j = 0; j < w_dst; ++j) {
 			memcpy(vaddr_dst + offset_dst,
 			       vaddr_src + offset_src, sizeof(u32));
+
+			offset_dst += dest_composer->cpp;
+			offset_src += src_composer->cpp;
 		}
-		i_dst++;
 	}
 }
 
-- 
2.17.1

Powered by blists - more mailing lists