dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Marijn Suijten <marijn.suijten@somainline.org>
To: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: David Airlie <airlied@linux.ie>,
	Konrad Dybcio <konrad.dybcio@somainline.org>,
	dri-devel@lists.freedesktop.org,
	Javier Martinez Canillas <javierm@redhat.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@somainline.org>,
	phone-devel@vger.kernel.org, Marek Vasut <marex@denx.de>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	linux-arm-msm@vger.kernel.org,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Martin Botka <martin.botka@somainline.org>,
	~postmarketos/upstreaming@lists.sr.ht,
	Sean Paul <sean@poorly.run>,
	Jami Kettunen <jami.kettunen@somainline.org>,
	Vladimir Lypak <vladimir.lypak@gmail.com>,
	Douglas Anderson <dianders@chromium.org>,
	linux-kernel@vger.kernel.org, Vinod Koul <vkoul@kernel.org>,
	Alex Deucher <alexander.deucher@amd.com>,
	freedreno@lists.freedesktop.org
Subject: Re: [Freedreno] [PATCH 1/5] drm/msm/dsi: Remove useless math in DSC calculation
Date: Wed, 5 Oct 2022 00:23:17 +0200	[thread overview]
Message-ID: <20221004222317.6or3w6vwgyd3yy6z@SoMainline.org> (raw)
In-Reply-To: <7ded0eb3-ef99-1979-ffb6-c639288bd863@quicinc.com>

On 2022-10-04 07:33:49, Abhinav Kumar wrote:
> 
> 
> On 10/1/2022 12:08 PM, Marijn Suijten wrote:
> > Multiplying a value by 2 and adding 1 to it always results in a value
> > that is uneven, and that 1 gets truncated immediately when performing
> > integer division by 2 again.  There is no "rounding" possible here.
> > 
> > Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> > Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> > ---
> >   drivers/gpu/drm/msm/dsi/dsi_host.c | 7 +------
> >   1 file changed, 1 insertion(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> > index 8e4bc586c262..e05bae647431 100644
> > --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> > +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> > @@ -1864,12 +1864,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> >   	data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
> >   	dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
> >   
> > -	/* bpp * 16 + 0.5 */
> > -	data = dsc->bits_per_pixel * 16;
> > -	data *= 2;
> > -	data++;
> > -	data /= 2;
> > -	target_bpp_x16 = data;
> > +	target_bpp_x16 = dsc->bits_per_pixel * 16;
> >   
> Since this patch is titled, "remove useless math", even the 
> target_bpp_x16 math looks redundant to me,
> 
> first we do
> 
> target_bpp_x16 = dsc->bits_per_pixel * 16;
> 
> then in the next line we do
> 
> data = (dsc->initial_xmit_delay * target_bpp_x16) / 16;
> 
> the *16 and /16 will cancel out here.
> 
> Instead we can just do
> 
> data = (dsc->initial_xmit_delay * dsc->drm->bits_per_pixel) ?

Thanks, good catch!  I might have been so focused on explaining the
effect of this patch and uselessness of the proposed `+ 0.5` rounding
here that I missed this intermediate variable now becoming redundant as
well.

Corrected for v2!

- Marijn

> >   	data = (dsc->initial_xmit_delay * target_bpp_x16) / 16;
> >   	final_value =  dsc->rc_model_size - data + num_extra_mux_bits;

  reply	other threads:[~2022-10-04 22:23 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01 19:08 [PATCH 0/5] drm: Fix math issues in MSM DSC implementation Marijn Suijten
2022-10-01 19:08 ` [PATCH 1/5] drm/msm/dsi: Remove useless math in DSC calculation Marijn Suijten
2022-10-01 20:19   ` Konrad Dybcio
2022-10-04  0:26   ` Bjorn Andersson
2022-10-04 14:33   ` [Freedreno] " Abhinav Kumar
2022-10-04 22:23     ` Marijn Suijten [this message]
2022-10-01 19:08 ` [PATCH 2/5] drm/msm/dsi: Remove repeated calculation of slice_per_intf Marijn Suijten
2022-10-01 20:22   ` Konrad Dybcio
2022-10-04  0:30   ` Bjorn Andersson
2022-10-04 14:41   ` Abhinav Kumar
2022-10-01 19:08 ` [PATCH 3/5] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
2022-10-01 20:28   ` Konrad Dybcio
2022-10-01 20:37   ` Marijn Suijten
2022-10-04 14:45   ` Dmitry Baryshkov
2022-10-04 22:35     ` Marijn Suijten
2022-10-04 22:40       ` Dmitry Baryshkov
2022-10-04 22:56         ` Marijn Suijten
2022-10-01 19:08 ` [PATCH 4/5] drm/msm/dpu1: " Marijn Suijten
2022-10-04 14:35   ` Dmitry Baryshkov
2022-10-04 17:03   ` Abhinav Kumar
2022-10-04 22:11     ` Marijn Suijten
2022-10-05 14:19       ` Abhinav Kumar
2022-10-05 18:45         ` Marijn Suijten
2022-10-01 19:08 ` [PATCH 5/5] drm/dsc: Prevent negative BPG offsets from shadowing adjacent bitfields Marijn Suijten
2022-10-01 20:23   ` Marijn Suijten
2022-10-04 14:41     ` Dmitry Baryshkov
2022-10-04 21:48       ` Marijn Suijten
2022-10-04 20:22   ` Abhinav Kumar
2022-10-04 21:57     ` Marijn Suijten
2022-10-04 22:31       ` Abhinav Kumar
2022-10-04 22:39         ` Marijn Suijten
2022-10-05 15:33           ` Abhinav Kumar
2022-10-05 18:29             ` Marijn Suijten
2022-10-04  4:42 ` [PATCH 0/5] drm: Fix math issues in MSM DSC implementation Vinod Koul
2022-10-04  9:51   ` Marijn Suijten

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221004222317.6or3w6vwgyd3yy6z@SoMainline.org \
    --to=marijn.suijten@somainline.org \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=angelogioacchino.delregno@somainline.org \
    --cc=dianders@chromium.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jami.kettunen@somainline.org \
    --cc=javierm@redhat.com \
    --cc=konrad.dybcio@somainline.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=martin.botka@somainline.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=sean@poorly.run \
    --cc=tzimmermann@suse.de \
    --cc=vkoul@kernel.org \
    --cc=vladimir.lypak@gmail.com \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).