Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2952055rwi; Fri, 28 Oct 2022 13:36:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78EA0F3aeCHMQOUhwWPplVyHTCUVvs9G++4ta5y6CFCDN/6jOhfD8KJi/jenfW9QR00sBY X-Received: by 2002:a05:6402:c45:b0:442:c549:8e6b with SMTP id cs5-20020a0564020c4500b00442c5498e6bmr1210752edb.123.1666989410726; Fri, 28 Oct 2022 13:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666989410; cv=none; d=google.com; s=arc-20160816; b=WmNRI+HnOOOI5t27UQHQJrJ5H2GzPmIRBFkhWH1fJvgp4tCbcovvhU0U5AzIZLDSt8 FLOTc1buCUiLN6vI1IqfxvZmYy9Z+TP3729EhXaC+KvnOqeDRIih1FcppW6fnsKqOQae EUgS09zQ5tRkRR9A5GB61EokomKbV68oYISp5tmesior7CxPUeSNfKbdUh1ape0O5D8M UD9RqlkX1tsv14dJ5GuiW0FYX2x8putbasN+2E4t1WP73Ya8HFDkKq441BPziX38Nqcj tt9PCM05mQgqlQocaMmRXPGo8ZA1FN9Ua6oRGfelJ5UqFvraPx1wQfRlWr3dysqWNgiI m6Lw== 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=IPC479CAA5HeMhgSDRQ1UWI5lvGUO4jQYTQV6u41Upc=; b=rJ+Wluvlwdx/tftc1Pt8eQrS1HS1ByFAodgKZ4QJODQqopfiQVoE0kbh/K+GeH1gPC 0PH28SPrulvsgt0PH5BKmGYKaJsHpb3NqvzZTZbS4dWEuTJ8EXZ//yRodgvNiqEj22zY E4dA2ZMY9jcItmeiqXHJh2hnLgR+tf9Ar6wzos4DiB7dgtmXf1PR8khcyfM1sI3vJqhB dBWMIannlMPB/LySci5yzqylC7f+vjJ0tZQ3ia7Ukpd9wvknICQjd6naPKnKghJ6w2ED 2BCkSkBzaxJH5C6zGi7JeUsz7LmAeqrPqMDEjmHxr9rgY05v2+wbbqZlVsv0SLKtmZSw lTbA== 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 qb6-20020a1709077e8600b0073155abc1b8si6215057ejc.154.2022.10.28.13.36.25; Fri, 28 Oct 2022 13:36:50 -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 S230155AbiJ1UKg (ORCPT + 99 others); Fri, 28 Oct 2022 16:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbiJ1UJX (ORCPT ); Fri, 28 Oct 2022 16:09:23 -0400 Received: from relay05.th.seeweb.it (relay05.th.seeweb.it [IPv6:2001:4b7a:2000:18::166]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236751C906F for ; Fri, 28 Oct 2022 13:09:20 -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-r2.th.seeweb.it (Postfix) with ESMTPSA id 804013F1D8; Fri, 28 Oct 2022 22:09:16 +0200 (CEST) Date: Fri, 28 Oct 2022 22:09:15 +0200 From: Marijn Suijten To: Abhinav Kumar Cc: phone-devel@vger.kernel.org, Rob Clark , Dmitry Baryshkov , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Sean Paul , David Airlie , Daniel Vetter , Douglas Anderson , Vladimir Lypak , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 00/10] drm/msm: Fix math issues in MSM DSC implementation Message-ID: <20221028200823.s5ygokpfy5jz25ge@SoMainline.org> Mail-Followup-To: Marijn Suijten , Abhinav Kumar , phone-devel@vger.kernel.org, Rob Clark , Dmitry Baryshkov , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Sean Paul , David Airlie , Daniel Vetter , Douglas Anderson , Vladimir Lypak , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20221026182824.876933-1-marijn.suijten@somainline.org> <99744fda-a3b8-f97a-294c-78e512d865bc@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99744fda-a3b8-f97a-294c-78e512d865bc@quicinc.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Hi Abhinav, On 2022-10-28 11:33:21, Abhinav Kumar wrote: > Hi Marijn > > On 10/26/2022 11:28 AM, Marijn Suijten wrote: > > Various removals of complex yet unnecessary math, fixing all uses of > > drm_dsc_config::bits_per_pixel to deal with the fact that this field > > includes four fractional bits, and finally making sure that > > range_bpg_offset contains values 6-bits wide to prevent overflows in > > drm_dsc_pps_payload_pack(). > > > > Altogether this series is responsible for solving _all_ Display Stream > > Compression issues and artifacts on the Sony Tama (sdm845) Akatsuki > > smartphone (2880x1440p). > > > > Changes since v3: > > - Swap patch 7 and 8 to make sure msm_host is available inside > > dsi_populate_dsc_params(); > > - Reword patch 6 (Migrate to drm_dsc_compute_rc_parameters()) to more > > clearly explain why the FIXME wasn't solved initially, but why it can > > (and should!) be resolved now. > > > > v3: https://lore.kernel.org/linux-arm-msm/20221009184824.457416-1-marijn.suijten@somainline.org/T/#u > > > > Changes since v2: > > - Generalize mux_word_size setting depending on bits_per_component; > > - Migrate DSI's DSC calculations to drm_dsc_compute_rc_parameters(), > > implicitly addressing existing math issues; > > - Disallow any bits_per_component other than 8, until hardcoded values > > are updated and tested to support such cases. > > > > v2: https://lore.kernel.org/linux-arm-msm/20221005181657.784375-1-marijn.suijten@somainline.org/T/#u > > > > Changes since v1: > > > > - Propagate r-b's, except (obviously) in patches that were (heavily) > > modified; > > - Remove accidental debug code in dsi_cmd_dma_add; > > - Move Range BPG Offset masking out of DCS PPS packing, back into the > > DSI driver when it is assigned to drm_dsc_config (this series is now > > strictly focusing on drm/msm again); > > - Replace modulo-check resulting in conditional increment with > > DIV_ROUND_UP; > > - Remove repeated calculation of slice_chunk_size; > > - Use u16 instead of int when handling bits_per_pixel; > > - Use DRM_DEV_ERROR instead of pr_err in DSI code; > > - Also remove redundant target_bpp_x16 variable. > > > > v1: https://lore.kernel.org/linux-arm-msm/20221001190807.358691-1-marijn.suijten@somainline.org/T/#u > > > > Marijn Suijten (10): > > drm/msm/dsi: Remove useless math in DSC calculations > > drm/msm/dsi: Remove repeated calculation of slice_per_intf > > drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on > > modulo > > drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size > > drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc > > drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters() > > drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits > > drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC > > values > > drm/msm/dpu1: Account for DSC's bits_per_pixel having 4 fractional > > bits > > drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent > > bits > > > > drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 11 +- > > drivers/gpu/drm/msm/dsi/dsi_host.c | 121 ++++++--------------- > > 2 files changed, 37 insertions(+), 95 deletions(-) > > > > -- > > 2.38.1 > > > > To keep the -fixes cycle to have only critical fixes (others are > important too but are cleanups), I was thinking of absorbing patches > 7,8,9 and 10 alone in the -fixes cycle and for patches 1-6, will go > through the 6.2 push. > > Let me know if there are any concerns if we just take patches 7,8,9 and > 10 separately. Unfortunately that isn't going to cut it. For starters patch 8 is only introducing additional validation but as long as no panel drivers set bpc != 8, this doesn't change anything: it is not a critical fix. Then, more importantly, as discussed in v2 reviews it was preferred to _not_ fix the broken code in dsi_populate_dsc_params() but migrate to drm_dsc_compute_rc_parameters() directly [1]. As such patch 6 (which performs the migration) is definitely a requirement for the fixes to be complete. Then again this patch looks weird when 5 is not applied, since both refactor how dsc->mux_word_size is assigned. At the same time it cannot be cleanly applied without patch 1 (Remove useless math in DSC calculations) nor patch 3 (Use DIV_ROUND_UP instead of conditional increment on modulo), but I just realized that patch 3 is now also useless as the code is being removed altogether while migrating to drm_dsc_compute_rc_parameters(). Same for patch 4 (Reuse earlier computed dsc->slice_chunk_size): while it may not seem obvious at first, the original code uses bits_per_pixel without considering the fractional bits, again resulting invalid values. Perhaps this should have been mentioned in the patch description, but I did not want to create an even larger chain of references pointing back and forth to future patches fixing the exact same bug. Unfortunately this patch doesn't apply cleanly without patch 2 (Remove repeated calculation of slice_per_intf) either. All in all, applying this series piecemeal requires careful consideration which of the patches are actually fixing issues, and is terribly tricky considering code cleanups touching the same code and sitting right before the fixes (done intentionally to not distract diffs in bugfixes being surrounded by odd looking code). [1]: https://lore.kernel.org/linux-arm-msm/CAA8EJpr=0w0KReqNW2jP8DzvXLgo_o6bKmwMOed2sXb6d8HKhg@mail.gmail.com/ - Marijn