Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp161247rdb; Wed, 20 Dec 2023 08:49:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IErsptJDwRP8nY0MgwRPBjg8W/bG6lPinxcwtTsLIqphKDyzCnUGoK2t46VdBChogLG5vS0 X-Received: by 2002:a05:6a00:298e:b0:6d9:3794:304c with SMTP id cj14-20020a056a00298e00b006d93794304cmr2116732pfb.66.1703090972338; Wed, 20 Dec 2023 08:49:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703090972; cv=none; d=google.com; s=arc-20160816; b=ZigY1Aqx0gcRzFL86y1uMAPupN97/+mGVuwPKEd3MT7IoeLcahm2xfMOwLDR1yCv2Y J7vLhMaAG2IkpfIA8XP2eNhRDplH0b2YSVxh5y0hiJt0KVlktgUSqbHoSvACLkm/Jrmq k1tuLo3gEmi8fQZ+QbrEJoJQen6HzzA8n5sTb9mPE/Z8pWSeJTxHoB2wyajcWhQheFIr oI06nSozfXUE07Pyqf4P+XcPj0ayPZSDTd0uYWP1AE+p++bVnu/adyjj8CupFCnpV/rW 4U7eguvNHfB2dsSHtqh/R1llslopnU1DdumDR4ZpnMM7qO9pBAVrI9F0+IUUFGu2nqyk Fztw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ZbFRKfQ8apHOhegnAQD1nmzIFGR465JSBOj3gnYHwtM=; fh=sqsfmfyJwUJv6m2jYDJZFZGhueTiUiMY+SatAtIaJFA=; b=OdK2IuUFp5Pq8OBxz/3dk6g/lTigasxGxu0bSnDkA3wbV5FoCEOLQuWUqZe09uoAgK 55A90Y1IO0UQSLTEnvX86kAQwR+6w9II494+bUwy0VZQBmWroUL+7ZHOC0gLOS6i1UzU snv7Vuc7pXF90tjIRrw6IzjwKr25msq6Ja7lKFBhBNcXpQS1rFGnnw/I15iVTrJg+sNf gfsxAlz64nfhL7pqGlHZt0IB40rK0DCN7LHYtLm1VTNTd74vBwNBHEy07u//qOsU+IQV zTiN4eKjkwbHqrSROKUkQGVbAf+RJjSUbZCtQ2AbdKfO7P07n47KC2H0ZoozW4c7BXCS DOsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NagBxEGF; spf=pass (google.com: domain of linux-kernel+bounces-7319-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ct19-20020a056a000f9300b006d8010338dcsi5316878pfb.116.2023.12.20.08.49.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7319-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NagBxEGF; spf=pass (google.com: domain of linux-kernel+bounces-7319-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5ADD528530A for ; Wed, 20 Dec 2023 16:49:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B00404653E; Wed, 20 Dec 2023 16:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="NagBxEGF" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A8764642E; Wed, 20 Dec 2023 16:49:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BKGe6XA026803; Wed, 20 Dec 2023 16:49:00 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=ZbFRKfQ8apHOhegnAQD1nmzIFGR465JSBOj3gnYHwtM=; b=Na gBxEGFhWLZDZ8bVq573pBUokR+i/OojEsme+jqQmtdTPivp6m1xv5khWF9CYwlX0 atVGQpLuB7nW9sIw6cEFEhAIW066FgS/hipaRKUXHBlbSnBH1l4Rgk9bAtGtsnaG cAyRBu2Su/zY2fdO/mT2V+FX9z4vdSFIAL6o/u/pDnGM212RSncmQ4C4eDSbfEzh 60J6bwRk10A16I+7KmCoeuDMAGud/5lnotaD2/tCrI9hYY9TzFHo5PD9ZB5JmO7T hgmQtL1LiuJ+9AL4aFjekoydExzQ245ryzpC/9L9fF2NqKmogzMEJ751rwfD57dh C5Kt7snbv24i9UTLBkCQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v37vxv940-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 16:49:00 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BKGmxDM001242 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Dec 2023 16:48:59 GMT Received: from [10.110.111.239] (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.1118.40; Wed, 20 Dec 2023 08:48:57 -0800 Message-ID: <91628bd3-45ab-0e2b-2331-f3f1ea2232b4@quicinc.com> Date: Wed, 20 Dec 2023 08:48:56 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v6] drm/msm/dpu: improve DSC allocation Content-Language: en-US To: Dmitry Baryshkov CC: , , , , , , , , , , , , , , , , References: <1702580172-30606-1-git-send-email-quic_khsieh@quicinc.com> From: Kuogee Hsieh In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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-ORIG-GUID: Lja8mOxvgY7cajDk_jdUI6JXc2yWi9pv X-Proofpoint-GUID: Lja8mOxvgY7cajDk_jdUI6JXc2yWi9pv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 suspectscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 clxscore=1015 mlxscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312200120 On 12/19/2023 2:32 PM, Dmitry Baryshkov wrote: > On Tue, 19 Dec 2023 at 18:18, Kuogee Hsieh wrote: >> Hi Dmitry, >> >> Anymore comments from you? > No, for some reason I missed this patch. Please excuse me. > >> On 12/14/2023 10:56 AM, Kuogee Hsieh wrote: >>> At DSC V1.1 DCE (Display Compression Engine) contains a DSC encoder. >>> However, at DSC V1.2 DCE consists of two DSC encoders, one has an odd >>> index and another one has an even index. Each encoder can work >>> independently. But only two DSC encoders from same DCE can be paired >>> to work together to support DSC merge mode at DSC V1.2. For DSC V1.1 >>> two consecutive DSC encoders (start with even index) have to be paired >>> to support DSC merge mode. In addition, the DSC with even index have >>> to be mapped to even PINGPONG index and DSC with odd index have to be >>> mapped to odd PINGPONG index at its data path in regardless of DSC >>> V1.1 or V1.2. This patch improves DSC allocation mechanism with >>> consideration of those factors. >>> >>> Changes in V6: >>> -- rename _dpu_rm_reserve_dsc_single to _dpu_rm_dsc_alloc >>> -- rename _dpu_rm_reserve_dsc_pair to _dpu_rm_dsc_alloc_pair >>> -- pass global_state to _dpu_rm_pingpong_next_index() >>> -- remove pp_max >>> -- fix for loop condition check at _dpu_rm_dsc_alloc() >>> >>> Changes in V5: >>> -- delete dsc_id[] >>> -- update to global_state->dsc_to_enc_id[] directly >>> -- replace ndx with idx >>> -- fix indentation at function declaration >>> -- only one for loop at _dpu_rm_reserve_dsc_single() >>> >>> Changes in V4: >>> -- rework commit message >>> -- use reserved_by_other() >>> -- add _dpu_rm_pingpong_next_index() >>> -- revise _dpu_rm_pingpong_dsc_check() >>> >>> Changes in V3: >>> -- add dpu_rm_pingpong_dsc_check() >>> -- for pair allocation use i += 2 at for loop >>> >>> Changes in V2: >>> -- split _dpu_rm_reserve_dsc() into _dpu_rm_reserve_dsc_single() and >>> _dpu_rm_reserve_dsc_pair() >>> >>> Fixes: f2803ee91a41 ("drm/msm/disp/dpu1: Add DSC support in RM") >>> Signed-off-by: Kuogee Hsieh >>> --- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 154 +++++++++++++++++++++++++++++---- >>> 1 file changed, 139 insertions(+), 15 deletions(-) > Reviewed-by: Dmitry Baryshkov > > See below for minor nit. > >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c >>> index f9215643..0ce2a25 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c >>> @@ -461,29 +461,153 @@ static int _dpu_rm_reserve_ctls( >>> return 0; >>> } >>> >>> -static int _dpu_rm_reserve_dsc(struct dpu_rm *rm, >>> - struct dpu_global_state *global_state, >>> - struct drm_encoder *enc, >>> - const struct msm_display_topology *top) >>> +static int _dpu_rm_pingpong_next_index(struct dpu_global_state *global_state, >>> + int start, > I'd still prefer to see `enum dpu_pingpong` as a parameter here > instead of just an index, but this is just my taste. Can you please elaborate more details (pseudo code)  for this? i can add it at my next DP dsc patches. > >>> + uint32_t enc_id) >>> { >>> - int num_dsc = top->num_dsc; >>> int i; >>> >>> - /* check if DSC required are allocated or not */ >>> - for (i = 0; i < num_dsc; i++) { >>> - if (!rm->dsc_blks[i]) { >>> - DPU_ERROR("DSC %d does not exist\n", i); >>> - return -EIO; >>> + for (i = start; i < (PINGPONG_MAX - PINGPONG_0); i++) { >>> + if (global_state->pingpong_to_enc_id[i] == enc_id) >>> + return i; >>> + } >>> + >>> + return -ENAVAIL; >>> +} >>> + >>> +static int _dpu_rm_pingpong_dsc_check(int dsc_idx, int pp_idx) >>> +{ >>> + /* >>> + * DSC with even index must be used with the PINGPONG with even index >>> + * DSC with odd index must be used with the PINGPONG with odd index >>> + */ >>> + if ((dsc_idx & 0x01) != (pp_idx & 0x01)) >>> + return -ENAVAIL; >>> + >>> + return 0; >>> +} >>> + >>> +static int _dpu_rm_dsc_alloc(struct dpu_rm *rm, >>> + struct dpu_global_state *global_state, >>> + uint32_t enc_id, >>> + const struct msm_display_topology *top) >>> +{ >>> + int num_dsc = 0; >>> + int pp_idx = 0; >>> + int dsc_idx; >>> + int ret; >>> + >>> + for (dsc_idx = 0; dsc_idx < ARRAY_SIZE(rm->dsc_blks) && >>> + num_dsc < top->num_dsc; dsc_idx++) { >>> + if (!rm->dsc_blks[dsc_idx]) >>> + continue; >>> + >>> + if (reserved_by_other(global_state->dsc_to_enc_id, dsc_idx, enc_id)) >>> + continue; >>> + >>> + pp_idx = _dpu_rm_pingpong_next_index(global_state, pp_idx, enc_id); >>> + if (pp_idx < 0) >>> + return -ENAVAIL; >>> + >>> + ret = _dpu_rm_pingpong_dsc_check(dsc_idx, pp_idx); >>> + if (ret) >>> + return -ENAVAIL; >>> + >>> + global_state->dsc_to_enc_id[dsc_idx] = enc_id; >>> + num_dsc++; >>> + pp_idx++; >>> + } >>> + >>> + if (num_dsc < top->num_dsc) { >>> + DPU_ERROR("DSC allocation failed num_dsc=%d required=%d\n", >>> + num_dsc, top->num_dsc); >>> + return -ENAVAIL; >>> + } >>> + >>> + return 0; >>> +} >>> + >>> +static int _dpu_rm_dsc_alloc_pair(struct dpu_rm *rm, >>> + struct dpu_global_state *global_state, >>> + uint32_t enc_id, >>> + const struct msm_display_topology *top) >>> +{ >>> + int num_dsc = 0; >>> + int dsc_idx, pp_idx = 0; >>> + int ret; >>> + >>> + /* only start from even dsc index */ >>> + for (dsc_idx = 0; dsc_idx < ARRAY_SIZE(rm->dsc_blks) && >>> + num_dsc < top->num_dsc; dsc_idx += 2) { >>> + if (!rm->dsc_blks[dsc_idx] || >>> + !rm->dsc_blks[dsc_idx + 1]) >>> + continue; >>> + >>> + /* consective dsc index to be paired */ >>> + if (reserved_by_other(global_state->dsc_to_enc_id, dsc_idx, enc_id) || >>> + reserved_by_other(global_state->dsc_to_enc_id, dsc_idx + 1, enc_id)) >>> + continue; >>> + >>> + pp_idx = _dpu_rm_pingpong_next_index(global_state, pp_idx, enc_id); >>> + if (pp_idx < 0) >>> + return -ENAVAIL; >>> + >>> + ret = _dpu_rm_pingpong_dsc_check(dsc_idx, pp_idx); >>> + if (ret) { >>> + pp_idx = 0; >>> + continue; >>> } >>> >>> - if (global_state->dsc_to_enc_id[i]) { >>> - DPU_ERROR("DSC %d is already allocated\n", i); >>> - return -EIO; >>> + pp_idx = _dpu_rm_pingpong_next_index(global_state, pp_idx + 1, enc_id); >>> + if (pp_idx < 0) >>> + return -ENAVAIL; >>> + >>> + ret = _dpu_rm_pingpong_dsc_check(dsc_idx + 1, pp_idx); >>> + if (ret) { >>> + pp_idx = 0; >>> + continue; >>> } >>> + >>> + global_state->dsc_to_enc_id[dsc_idx] = enc_id; >>> + global_state->dsc_to_enc_id[dsc_idx + 1] = enc_id; >>> + num_dsc += 2; >>> + pp_idx++; /* start for next pair */ >>> } >>> >>> - for (i = 0; i < num_dsc; i++) >>> - global_state->dsc_to_enc_id[i] = enc->base.id; >>> + if (num_dsc < top->num_dsc) { >>> + DPU_ERROR("DSC allocation failed num_dsc=%d required=%d\n", >>> + num_dsc, top->num_dsc); >>> + return -ENAVAIL; >>> + } >>> + >>> + return 0; >>> +} >>> + >>> +static int _dpu_rm_reserve_dsc(struct dpu_rm *rm, >>> + struct dpu_global_state *global_state, >>> + struct drm_encoder *enc, >>> + const struct msm_display_topology *top) >>> +{ >>> + uint32_t enc_id = enc->base.id; >>> + >>> + if (!top->num_dsc || !top->num_intf) >>> + return 0; >>> + >>> + /* >>> + * Facts: >>> + * 1) no pingpong split (two layer mixers shared one pingpong) >>> + * 2) DSC pair starts from even index, such as index(0,1), (2,3), etc >>> + * 3) even PINGPONG connects to even DSC >>> + * 4) odd PINGPONG connects to odd DSC >>> + * 5) pair: encoder +--> pp_idx_0 --> dsc_idx_0 >>> + * +--> pp_idx_1 --> dsc_idx_1 >>> + */ >>> + >>> + /* num_dsc should be either 1, 2 or 4 */ >>> + if (top->num_dsc > top->num_intf) /* merge mode */ >>> + return _dpu_rm_dsc_alloc_pair(rm, global_state, enc_id, top); >>> + else >>> + return _dpu_rm_dsc_alloc(rm, global_state, enc_id, top); >>> >>> return 0; >>> } > >