Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2998066pxa; Tue, 25 Aug 2020 08:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAz4cMnFCSWNJ/yf21hpBSydA76eua6ByfU15E4DNSUolnEpO2pg9vQxa8hNsvx47uv0BO X-Received: by 2002:a50:b701:: with SMTP id g1mr11276810ede.197.1598370339742; Tue, 25 Aug 2020 08:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598370339; cv=none; d=google.com; s=arc-20160816; b=rnXjbalV2OXJBwzs8+vRd5dj17jxGxlB570lfIbXFVt+lyWNGW1kVT5kOwZv7OJ/EB Yx6oxpKOruiRswpKLu9BKXVjHchFxKmgAOocLY2rB4UghZxg4TcCH7qREZNbhZldNubM 141N6PDG7OWkY3Cr+Za61eppu1I3w4iHd06ODkguhyKs0blVnniVKqz7hbWoeBTgWeGs zCu4yZlIWUXZLIE7Q5bLhCZ1B4mhEBemAcGmXah8eEGKAyGaa/QaXVW2gxcBU8MbazUX oezt2CkfPUECNZM9Red3tGoS4p5b4g5vTy/to9XKUd1puD2/ELzI25t7Kfg+4wc71xDj LPjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QYGt1AUketUmIhWzMlfw1o2JhMefg6zcZtSy8rTzBOg=; b=zWARW0KvfPaP/Iu3jE0H6B5dlTR1d/zBURaUdpHneUEzjKCqFFN8lJAx0ScflWd3KF gRgwTJbHph46I9gIFq4icbsci4f7x7s6MqeYq6ORgkql5dZxEa3NFFnauqMbQ3ikahX7 zsMpbmIyRlqqE0/KOFxUMfVECCv+cMDmNMWYDodOgZjvrO6EESk7A00rktbjntmXc4oc qlZ2zJSZXkaAvasq6kUk9lDpYlFj7YpsShGPgNw+KmMOWfTIRXHXuIpS08+l1TgHGgFh DaYlnTWq8HS0MEi29K3cHolKZ7rI9flNr/xc5iA1dOdDRmGNifYp0rq/88/+Moe8tqiD UO6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YRVt4fLI; 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 b4si4995596ejg.366.2020.08.25.08.45.16; Tue, 25 Aug 2020 08:45:39 -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=YRVt4fLI; 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 S1726813AbgHYPnA (ORCPT + 99 others); Tue, 25 Aug 2020 11:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbgHYPm6 (ORCPT ); Tue, 25 Aug 2020 11:42:58 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9D9C061574 for ; Tue, 25 Aug 2020 08:42:58 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id s20so2923822wmj.1 for ; Tue, 25 Aug 2020 08:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QYGt1AUketUmIhWzMlfw1o2JhMefg6zcZtSy8rTzBOg=; b=YRVt4fLIXfvscIz3QIX4MM7DnnoBzT0NcifEaa2iPJClNPPpF+CVrbBohVMxN2Pmrd XYLgSL+bEdIAOhTouHyXvfvL5CuWW688nP4fsZdeCpn8oSE4NcbKV7T9x8KD153KsPkZ v9qiUgIEvlDnjrphU7Pu9jG2hKHK//UkEmHM7ioTFSX6GDGz4bQFVvpmcLxX69Rlt1o9 ljOHuwlBeBLGX7c8YISWWDJQKC2k0uq/zUynjXg3tyTBZO8zkLtzj/MOVedQxPGChS2H ENzCvvWuUe4qCdHxV/47E+yGmM/l1kheFdGZK84sbe+GjZQb70o9CnEIbTsNA57nCYin Jzbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QYGt1AUketUmIhWzMlfw1o2JhMefg6zcZtSy8rTzBOg=; b=E3SLI+HssnLwfqf10GjjKr6/Ajs0emYapotBt5EHRRqpFDly06eXr/h960vKWgco7j mMuqAAyYtRIytv7e/okWkqkuyzmht72MEkFog299Q47z1alUugYW5c4nEiLjdvWGqH9A SUAQXjhRtUqwD3BSHuYvS8z/GYM6Sp/jhpKlUs+xG3EbOJZ/48HvIblwdt0UynjgCbvF hTdTeM6lkhc/fUig8su6lJ+cKldE8Y6DdQqL8AXYKQ4gal2BIqjapYmsJB9I/1YuZI2W dvz47mIDSOWZ4xrgxpGZN6ViL2b6NSDUMIAg2MBAm0inFjVVs1sNRTVTwTcjR/Rx8mlO CT/A== X-Gm-Message-State: AOAM5335hJK9eA4xBagt9mb6Zu6TYXpp73qGa53BQVqYayvKo62mX2Fv AZ2HyRxmfhm0eDQ4jZr1ETU= X-Received: by 2002:a7b:c095:: with SMTP id r21mr2835661wmh.152.1598370176924; Tue, 25 Aug 2020 08:42:56 -0700 (PDT) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id a85sm7203453wmd.26.2020.08.25.08.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 08:42:56 -0700 (PDT) Date: Tue, 25 Aug 2020 12:42:46 -0300 From: Melissa Wen To: Rodrigo Siqueira Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Brian Starkey , Liviu Dudau , Daniel Vetter , Simon Ser , Leandro Ribeiro , daniels@collabora.com, Emil Velikov Subject: Re: [PATCH v5 2/3] drm/vkms: Compute CRC without change input data Message-ID: <20200825153653.k22gbd72rdxu5qtk@smtp.gmail.com> References: <20200825023142.2561220-1-rodrigosiqueiramelo@gmail.com> <20200825023142.2561220-3-rodrigosiqueiramelo@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200825023142.2561220-3-rodrigosiqueiramelo@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/24, Rodrigo Siqueira wrote: > The compute_crc() function is responsible for calculating the > framebuffer CRC value; due to the XRGB format, this function has to > ignore the alpha channel during the CRC computation. Therefore, > compute_crc() set zero to the alpha channel directly in the input > framebuffer, which is not a problem since this function receives a copy > of the original buffer. However, if we want to use this function in a > context without a buffer copy, it will change the initial value. This > patch makes compute_crc() calculate the CRC value without modifying the > input framebuffer. > > Change in V4 (Emil): > - Move bitmap_clear operation and comments to get_pixel function > > Signed-off-by: Rodrigo Siqueira > --- > drivers/gpu/drm/vkms/vkms_composer.c | 38 ++++++++++++++++++---------- > 1 file changed, 24 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c > index 4d8bc04bb6ee..387b0690a64a 100644 > --- a/drivers/gpu/drm/vkms/vkms_composer.c > +++ b/drivers/gpu/drm/vkms/vkms_composer.c > @@ -9,33 +9,43 @@ > > #include "vkms_drv.h" > > +static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer, > + const struct vkms_composer *composer) > +{ > + u32 pixel; > + int src_offset = composer->offset + (y * composer->pitch) > + + (x * composer->cpp); > + > + pixel = *(u32 *)&buffer[src_offset]; > + /* XRGB format ignores Alpha channel */ > + bitmap_clear((void *)&pixel, 0, 8); I noticed a small problem in this bitmap_clear as I recently sent a patch changing it. The starting point for zeroing the alpha is not 0, but 24. As in the removed line below: - bitmap_clear(vaddr_out + src_offset, 24, 8); It affects the kms_cursor_crc/cursor-alpha-transparent subtest. > + > + return pixel; > +} > + > /** > * compute_crc - Compute CRC value on output frame > * > - * @vaddr_out: address to final framebuffer > + * @vaddr: address to final framebuffer > * @composer: framebuffer's metadata > * > * returns CRC value computed using crc32 on the visible portion of > * the final framebuffer at vaddr_out > */ > -static uint32_t compute_crc(void *vaddr_out, struct vkms_composer *composer) > +static uint32_t compute_crc(const u8 *vaddr, > + const struct vkms_composer *composer) > { > - int i, j, src_offset; > + int x, y; > + u32 crc = 0, pixel = 0; > int x_src = composer->src.x1 >> 16; > int y_src = composer->src.y1 >> 16; > int h_src = drm_rect_height(&composer->src) >> 16; > int w_src = drm_rect_width(&composer->src) >> 16; > - 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); > - /* XRGB format ignores Alpha channel */ > - bitmap_clear(vaddr_out + src_offset, 24, 8); > - crc = crc32_le(crc, vaddr_out + src_offset, > - sizeof(u32)); > + > + for (y = y_src; y < y_src + h_src; ++y) { > + for (x = x_src; x < x_src + w_src; ++x) { > + pixel = get_pixel_from_buffer(x, y, vaddr, composer); > + crc = crc32_le(crc, (void *)&pixel, sizeof(u32)); > } > } > > -- > 2.28.0 >