Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp2061253ybm; Sun, 31 May 2020 07:22:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFwszuyKVViflkKEWRyv/0vcTCDRl3cjyNRM1cXp2R1KvpOEjgVFHirDYaMEJQvRKTKBrD X-Received: by 2002:aa7:da4f:: with SMTP id w15mr9464524eds.384.1590934952407; Sun, 31 May 2020 07:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590934952; cv=none; d=google.com; s=arc-20160816; b=mN128AhY+iwjKN9LXP+o2SuP2h6gZUVhZK6AJngXoXvb7lHr+nLP8amX06DhUPFW2R sX9n5JH3R3Sl9t4JlrA9Tm32Y5FAKGDgoXgOqa1dVKsqvcwSd0EKnRVxkou+t4Dcuj5t gtIbRq27qTKN8byHCBQFKZGdXk+kM+dgrfmY8q/xkLZmp5n69ZrPKmg4tgKQG/pOfcV7 KR+cEc88v5jfWV1ex8ru8d9Vj1ZmjbNZWGzCq5L5yhY0rxwfMWIR4kFjiPEh8fcWjYzi 6Up6qU8By/rwNW+xPeO7Q34eKrX9Z2EIPUhhqryu3h9nSo97xiIXj28BBF8n2SWJ1tQ7 W5fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=eYCtR5XyB8uUfd8xXmIEoD6CXSCHEWmBCVrdsJOKI14=; b=jPw4PwKS1/94dh9oWoqf32drX7S2gUtFlaizEMvtgR8mKwTXnEFDAUJ/mucJ9YWrDE 3IlqX4Q4DMGhD50qIf4b+cVM2exoI4PjSxSnBRnsZSnETV/Da934B8t8RxRviN2mZBMr h2qK09CP2xc+tYmy+tEH1dm3+ktIuTHYgl7dlcGO4AzU1+5nsMc3RSZVfcwqsaYIqs63 Oi+fb1LxVUZeLN3Gz3ytMk6bzKXXp5+dju8TQSkADwwnOwVZizCgSMfaa54G+t+p67Kr Q8jQjeen904nOkWOB7d3A0iXtqopQ9xkqaDjZFgi/BcJ/3mnhd3PpBBe9moPVbtquFrx 4ZEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EuOaIXRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf24si6781132ejb.80.2020.05.31.07.21.55; Sun, 31 May 2020 07:22:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EuOaIXRX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbgEaNMx (ORCPT + 99 others); Sun, 31 May 2020 09:12:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbgEaNMx (ORCPT ); Sun, 31 May 2020 09:12:53 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115FEC061A0E for ; Sun, 31 May 2020 06:12:53 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id h95so2842828pje.4 for ; Sun, 31 May 2020 06:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=eYCtR5XyB8uUfd8xXmIEoD6CXSCHEWmBCVrdsJOKI14=; b=EuOaIXRX6UNAuI03P+SZF1/kwWXLjvWjU6NvoBr9uUNG4FOzQU1lO6NzHGii3nQ8JZ CHn6Pch07wPHqTbrLYFdCOci6KiUUCY8PdLf9tHnX1V2uD7wWuzYgc0EYBRNjoOrHna1 STUM+LzTB3cu76b3OZXoV4XojZpQLzAn6L+oesG9aRZaV6EviTh8uhePndoMq8Ze8V0Q UYimf9+zaMxJUNN23PkI9m6/x1BQ7oeiHl4KnTYsZKcuk4s0QUfinQoYB9micQ3rn88L ZgQ8gFH35v1ojC9Xd8pagrCxKlu4ILHPV4yr0fmDDiRyoFW5a64+jgdinWXqN6Zh+tf0 BNjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eYCtR5XyB8uUfd8xXmIEoD6CXSCHEWmBCVrdsJOKI14=; b=GVqi/Brh11lm3/JaxCYjyqqs4+OYABrrcuhnXjomgJXqUuA/4WDBlVsc/WaQHHNVuO gRQ9qSXCwueAoqkFlIAYEfh7989sCs3F687e2os32gpM/n+UBmUX1UoN8AHyU9lvtTK4 KKndMSj2JRJvgt4ZhQm0W5nI6CILX/LjhQlwkkCFYwb/bEioLsbJ9NgFnAxDmiUZqg82 5QXrLvP60ryeWW7HQwIoeFbHJ+6gpvHgy0BO5SNqj1QVd1wuqu5bvtcPHLxNAnU6mw0w o7SZ3tsp14DacRdPHgUg04ISEiOvi5K68FthofOjkTN4Le4E+uBvh1jdxsnPQ2+tfv9C +8qA== X-Gm-Message-State: AOAM532W7KLxsiTWZEiXP6IlSZNZIaeCQ82DpR28n9PtRKrB0XGTwF39 NwG5JVb8u1KzkLctxoJZZx8= X-Received: by 2002:a17:90b:28d:: with SMTP id az13mr16251573pjb.67.1590930772433; Sun, 31 May 2020 06:12:52 -0700 (PDT) Received: from localhost.localdomain ([61.83.141.141]) by smtp.gmail.com with ESMTPSA id m2sm4701573pjk.52.2020.05.31.06.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2020 06:12:51 -0700 (PDT) From: Sidong Yang To: Daniel Vetter Cc: Sidong Yang , Rodrigo Siqueira , Haneen Mohammed , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/vkms: Optimize compute_crc(), blend() Date: Sun, 31 May 2020 22:12:37 +0900 Message-Id: <20200531131237.24781-1-realwakka@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Sidong Yang --- 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