Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1575698rwb; Wed, 14 Dec 2022 12:00:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf41HlxbzT8Turh/b+/G9uHdMSgQvd0JXgy7tmcG0eFR7wKyTdzf4Iq8sBDQ7DwzJeBunnDJ X-Received: by 2002:a50:ed98:0:b0:46b:4011:9863 with SMTP id h24-20020a50ed98000000b0046b40119863mr22743034edr.39.1671048030531; Wed, 14 Dec 2022 12:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671048030; cv=none; d=google.com; s=arc-20160816; b=dX2JQUVxO2Ky+n9M/fgejvlaZMctQRc1Bc8z1pZV5eDUAg2JCbqpKrEjir2lzeADXW HHhjqWz6IIA2vcb8dGsx95PZ1y9TfCvuOMy68BqpqOeJaFr6SH/n7TEUjYuG4RLPogDM K53xAgYdjNWEheQMZNluKJAQRI0FvXsh6o2ZQVBJeFYvOLBsK2W57B7xPt+UTVa+T5rO s+nwu7cJa2MXt5ii2QwL+RFvD9ddpgt3PitkYfb1R6RtYMAXWnCSjccZgKpCXX477xpT bf72i0o+9JxsNcbzw0KirXwQff8Ec4W0ZZCki7MiM7hjwntWTeijCV8bsmebRn6oHHIK iksA== 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=rhNmKW7bJyiXK3KoO9+Z/7b4iTEuc54FW2pBBfdqlRg=; b=I3swqshT15zdgrtJqbRLJvv0ydy4K5J2FGKy1Nra+6UJOgBgNjhirxA0R5hS5gpyiO Xe8+agAfxdSpunocYu+m1OT6mZFUdkmTPt3AaPW74m6CSn6M0qyU45oAWzb11pKo+DdI 38aylhAzF+RCqbrM1YwsttxfheMS8oMMVAYuVvUclhwIYHPJ63TZFbxmqRNPYIxdvYvi iXi9AWoEvlcKkUgSI5vaWSWxukTtDS+Ubv+EN696chQhK9RtFUorjvIgSNgIQ8a4EWCo LWH7JCVnbzRBTDqQ4Fvdxssm0GEOyi0L8oytd/jL56zGwp+eaI5hjKmPMHDswOk4m6pm zj3g== 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 dz17-20020a0564021d5100b0046ced2c935csi14729159edb.585.2022.12.14.12.00.13; Wed, 14 Dec 2022 12:00:30 -0800 (PST) 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 S238838AbiLNTbv (ORCPT + 69 others); Wed, 14 Dec 2022 14:31:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237752AbiLNTbs (ORCPT ); Wed, 14 Dec 2022 14:31:48 -0500 Received: from relay02.th.seeweb.it (relay02.th.seeweb.it [5.144.164.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC9EB124; Wed, 14 Dec 2022 11:31:47 -0800 (PST) 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-r1.th.seeweb.it (Postfix) with ESMTPSA id 80F2B1F541; Wed, 14 Dec 2022 20:31:45 +0100 (CET) Date: Wed, 14 Dec 2022 20:31:44 +0100 From: Marijn Suijten To: Dmitry Baryshkov Cc: phone-devel@vger.kernel.org, Rob Clark , Abhinav Kumar , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Sean Paul , David Airlie , Daniel Vetter , Stephen Boyd , Bjorn Andersson , Jessica Zhang , Ville =?utf-8?B?U3lyasOkbMOk?= , Kuogee Hsieh , Jani Nikula , sunliming , Sam Ravnborg , Haowen Bai , Konrad Dybcio , Loic Poulain , Vinod Polimera , 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: [RFC PATCH 6/6] drm/msm/dpu: Disallow unallocated (DSC) resources to be returned Message-ID: <20221214193144.to6yk5tr46akfy5m@SoMainline.org> Mail-Followup-To: Marijn Suijten , Dmitry Baryshkov , phone-devel@vger.kernel.org, Rob Clark , Abhinav Kumar , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Sean Paul , David Airlie , Daniel Vetter , Stephen Boyd , Bjorn Andersson , Jessica Zhang , Ville =?utf-8?B?U3lyasOkbMOk?= , Kuogee Hsieh , Jani Nikula , sunliming , Sam Ravnborg , Haowen Bai , Konrad Dybcio , Loic Poulain , Vinod Polimera , 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: <20221213232207.113607-1-marijn.suijten@somainline.org> <20221213232207.113607-7-marijn.suijten@somainline.org> <4b7b4fb0-b99b-1022-b0f6-e91a84e8d082@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b7b4fb0-b99b-1022-b0f6-e91a84e8d082@linaro.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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 2022-12-14 20:56:30, Dmitry Baryshkov wrote: > On 14/12/2022 01:22, Marijn Suijten wrote: > > In the event that the topology requests resources that have not been > > created by the system (because they are typically not represented in > > dpu_mdss_cfg ^1), the resource(s) in global_state (in this case DSC > > blocks) remain NULL but will still be returned out of > > dpu_rm_get_assigned_resources, where the caller expects to get an array > > containing num_blks valid pointers (but instead gets these NULLs). > > > > To prevent this from happening, where null-pointer dereferences > > typically result in a hard-to-debug platform lockup, num_blks shouldn't > > increase past NULL blocks and will print an error and break instead. > > After all, max_blks represents the static size of the maximum number of > > blocks whereas the actual amount varies per platform. > > > > In the specific case of DSC initial resource allocation should behave > > more like LMs and CTLs where NULL resources are skipped. The current > > hardcoded mapping of DSC blocks should be loosened separately as DPU > > 5.0.0 introduced a crossbar where DSC blocks can be "somewhat" freely > > bound to any PP and CTL, but that hardcoding currently means that we > > will return an error when the topology reserves a DSC that isn't > > available, instead of looking for the next free one. > > > > ^1: which can happen after a git rebase ended up moving additions to > > _dpu_cfg to a different struct which has the same patch context. > > > > Signed-off-by: Marijn Suijten > > --- > > drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c > > index 73b3442e7467..dcbf03d2940a 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c > > @@ -496,6 +496,11 @@ static int _dpu_rm_reserve_dsc(struct dpu_rm *rm, > > > > /* 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; > > + } > > + > > if (global_state->dsc_to_enc_id[i]) { > > DPU_ERROR("DSC %d is already allocated\n", i); > > return -EIO; > > @@ -660,6 +665,11 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm, > > blks_size, enc_id); > > break; > > } > > + if (!hw_blks[i]) { > > + DPU_ERROR("No more resource %d available to assign to enc %d\n", > > + type, enc_id); > > + break; > > + } > > blks[num_blks++] = hw_blks[i]; > > } > > > > These two chunks should come as two separate patches, each having it's > own Fixes tag. Ack. They are indeed addressing different issues (with the same outcome) with differing "backportability". Will address in v2, thanks for pointing it out (and missing a Fixes: in the first place, of which we already have so many...). - Marijn