Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2131881ybb; Sat, 21 Mar 2020 13:38:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvxZcBwrZh/2FPWhcGyKdCdY7WvUDdp26vlEwTf7iel0o3ZJN1Nh6WE5VGg71WvSGYkVPGw X-Received: by 2002:aca:4986:: with SMTP id w128mr11360452oia.46.1584823125571; Sat, 21 Mar 2020 13:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584823125; cv=none; d=google.com; s=arc-20160816; b=zVrUjy91/4lh9/Qd6bbYPWl55W1RjOt3lDVrUq0wV+T0MMDW0CyXgGGCBFS5gHfsS5 RjfviQoYJIQODNP1Hv4jZYhIvifLO7MRWnt6gotY7TGGLhrReOTN+QkNgPHz6D6Nj1q+ Zy8RbluNsQo8hfMLUQtMZhm9b4wI1HI9296cQgewTiSJ9fwj6ZF2d2ff5uvHNlRYXO6f AX652YWq37i9YKRkDFBIT2sXFVJI3G1rjpI2PPNbh4EsmRj5jrkPSNpx7SN8LxcIzwme u2e2GBFf6O4EyZIbnBuoVayZdlz5hkUZlqjynkdoo3NEaeKmnM215iA3mZp6Xuh6PE2N aOww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=ZZ8vMEMrPzAmCCEBSbU8aR5UX0QpU9PFQ1YG0DRV08Y=; b=CK4yl/xWCemDJh6qG6/2MgZZZu8jmRmamIQAHauQmWgYi5R+u9epclz0bqdsAlBPOS HzyghupMbb+cYIHa8uQeR3CVKnmxoMxxC5awl24tSwjfdRbAJ6HJXoS2Yn9xNyeAaYFW eMN7WXVguXtjbDmRWk+bwruEZX/H5aSrzBq8CWSHImMbgHnZx9XI8DnEBsEeoqlegjJ8 9tUOi7v8s35Y9HXd2NFtLkmkl7EFZdaTVcdoix6zlRrsgUYqB0r1En1qpg2RwhtJ3kSS ud//IgUcuEu36/jUbOicGwQPKylrldmrCMi/81y9M5uNJvNpvcmONSQgY78P6MxoPuRj hlOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IttaYxyj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id c5si5394535otm.104.2020.03.21.13.38.33; Sat, 21 Mar 2020 13:38:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IttaYxyj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727286AbgCUUgv (ORCPT + 99 others); Sat, 21 Mar 2020 16:36:51 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:44304 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbgCUUgu (ORCPT ); Sat, 21 Mar 2020 16:36:50 -0400 Received: by mail-ed1-f65.google.com with SMTP id z3so11519143edq.11 for ; Sat, 21 Mar 2020 13:36:48 -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:mime-version:content-disposition; bh=ZZ8vMEMrPzAmCCEBSbU8aR5UX0QpU9PFQ1YG0DRV08Y=; b=IttaYxyjD1JYhBBOqIdM+9UpYtHnFoKk0/PzLFAQvrnz1/GlrqsgArmSJ9zmLkoNHl le8t7zck7thQKq+I30w2OlvuVkPshfI8avRRtZOSw+ddn4jWuCIBkl1s97bXBa+CQBVE ly/Lxh+N/wFaFtPYpv3Ag/QXfRMVrR/tUqXYH9vy3u7cKliybR6MHGPrzH7RnPdrI0CI HKhYdDYg4YhiWY3YRZlq5ldLK7+f7dnwl3EQNV41eGg/w5HScKZ6iq1AKIop2XAtb9Cw IVud8nbkuDvbjvZfn669sQMyxPkbQZZavuiYtBnxcB57F3G+SxyBJ0xM9rmTEE6DSW+m UINA== 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:mime-version :content-disposition; bh=ZZ8vMEMrPzAmCCEBSbU8aR5UX0QpU9PFQ1YG0DRV08Y=; b=PMlqOe3x64d1jwyDEX18LUawIAfpNeaUy263eRYo6RJaJJxl92SCmrgWeFXBumPWVJ e7UO8buvLX/VFusKu98IRXzY3xWvPCotVeshsEyBmYBiAFyUHBNhyLsJZFrwfL91oQqN kYgOrloL8rWvPg+50Krw+0yAFbMXTepGMcMpdEVNfPMWXpySMaC5I2d8v1dMPvJ5bNtR R297EeSCtq9/rhJEBO/dwwqFgwiVoiZmpIhd9pOtBpIG9xIIuqj+YxkakjKRdyRHVG0D NJ5qt3ZRG71qIAtlFyrBg5oHpRTyBTd40A92GOaOS6AWwuqQ9XYUGHMoEYVwxwOhqzho IfSA== X-Gm-Message-State: ANhLgQ0UO6kRA1DOsYTscgDW3m1iWn/1v4E16U5VgW3kRxlXA9NRlm+d ML8P7a88D++SSYidZNExqG4= X-Received: by 2002:a17:906:34db:: with SMTP id h27mr13452108ejb.111.1584823008214; Sat, 21 Mar 2020 13:36:48 -0700 (PDT) Received: from smtp.gmail.com ([2001:818:e238:a000:51c6:2c09:a768:9c37]) by smtp.gmail.com with ESMTPSA id ca12sm683498edb.47.2020.03.21.13.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2020 13:36:47 -0700 (PDT) Date: Sat, 21 Mar 2020 17:36:40 -0300 From: Melissa Wen To: Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , David Airlie , Rodrigo.Siqueira@amd.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/vkms: use bitfield op to get xrgb on compute crc Message-ID: <20200321203640.dwyk25jvnn2rffpw@smtp.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The previous memset operation was not correctly setting zero on the alpha channel to compute the crc, and as a result, the pipe-A-cursor-alpha-transparent subtest of the IGT test kms_cursor_crc was crashing. To avoid errors of misinterpretation related to endianness, this solution uses a bitfield operation to extract the RGB values from each pixel and ignores the alpha channel as expected. Signed-off-by: Melissa Wen --- drivers/gpu/drm/vkms/vkms_composer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 4af2f19480f4..8c1c005bb717 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include +#include #include #include @@ -9,6 +10,8 @@ #include "vkms_drv.h" +#define XRGB_MSK GENMASK(23, 0) + /** * compute_crc - Compute CRC value on output frame * @@ -26,6 +29,7 @@ static uint32_t compute_crc(void *vaddr_out, struct vkms_composer *composer) int h_src = drm_rect_height(&composer->src) >> 16; int w_src = drm_rect_width(&composer->src) >> 16; u32 crc = 0; + u32 *pixel; for (i = y_src; i < y_src + h_src; ++i) { for (j = x_src; j < x_src + w_src; ++j) { @@ -33,7 +37,8 @@ static uint32_t compute_crc(void *vaddr_out, struct vkms_composer *composer) + (i * composer->pitch) + (j * composer->cpp); /* XRGB format ignores Alpha channel */ - memset(vaddr_out + src_offset + 24, 0, 8); + pixel = vaddr_out + src_offset; + *pixel = FIELD_GET(XRGB_MSK, *(u32 *)pixel); crc = crc32_le(crc, vaddr_out + src_offset, sizeof(u32)); } -- 2.25.1