Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp221317ybi; Tue, 16 Jul 2019 19:31:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdLQZMC8UqYorY/sDHPGQ8RsaCTAqDn5H09W8K+G+YDbm5rJDbg2iEmPNU5sIxbz/mgN+p X-Received: by 2002:a17:90a:1ae2:: with SMTP id p89mr38538101pjp.26.1563330678376; Tue, 16 Jul 2019 19:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563330678; cv=none; d=google.com; s=arc-20160816; b=PpsgHb0kxq+PgwhNJyIIlpwpXif84/UwZFmUeAcLL7adKppejE+QsuI17fybmHLVpy P7St/vVkf/sESjjBPgaSltQ4wDQUErhaYFamhWMsqfb6ps5dYX78SOFbq1HfgYJ51yOL x7EFee/DnOQbatFwTzEVlgG07ZaSbOhhwmL2acJqm9BT37FLUvVD5F/NHgNAmL4XA7HD qI92TRsH30LhdJQpof/dj2t/5eDa0XAonDC5PyHWzjydwT/iPbZ4STesixBn+ZHlE3rh 9VE1zKvmUMf4foRPs5Iki1AFT/Rtp9tUn/+aD3VMxFXzHggz7dvL5aHKWOqDft6rxBWn MjoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature; bh=YA8lAAAs8QKJaZT6FgrXTDQyRFELqwwXAnvE6DYcrwo=; b=naMvQQM8iBRJWyeCFAEes0ultlYoWBr2Eq+HUIt40sC6supvyfAc1e3GTNZU1VnUye x+juHJ278d8IWeJse33gwW50mSLJZWrmJ6MkyMqG0gQTflT7jr4vkeRz4b70DYY2XM4X 8SavNan42ZIfBzbsgI39/bxXbrixTbuOjG5ILb6y6dl/cX4HXOcodop9LvtcDpsW+R42 Qbj5eUcTGRe6m6YYKRRrNZ8ZAXZYPFQHjTgQDqts/XQGewwUAsSruZre0pPIKOHyCXNE KRSrw1nRi+YbAZmUKT+Hkno8waSf1Low0twNE1aZtHY1xh7uQG7rxOlFzTSzvNhEcdg8 YTag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jUqM3qYM; 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 u15si21238347pgn.178.2019.07.16.19.31.00; Tue, 16 Jul 2019 19:31:18 -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=jUqM3qYM; 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 S1727743AbfGQCac (ORCPT + 99 others); Tue, 16 Jul 2019 22:30:32 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:35344 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbfGQCab (ORCPT ); Tue, 16 Jul 2019 22:30:31 -0400 Received: by mail-qt1-f194.google.com with SMTP id d23so21822458qto.2 for ; Tue, 16 Jul 2019 19:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YA8lAAAs8QKJaZT6FgrXTDQyRFELqwwXAnvE6DYcrwo=; b=jUqM3qYMZZMW9/ukdmhyypFlzErDXK17HLvVFp30vzHZdthvv+iO0s9lyIV/rGVPqr JBM0uE5gctX59YzlfaoaOCLumfIyAEOUemNySjDWg1k0Q+ciyd/Uar+SuWXLLZWACU23 agMYZ59E7FL/gYr7PynzaiVjKQfGs8OO9PmVOOFsNXMCPspk9518riVDU+icSptb+gAt jmhw/TrMfvKtydIt85yWi5vp3jJKjq61iXH56JcSSYGbNPF4KK6/RxoiihadMJ0TYPY1 M0dYmJrF3c3ZXkW8nyrczl/w10EIh8Bh2djARwzspOpQVzTJoBQuxvTUyRkXAg7uOiLj gYxg== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YA8lAAAs8QKJaZT6FgrXTDQyRFELqwwXAnvE6DYcrwo=; b=uk/EvfRBGKYNO20lidP1lXht+3+Eiby7xYmU/BiZ1IrK7wIhz2Ws7Wc/Eax0dOFm6P VyRPvf/vOPBsviP5UEAr53gxfBrFdIxflmiRgsSDqnwxuWCeHwhd3CgulUdNzgvpG3MR wcxxQQSxXA3As2ma/e0WRrrjOKLHdt0KXpKPG9ZH1jrP+vgTmIrsFXl5OTFnwaZ07LrQ OxJhIeZn8QhbjX5c18o77JSIi3sg710biAVr1l1+u9zgJTncvw16wXB6yMOIGK+mX+ql SctdRBmOBgGBQcmem2GfcVwr+ZzSGvwmY++2x0sSguwMj98nQkQhm2cXS0MoqM3bxTJ7 5k/A== X-Gm-Message-State: APjAAAVsdFckFPwwlCFv5UHYHkajbnKNV7Gkz7Oi/+e53vLPfw8up6YJ sFLA3t9O+bY1u2+3knCkwA8= X-Received: by 2002:a0c:8a76:: with SMTP id 51mr26976107qvu.210.1563330630560; Tue, 16 Jul 2019 19:30:30 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.22]) by smtp.gmail.com with ESMTPSA id b202sm10257728qkg.83.2019.07.16.19.30.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 19:30:29 -0700 (PDT) Date: Tue, 16 Jul 2019 23:30:24 -0300 From: Rodrigo Siqueira To: Brian Starkey , Liviu Dudau , Haneen Mohammed , Simon Ser , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 4/5] drm/vkms: Compute CRC without change input data Message-ID: <20190717023024.svpgfbzgund2awfw@smtp.gmail.com> References: <20190711082105.GI15868@phenom.ffwll.local> <20190712031449.3pmeimkcde2hrxxh@smtp.gmail.com> <20190716083715.GT15868@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="qp4bmywubblpnone" Content-Disposition: inline In-Reply-To: <20190716083715.GT15868@phenom.ffwll.local> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --qp4bmywubblpnone Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 07/16, Daniel Vetter wrote: > On Fri, Jul 12, 2019 at 12:14:49AM -0300, Rodrigo Siqueira wrote: > > On 07/11, Daniel Vetter wrote: > > > On Tue, Jun 25, 2019 at 10:38:31PM -0300, 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. Th= is > > > > patch makes compute_crc() calculate the CRC value without modifying= the > > > > input framebuffer. > > >=20 > > > Uh why? For writeback we're writing the output too, so we can write > > > whatever we want to into the alpha channel. For writeback we should n= ever > > > accept a pixel format where alpha actually matters, that doesn't make > > > sense. You can't see through a real screen either, they are all opaqu= e :-) > > > -Daniel > >=20 > > Hmmm, > >=20 > > I see your point and I agree, but even though we can write whatever we > > want in the output, don=E2=80=99t you think that is weird to change the > > framebuffer value in the compute_crc() function? >=20 > Not sure what you mean here ... ? From a quick look the memset only sets > our temporary buffer, so we're not changing the input framebuffer here. > And we have to somehow get rid of the X bits, since there's no alpha > value. For CRC computation, all we need is some value which is the same > for every frame (so that the CRC stays constant for the same visible > output). For writeback we could write whatever we want (which includes > whatever is there already). But there's no guarantee and definitely no > expectation that the X bits survive. Writing 0 is imo the most reasonable > thing to do. I'm not even sure whether modern gpus can still do channel > masking (i.e. only write out specific channels, instead of the entire > color). That was a "feature" of bitop blitters of the 80s/90s :-) > -Daniel Ahhh, now I can see that my mindset was in the 90s :) Thanks =20 > >=20 > > Thanks > > =20 > > > >=20 > > > > Signed-off-by: Rodrigo Siqueira > > > > --- > > > > drivers/gpu/drm/vkms/vkms_composer.c | 31 +++++++++++++++++-------= ---- > > > > 1 file changed, 19 insertions(+), 12 deletions(-) > > > >=20 > > > > diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm= /vkms/vkms_composer.c > > > > index 51a270514219..8126aa0f968f 100644 > > > > --- a/drivers/gpu/drm/vkms/vkms_composer.c > > > > +++ b/drivers/gpu/drm/vkms/vkms_composer.c > > > > @@ -6,33 +6,40 @@ > > > > #include > > > > #include > > > > =20 > > > > +static u32 get_pixel_from_buffer(int x, int y, const u8 *buffer, > > > > + const struct vkms_composer *composer) > > > > +{ > > > > + int src_offset =3D composer->offset + (y * composer->pitch) > > > > + + (x * composer->cpp); > > > > + > > > > + return *(u32 *)&buffer[src_offset]; > > > > +} > > > > + > > > > /** > > > > * 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; > > > > int x_src =3D composer->src.x1 >> 16; > > > > int y_src =3D composer->src.y1 >> 16; > > > > int h_src =3D drm_rect_height(&composer->src) >> 16; > > > > int w_src =3D drm_rect_width(&composer->src) >> 16; > > > > - u32 crc =3D 0; > > > > + u32 crc =3D 0, pixel =3D 0; > > > > =20 > > > > - for (i =3D y_src; i < y_src + h_src; ++i) { > > > > - for (j =3D x_src; j < x_src + w_src; ++j) { > > > > - src_offset =3D composer->offset > > > > - + (i * composer->pitch) > > > > - + (j * composer->cpp); > > > > + for (y =3D y_src; y < y_src + h_src; ++y) { > > > > + for (x =3D x_src; x < x_src + w_src; ++x) { > > > > /* XRGB format ignores Alpha channel */ > > > > - memset(vaddr_out + src_offset + 24, 0, 8); > > > > - crc =3D crc32_le(crc, vaddr_out + src_offset, > > > > - sizeof(u32)); > > > > + pixel =3D get_pixel_from_buffer(x, y, vaddr, composer); > > > > + bitmap_clear((void *)&pixel, 0, 8); > > > > + crc =3D crc32_le(crc, (void *)&pixel, sizeof(u32)); > > > > } > > > > } > > > > =20 > > > > --=20 > > > > 2.21.0 > > >=20 > > > --=20 > > > Daniel Vetter > > > Software Engineer, Intel Corporation > > > http://blog.ffwll.ch > >=20 > > --=20 > > Rodrigo Siqueira > > https://siqueira.tech >=20 >=20 >=20 > > _______________________________________________ > > dri-devel mailing list > > dri-devel@lists.freedesktop.org > > https://lists.freedesktop.org/mailman/listinfo/dri-devel >=20 >=20 > --=20 > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch --=20 Rodrigo Siqueira https://siqueira.tech --qp4bmywubblpnone Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE4tZ+ii1mjMCMQbfkWJzP/comvP8FAl0uiEAACgkQWJzP/com vP8X0xAAxp4KZSRHIF9p/L79o4+j8/J2PBMeibgeeQsw2NFfff6rbip2bM4sfccv mjdtxPGJHMUWr/vdeRvokp9kg9QWE/ZOxmX+u07c+/x+qxPhB1/p3uogpNpRvsZ+ SF2xG8riCOmTuKetflJUh7chAm/RDPM/TaajZfUGIIwY9gQm1/C0WyumBp85izpU Nk1dk6Dj/xplD8d+19P7uKgUDc+d3P4ogRbUQKW5NqvgrXyXxa4Zzv1W40BKwsIS jx5xQAqrcQUCkOdPRJyzVMLKBe0kagIEhXMHfSlyn+Nlp47AXYUjMlUV4TuY5980 HsWPGAs98tNpCM+jj1bWxym5F0LnKxyxMqHg62gGQLOWQBVdhWLmYtdCf7bI8A0I 95stQVF6CqWxNzcYJ6ffw6ZFNXKVba6uzrPIAWVwYTvX/JmULM9JzZVMG33vbeYH Yd8grYgJLvRU8k5pc1g5LjXC0+9im1Jr10mmywgUhipErbMxXOfhMuIe2/2lsx5v zkMk/UTlVZQrXxJOw4NUXeb0wDXelrTR3/5cSDT0uMWjSU84AFQLvd5767YxqD+h odiOohM4xAEkB7478GVvwsyjUMf9Tn1QGeWX/m2lsZgv2qYmT5zgVkG1H7jzSEO7 mRzB0k/z3o9M40wzDebVg5TRcyNOdn3+8xKFumWmvmNXuGYMOAU= =ajCg -----END PGP SIGNATURE----- --qp4bmywubblpnone--