Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp66502rwb; Wed, 5 Oct 2022 14:50:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5h8UdmrBjXXy0G3wtMUE1thZaNrbienO2mvpoL4BJii2bIgyuJN7fukJ50JKkeJ/m0AFbg X-Received: by 2002:a63:4283:0:b0:457:dced:8ba3 with SMTP id p125-20020a634283000000b00457dced8ba3mr1624376pga.220.1665006626388; Wed, 05 Oct 2022 14:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665006626; cv=none; d=google.com; s=arc-20160816; b=TkUrUFGG5TxLfCANsDe/q9OnJmRpRiw+nGBIl9J5r1PAuZeI8q2PhqFyvQ1PNguxqj i+GQREA/Cp6XYiScsdi8br7l2QaRIYHRRT412OwWmTQT+unD0ZH+noGzM1Jwl+OhWbws aK+imSj4MSWm1EMeIJwsQlXrTB/vK3+LGVSMddSIza7TiofWUv7lUGP4VHLF+3nOakrn vbqxKUOI83e/CtsgABj3RJKTyeJLBGDoQLbCetu4RoxfdAgPmQz0CrtJaPBUEgsDV/pF sUdXaGOGz/ro+jJrFLIN6yx5kvXTxHHNFHCvYzEW7CLCRloOTGhcVBlxkxEWpMpAsdD4 EmfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=m8rcUOmSkkOBsqzuwn+dnbX0t6FP3OQ03nPOvq9bcVk=; b=DnlgV/paAqJbPBle7NqejO3HSkehfHjwPL1BInlIGfD+JcVfLScOc0sR4MTHiF4jtE 2cAeUdq5yOlhB86iMxTNS6nfQ8D6mSiD6tSZdY6xdlkKbV5oXIWI6YUFYup8yZv1jlzR VdpRNi7kzgOZjXyKyJSlAc2/CxKGAyM0ZxzaPy0/nkkYw1OSW36Kano7Sh/fEAFVPIhn GnVnW6ms2/Ylkl1pcIxakahKB3kcHDLoecgvOMry4ms9tlBwirxMmn1AtHnM1c9pmB/s kJ9veek5nBk/sGpEIyPIIEUjPyFZLi9gsY40r3XWPznD/Ts7XtoZ2hOZ8MVNTWzj8pkB JPgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XOYcf+MX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a170903024f00b00174b83659fasi16360012plh.502.2022.10.05.14.50.07; Wed, 05 Oct 2022 14:50:26 -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; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XOYcf+MX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231204AbiJEVO1 (ORCPT + 99 others); Wed, 5 Oct 2022 17:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbiJEVOZ (ORCPT ); Wed, 5 Oct 2022 17:14:25 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC7424BD9; Wed, 5 Oct 2022 14:14:24 -0700 (PDT) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 295L6WwP029173; Wed, 5 Oct 2022 21:14:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=m8rcUOmSkkOBsqzuwn+dnbX0t6FP3OQ03nPOvq9bcVk=; b=XOYcf+MXIAmdVZGqMdudKj4Ym6rvpoqI2Ev50qjtjLJSWnBk5opZd4PQIaqUZcXSERPV KNxAge5Al6viiDU5nCoUBSDAvGMRgsR5qRWWe0oeCr5JKIMlSPic/jE3QIGWXcsrzjGk oOB2p1FugaRC1gw3iG30Pr4fzMQrmYFDYRL2suxLJL3+JmB5j6+6FscQFsuXP6U9AnlE BgrRBYrAb2Xg9W3IvmJMszpUfYilNq1OgoP4EfBko67xasOTeJIeFrvOJRXKGl7wjzqv UVySLkwHGPXMcpkSATJdOGwoDjTa83EuhOztoht6Ix500Mcpf6/MOkw0tCMTya8BrOwW qQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3k0escvc9g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Oct 2022 21:14:08 +0000 Received: from pps.filterd (NALASPPMTA04.qualcomm.com [127.0.0.1]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 295Ku7JN006827; Wed, 5 Oct 2022 21:14:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 3k1e0drn5q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Oct 2022 21:14:07 +0000 Received: from NALASPPMTA04.qualcomm.com (NALASPPMTA04.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 295L27se014655; Wed, 5 Oct 2022 21:14:07 GMT Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (PPS) with ESMTPS id 295LE73u027387 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Oct 2022 21:14:07 +0000 Received: from [10.38.244.136] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 5 Oct 2022 14:14:04 -0700 Message-ID: Date: Wed, 5 Oct 2022 14:14:02 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v2 1/7] drm/msm/dsi: Remove useless math in DSC calculations Content-Language: en-US To: Marijn Suijten , , Rob Clark , Dmitry Baryshkov , Vinod Koul CC: <~postmarketos/upstreaming@lists.sr.ht>, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Daniel Vetter , Sean Paul , Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Douglas Anderson , Vladimir Lypak , , , , , David Airlie References: <20221005181657.784375-1-marijn.suijten@somainline.org> <20221005181657.784375-2-marijn.suijten@somainline.org> From: Abhinav Kumar In-Reply-To: <20221005181657.784375-2-marijn.suijten@somainline.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 2omwmzd_ViBXMlRXd0jRT5coS9A-OjGr X-Proofpoint-GUID: 2omwmzd_ViBXMlRXd0jRT5coS9A-OjGr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-10-05_05,2022-10-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 adultscore=0 clxscore=1015 suspectscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 bulkscore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210050131 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, 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 10/5/2022 11:16 AM, 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. > > After that target_bpp_x16 is used to store a multiplication of > bits_per_pixel by 16 which is only ever read to immediately be divided > by 16 again, and is elided in much the same way. > > Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data") > Signed-off-by: Marijn Suijten Reviewed-by: Abhinav Kumar > --- > drivers/gpu/drm/msm/dsi/dsi_host.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c > index 8e4bc586c262..70077d1f0f21 100644 > --- a/drivers/gpu/drm/msm/dsi/dsi_host.c > +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c > @@ -1784,7 +1784,6 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc) > int hrd_delay; > int pre_num_extra_mux_bits, num_extra_mux_bits; > int slice_bits; > - int target_bpp_x16; > int data; > int final_value, final_scale; > int i; > @@ -1864,14 +1863,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; > - > - data = (dsc->initial_xmit_delay * target_bpp_x16) / 16; > + data = dsc->initial_xmit_delay * dsc->bits_per_pixel; > final_value = dsc->rc_model_size - data + num_extra_mux_bits; > dsc->final_offset = final_value; >