Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5828263ybg; Tue, 22 Oct 2019 08:58:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxO4733iD7Q4jAjSlvvARE4/jUf9p76q6TUUJWl/dZ+bmJD3JYos6m2YBk9jgF1LKqohNQA X-Received: by 2002:a50:ab10:: with SMTP id s16mr31610296edc.118.1571759888019; Tue, 22 Oct 2019 08:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571759888; cv=none; d=google.com; s=arc-20160816; b=i8LRclav+cs0N8ONqFBPz2pnD/77PMGQdOv/e/DOcLq3plyTAOQ+pdwNipiAPB8PJc dHuL67KmCmLD1n/PrP5xFHqP+BWYdubm8iS7nk0j1DGN8kwBB7bXwkEa3eTDPCPTZ5l3 kwvdDmNB/ElnaXziyaMY/8O4P8YF2PvEm1vfcurLpW0LNkM81D4jec6IWl1stNfKulSP 3kW9mPXqKtrp7xKXnR0ED1zbEimwIRZG+fbP5wDlt+y2r7RHY6MO/GZggcKUUF9seqbq wPOMfFBo10/URhMhITOIqAkDAOvgKm7SjS3rJmS3x2ZOiKOmdDGhnUJ8Be5TEXiwwbqW Vibw== 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:cc :to:from:date; bh=cEpU8JSpBeNFrXvqDFzj6GgPPFWS7JihZQbsOKK21NU=; b=k6aTloXjdC/CnSy34VlQ93UTsRfvPUMg5f+qvfc8fMOVunkz0/9E+mkvYoItxjxlO7 LozWmd4opuk3LB9C+WyKnmp0Tt/c5nsKWKhkdU0BaigaQ3Yh4RPApEcEuBEAmxbJ1P2J JuJvIBTabAHgk54E0HrIeW+W47Mk3dZm4LaNCsNHslCEwS/foEkNudRKhhvtMDmuSMeF 73UeMF4G6Sj24dCyTbQp4fb8prVJt8LfqCMbbYlk4f8NwsjJz39MkcYvOJZLUC6KVUCB NJNp9JfN1jISBsNtO5TTfHoA25I8f9NnhwB7y+2righKfZ53e7w/5jZZMkpzgAba/PMo 5/3w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si11249814ejf.28.2019.10.22.08.57.42; Tue, 22 Oct 2019 08:58:08 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732092AbfJVOBf (ORCPT + 99 others); Tue, 22 Oct 2019 10:01:35 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:34455 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388057AbfJVOBe (ORCPT ); Tue, 22 Oct 2019 10:01:34 -0400 X-Originating-IP: 86.250.200.211 Received: from aptenodytes (lfbn-1-17395-211.w86-250.abo.wanadoo.fr [86.250.200.211]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 9477FE000A; Tue, 22 Oct 2019 14:01:29 +0000 (UTC) Date: Tue, 22 Oct 2019 16:01:29 +0200 From: Paul Kocialkowski To: Hans Verkuil Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Chen-Yu Tsai , Maxime Ripard , Ezequiel Garcia , Tomasz Figa , Nicolas Dufresne , Jernej Skrabec , Jonas Karlman , Thomas Petazzoni Subject: Re: [PATCH v8 3/3] media: cedrus: Add HEVC/H.265 decoding support Message-ID: <20191022140129.GA1926725@aptenodytes> References: <20190927143411.141526-1-paul.kocialkowski@bootlin.com> <20190927143411.141526-4-paul.kocialkowski@bootlin.com> <20191017095751.5a229051@coco.lan> <20191022124012.GD2651@aptenodytes> <20191022131751.GE2651@aptenodytes> <62ddccd3-38c0-89c5-7f0c-35f24494c3f9@xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IS0zKkzwUGydFO0o" Content-Disposition: inline In-Reply-To: <62ddccd3-38c0-89c5-7f0c-35f24494c3f9@xs4all.nl> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue 22 Oct 19, 15:37, Hans Verkuil wrote: > On 10/22/19 3:17 PM, Paul Kocialkowski wrote: > > Hi again, > >=20 > > On Tue 22 Oct 19, 14:40, Paul Kocialkowski wrote: > >> Hi Mauro and thanks for the review, > >> > >> On Thu 17 Oct 19, 09:57, Mauro Carvalho Chehab wrote: > >>> Em Fri, 27 Sep 2019 16:34:11 +0200 > >>> Paul Kocialkowski escreveu: > >>> > >>>> This introduces support for HEVC/H.265 to the Cedrus VPU driver, with > >>>> both uni-directional and bi-directional prediction modes supported. > >>>> > >>>> Field-coded (interlaced) pictures, custom quantization matrices and > >>>> 10-bit output are not supported at this point. > >>>> > >>>> Signed-off-by: Paul Kocialkowski > >>>> --- > >>> > >>> ... > >>> > >>>> + unsigned int ctb_size_luma =3D > >>>> + 1 << log2_max_luma_coding_block_size; > >>> > >>> Shifts like this is a little scary. "1" constant is signed. So, if > >>> log2_max_luma_coding_block_size is 31, the above logic has undefined > >>> behavior. Different archs and C compilers may handle it on different > >>> ways. > >> > >> I wasn't aware that it was the case, thanks for bringing this to light! > >> I'll make it 1UL then. > >> > >>>> +#define VE_DEC_H265_LOW_ADDR_PRIMARY_CHROMA(a) \ > >>>> + (((a) << 24) & GENMASK(31, 24)) > >>> > >>> Same applies here and on other similar macros. You need to enforce > >>> (a) to be unsigned, as otherwise the behavior is undefined. > >>> > >>> Btw, this is a recurrent pattern on this file. I would define a > >>> macro, e. g. something like: > >>> > >>> #define MASK_BITS_AND_SHIFT(v, high, low) \ > >>> ((UL(v) << low) & GENMASK(high, low)) > >>> > >>> And use it for all similar patterns here. > >> > >> Sounds good! I find that the reverse wording (SHIFT_AND_MASK_BITS) wou= ld be > >> a bit more explicit since the shift happens prior to the mask. > >=20 > > Apparently the UL(v) macro just appends UL to v in preprocessor, so it = won't > > work with anything else than direct integers. > >=20 > > I'll replace it with a (unsigned long) cast, that seems to do the job. >=20 > Shouldn't that be a (u32) cast? Since this is used with 32 bit registers? This would work for cedrus, but I think that what Mauro had in mind was to migrate this macro to linux/bits.h, where everthing else (including GENMASK) is apparently defined in terms of unsigned long and not types with explicit numbers of bits. So I find it more consistent to go with unsigned long. In our case, 64-bit platforms that use cedrus would calculate the macro on 64 bits and use it in 32-bit variables. Since we're never masking beyond the lower 32 bits, I don't see how things could go wrong and the situation looks fairly similar to the use of GENMASK in similar conditions. Does that sound right to you or am I missing something here? Cheers, Paul > Regards, >=20 > Hans >=20 > >=20 > > Cheers, > >=20 > > Paul > >=20 > >> Also we probably need to have parenthesis around "low", right? > >> > >>> The best would be to include such macro at linux/bits.h, although some > >>> upstream discussion is required. > >>> > >>> So, for now, let's add it at this header file, but work upstream > >>> to have it merged there. > >> > >> Understood, I'll include it in that header for now and send a separate= patch > >> for inclusion in linux/bits.h (apparently the preprocessor doesn't car= e about > >> redefinitions so we can just remove the cedrus fashion once the common= one is > >> in). > >> > >> What do you think? > >> > >> Cheers, > >> > >> Paul > >=20 > >=20 > >=20 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --IS0zKkzwUGydFO0o Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAl2vC7kACgkQ3cLmz3+f v9FNWQf/VOFy2NcFFmeA6TWZfvyrkmu5obas+AFQpmgHiPdhg/5hxka22rig87Es ZGJbCBBCOTKnxdGVp4TX+gNTWdHNuwcc3m61U50w6uNFaPnSHjraKEvt6A44rwoq DyQA5JeBbyLpjKT6ceVhSl719jqnsNr3wel0zNo1rBLvyFRxZgvysWff3x3xAQQU 3+InsoB/T1C8tj1dMlS2okywVpeN8MfKcTX8Yfw3kubeULYM6gzoZ377Px6DMYmP SpNlTYcYQIoIKni/pB8ji+BfisYqdcLBkVq37Y6vcTLWZmiF9bTfXylaTefEISaq 3Mss27y4ElhNhARIXlfxsz8Vn1Hrgw== =VMbB -----END PGP SIGNATURE----- --IS0zKkzwUGydFO0o--