Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1109157rwb; Tue, 4 Oct 2022 15:48:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59Tl/MliBpPvnnOcmdicqHBC7hqrDCs7QAOb4QK4HXeBDTphczq2f/1EWIckyq+oEJls7Y X-Received: by 2002:a17:907:746:b0:741:4a1b:cb1f with SMTP id xc6-20020a170907074600b007414a1bcb1fmr20368473ejb.370.1664923704952; Tue, 04 Oct 2022 15:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664923704; cv=none; d=google.com; s=arc-20160816; b=hbSUfInkatzoemwR+29IZD2xk3pMaxXwfvctZHCTj5iimFjbzQEOGHT/clitv7oYo4 cpsnbwCHNKtyWT2UZGPGWYJTfeS+YFwA/4nlW4yKO0QmB4N8vH83lHP0tXwomwas0UXz cIV4W8ziuuKlSM/weqc6BUt/MxdKw7jzwAo5GsZd1D+BXuMiertKrj7H9VYm6coKpf4Z NkpRjAYha9IEl4mqUy5LBUISezZvTL1c8D/NGx2g/uWLNoFfpGOL48jzqVteWnQ61VLE C1+ddWbwcwl34tpv++JqXN1lIwxLxhzgzIT3UP2y7MVGlefloRzsNiT345a5tfKCNB7P CoIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=xE5IiDvYNyOnBOL6rflWpTjzXH989PuDDccTGYzwBOs=; b=MHWsWPYyGxoknPh5k3MkidmmvJVTWjqSzk+rm/ezzn/B+A23ms8aiCaehLbscHrIM3 qnEC/vjEr3udq1/m5iHhvld2/RcixMaR+Tdhm75lmQDwl53CzC7LQV57YRWkZAUheJV6 E89znDMU9mgNyHBSgPiy3i7tWxQy7YpJk0XHvTtyLakbe1hSxEiVDXyIunjljEoHaHTW cLev6OSM/ofWZ6s9urz/B9rSWW2L6A7nTTpqs5LdnCLmP9JKExkPIjPfEpPB1+mLo26Z 1TH6GEgSz0MjeYjG03V5xN41XiEjefAX/xKdOPIxyn8/6rSD3uLiyAFsCKb8l5odBoTf GgGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp13-20020a1709073e0d00b0078cfdd694bfsi4218208ejc.280.2022.10.04.15.47.59; Tue, 04 Oct 2022 15:48:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbiJDVtJ (ORCPT + 99 others); Tue, 4 Oct 2022 17:49:09 -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: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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