From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CCBFC433FE for ; Tue, 4 Oct 2022 21:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbiJDVtL (ORCPT ); Tue, 4 Oct 2022 17:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232250AbiJDVsp (ORCPT ); Tue, 4 Oct 2022 17:48:45 -0400 Received: from relay04.th.seeweb.it (relay04.th.seeweb.it [IPv6:2001:4b7a:2000:18::165]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC4B167E7; Tue, 4 Oct 2022 14:48:22 -0700 (PDT) Received: from SoMainline.org (94-209-172-39.cable.dynamic.v4.ziggo.nl [94.209.172.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r1.th.seeweb.it (Postfix) with ESMTPSA id 4FD4F200F6; Tue, 4 Oct 2022 23:48:18 +0200 (CEST) Date: Tue, 4 Oct 2022 23:48:16 +0200 From: Marijn Suijten To: Dmitry Baryshkov Cc: phone-devel@vger.kernel.org, Rob Clark , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , David Airlie , Daniel Vetter , Abhinav Kumar , Sean Paul , Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Douglas Anderson , Vladimir Lypak , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Lyude Paul Subject: Re: [PATCH 5/5] drm/dsc: Prevent negative BPG offsets from shadowing adjacent bitfields Message-ID: <20221004214816.3azmktopwjgpodzt@SoMainline.org> Mail-Followup-To: Marijn Suijten , Dmitry Baryshkov , phone-devel@vger.kernel.org, Rob Clark , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , David Airlie , Daniel Vetter , Abhinav Kumar , Sean Paul , Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Douglas Anderson , Vladimir Lypak , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Lyude Paul References: <20221001190807.358691-1-marijn.suijten@somainline.org> <20221001190807.358691-6-marijn.suijten@somainline.org> <20221001202313.fkdsv5ul4v6akhc3@SoMainline.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-10-04 17:41:07, Dmitry Baryshkov wrote: > On Sat, 1 Oct 2022 at 23:23, Marijn Suijten > wrote: > [..] > > Pre-empting the reviews: I was contemplating whether to use FIELD_PREP > > here, given that it's not yet used anywhere else in this file. For that > > I'd remove the existing _SHIFT definitions and replace them with: > > > > #define DSC_PPS_RC_RANGE_MINQP_MASK GENMASK(15, 11) > > #define DSC_PPS_RC_RANGE_MAXQP_MASK GENMASK(10, 6) > > #define DSC_PPS_RC_RANGE_BPG_OFFSET_MASK GENMASK(5, 0) > > > > And turn this section of code into: > > > > cpu_to_be16(FIELD_PREP(DSC_PPS_RC_RANGE_MINQP_MASK, > > dsc_cfg->rc_range_params[i].range_min_qp) | > > FIELD_PREP(DSC_PPS_RC_RANGE_MAXQP_MASK, > > dsc_cfg->rc_range_params[i].range_max_qp) | > > FIELD_PREP(DSC_PPS_RC_RANGE_BPG_OFFSET_MASK, > > dsc_cfg->rc_range_params[i].range_bpg_offset)); > > > > Is that okay/recommended? > > This is definitely easier to review. However if you do not want to use > FIELD_PREP, it would be better to split this into a series of `data |= > something` assignments terminated with the rc_range_parameters[i] > assignment. Anything is fine by me, I have no strong opinion on this and rather leave it up to the maintainers. However, FIELD_PREP gives us concise `#define`s through a single `GENMASK()` carrying both the shift and mask/field-width. At the same time these genmask definitions map more clearly to the layout comment right above: /* * For DSC sink programming the RC Range parameter fields * are as follows: Min_qp[15:11], max_qp[10:6], offset[5:0] */ If switching to `data |=` however, I've been recommended to not use FIELD_PREP but fulyl write out `data |= (value & MASK) << SHIFT` instead. Perhaps a more important question is how to apply this consistently throughout the function? - Marijn