Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp170212rwi; Wed, 12 Oct 2022 18:02:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Me3BN+3Idb8wOQ3XDWOye1JPiZnKItBqTTQHUzQbZUc7YjZBUwirw1hkM6FoG4QeZkKHD X-Received: by 2002:a17:907:968e:b0:78d:d68d:6751 with SMTP id hd14-20020a170907968e00b0078dd68d6751mr8699310ejc.403.1665622958629; Wed, 12 Oct 2022 18:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665622958; cv=none; d=google.com; s=arc-20160816; b=KTm/z2P6k5aCKHzvYZ9b/ylcZR/vNGZOPO/HSfHQaKZwmcK2G+TywXlXm7Tyx+BDGL ptxCLo3mG1t5L4rsrP8/zFqxCNAXdOVAOn2/mN0EndwD+h6rA2LqftgbUYsjyfYY3AMm Ef8Or/q5a+rP8MTeCc8TJtaukMN/ZUxyxYOvVyloIfN8BVvfZNND75u8LTVpJnVBhDL+ /CbnsOMZ45be/lV6tXQwruMsHPELxk5bEZEftnm6POoBZaNXjaqovd27avxmNpdJdvUz 2NGEZAVwyGTfe2FpTdE1OY4u5hqmrS8yZ8ipKH9VZCEogfec5GDfVseAKo1HrJ385w8X q5YA== 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=CNPmxgW3pPlP+BkFNJfzz3SBIfQiNzpnFWL/syGAZ3w=; b=G5A+IkRMcoEkTPFcneyypvmMRlz0ubX3i/TGjtIPL0sddMoYllDRgYqnOU7XmYSWbk IKVn6AGhvBp3ElHoI15eKZn6XT0qdkRc67nJDg6cHc728y3f3D3lpKA1nApKR3xlF4WS PPnYGxeGG1/1V4SwrGVXBbH0gs+SdyIxzxqqiNK/hS4eGvlRXKjhDAZ0uLj8DCe/4U/Z 3rGLnVYsO9xeYCbSeboJXow2oguS8DMyyGIwGa0+iN/E75peI8nfabem332CDbXTNcjm ozlq1CcBSi36zw7LaDQQzxWWdsIItQx/nnVWdK7cVG1nNu6O1ctGegdAR67jJlPzR307 7Zjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=YYT8oAsl; 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 gb10-20020a170907960a00b007848e6eaef1si14171354ejc.733.2022.10.12.18.02.13; Wed, 12 Oct 2022 18:02:38 -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=YYT8oAsl; 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 S229716AbiJLX0f (ORCPT + 99 others); Wed, 12 Oct 2022 19:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiJLX0e (ORCPT ); Wed, 12 Oct 2022 19:26:34 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A154A10A; Wed, 12 Oct 2022 16:26:33 -0700 (PDT) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29CNJURK010887; Wed, 12 Oct 2022 23:26:22 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=CNPmxgW3pPlP+BkFNJfzz3SBIfQiNzpnFWL/syGAZ3w=; b=YYT8oAslM5mllwEzPfjAVavKxoQkuy0RtVdCtZS6GOzj3XH2NOG/Boj3T7pF7udzr5ts 7dNz3LZQqGpAZjIW8vEywLrhhlSalgDv+wFiKQjH8s1gKOG/8KrLOVmvDl6K6DJ09oR/ fVh2VC33jxOy6FkcNd5q/qk16ZQ81zTNagEcO8XhAtluyeGeSVp5Mlmrz/jrpP2pSeKC tQVj2tdGtpb0nL6uYQ92/pos6XHgDE2wQQIor5XFTAW0C5pxbgXmRC9STMm+CtnIdPc8 8puUrlEd4npN7bKB92uV3WvShVvCzU5bgICbh2eLdouic7GYFuseEFKsMLeTUpEvef6r bA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3k5x7g1ptt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Oct 2022 23:26:22 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 29CNQLq8014442 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Oct 2022 23:26:21 GMT Received: from [10.38.241.12] (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, 12 Oct 2022 16:26:17 -0700 Message-ID: Date: Wed, 12 Oct 2022 16:26:15 -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 v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Content-Language: en-US To: Marijn Suijten , CC: <~postmarketos/upstreaming@lists.sr.ht>, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Rob Clark , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter , Vinod Koul , Douglas Anderson , Vladimir Lypak , , , , References: <20221009184824.457416-1-marijn.suijten@somainline.org> <20221009185316.462522-3-marijn.suijten@somainline.org> From: Abhinav Kumar In-Reply-To: <20221009185316.462522-3-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-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 0whAIauxe-5GPU5WOKX9nvzxO4GX52Ed X-Proofpoint-ORIG-GUID: 0whAIauxe-5GPU5WOKX9nvzxO4GX52Ed X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-12_11,2022-10-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210120146 X-Spam-Status: No, score=-3.3 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/9/2022 11:53 AM, Marijn Suijten wrote: > The bpg_offset array contains negative BPG offsets which fill the full 8 > bits of a char thanks to two's complement: this however results in those > bits bleeding into the next field when the value is packed into DSC PPS > by the drm_dsc_helper function, which only expects range_bpg_offset to > contain 6-bit wide values. As a consequence random slices appear > corrupted on-screen (tested on a Sony Tama Akatsuki device with sdm845). > > Use AND operators to limit these two's complement values to 6 bits, > similar to the AMD and i915 drivers. > > 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 | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c > index 46032c576a59..c5c2d70ac27d 100644 > --- a/drivers/gpu/drm/msm/dsi/dsi_host.c > +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c > @@ -1804,7 +1804,11 @@ static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc > for (i = 0; i < DSC_NUM_BUF_RANGES; i++) { > dsc->rc_range_params[i].range_min_qp = min_qp[i]; > dsc->rc_range_params[i].range_max_qp = max_qp[i]; > - dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i]; > + /* > + * Range BPG Offset contains two's-complement signed values that fill > + * 8 bits, yet the registers and DCS PPS field are only 6 bits wide. > + */ > + dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i] & DSC_RANGE_BPG_OFFSET_MASK; > } > > dsc->initial_offset = 6144; /* Not bpp 12 */