Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3798770ybb; Mon, 23 Mar 2020 07:56:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vswnhoTpG8FZ9PULEtUpAoQCOYGe5djXzqZfPyCk4xRiAgvYuULwqVJddGaYSekP0pP/NWB X-Received: by 2002:a9d:5e8b:: with SMTP id f11mr18720949otl.110.1584975386196; Mon, 23 Mar 2020 07:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584975386; cv=none; d=google.com; s=arc-20160816; b=IHH3T3HKfqT96BXPQr25hkJpB/KLa7fNnOEFbg8PUMNesHuxNB8x5jiQEmwm+uwRk3 fS18Jpqs/9uUBss6Qzz2DP/vaULaV9csx3GpKxda1spDrex3p71LfKW93ANkacNRZnSU HuGHGcKoVn9BeAyBtZ3QaNsaOoKqNfiQBUSMGjjWAOFt6UL5i39+LVw04+nXeoFzlgaD VVcfUUN1/OJhNBy4wKq/MyCzetyjo8ydyvdGz3naFS7XVslptGUpW09q+67zdlTkwkHR k/uAJqGsJci4XaYrZ5KxytSGdycY25MzKslZvIt/I767weL40PsNWkIIwPEwrC8YZ9kh WnKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=cvFJdAGmkEJgI7CKLrkWe1kpWqXCbROWHlx7qz+XYHk=; b=l45L9Zrh+aYdrD8gr0jRcl/7ZQM0V9trCqmcDsH9teyKrQo+4SPeOyo4jAUqMvKCy7 EWM1HKRiRILyKkeC7Pr//EqikvmOP2ZF7P5gr6J5cryi2GuYR0/O3ijbv3Xw6wAg6Bpa kfAqNLSZfXIdd34t7AXUF1bhPYfACRPK4zSyP+JF3NVLUzyzbcXUoAJ2Oheyk6MIB8xk jMfr7LD6jntecTvaLw6MY/VP2hZOlgT2PL6YbAewWmF4tEE9EWyikzxh5T5vArR/14Xl aSxUfq+QRNf7Fy1t60JGWxAuV8RbrcijlzKqTdnYCtyTDYg7ZQIv3IWXQe+IZ62hTxZG wexg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si8157333otp.318.2020.03.23.07.56.12; Mon, 23 Mar 2020 07:56:26 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbgCWOyp convert rfc822-to-8bit (ORCPT + 99 others); Mon, 23 Mar 2020 10:54:45 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:57480 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725710AbgCWOyp (ORCPT ); Mon, 23 Mar 2020 10:54:45 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-2-iYJu0SDqM9iMX_bcm93M5w-1; Mon, 23 Mar 2020 14:54:41 +0000 X-MC-Unique: iYJu0SDqM9iMX_bcm93M5w-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 23 Mar 2020 14:54:40 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 23 Mar 2020 14:54:40 +0000 From: David Laight To: 'Melissa Wen' , Rodrigo Siqueira , Haneen Mohammed , Daniel Vetter , David Airlie , "Rodrigo.Siqueira@amd.com" CC: "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] drm/vkms: use bitfield op to get xrgb on compute crc Thread-Topic: [PATCH] drm/vkms: use bitfield op to get xrgb on compute crc Thread-Index: AQHV/8B1smDC5j2GuEKWS+RWmHzqeKhWQ8Aw Date: Mon, 23 Mar 2020 14:54:40 +0000 Message-ID: References: <20200321203640.dwyk25jvnn2rffpw@smtp.gmail.com> In-Reply-To: <20200321203640.dwyk25jvnn2rffpw@smtp.gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Melissa Wen > Sent: 21 March 2020 20:37 > 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)); That looks horrid. I suspect the simplest fix is to change the memset() offset/length to bytes from bits. Or (assuming the alpha channel is last) just: *(u8 *)(vaddr_out + src_offset + 3) = 0; I'm not sure of the options for the crc code, but if you are only passing in 4 bytes there ought to be an option to pass in the value itself (rather than the address). Do you actually want to 'zap' the alpha channel data from the output buffer? or just exclude it from the crc?? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)