Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6677782rwl; Mon, 9 Jan 2023 11:27:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXs2qTwPBal4N5TAL2MtUacCjT3pK+ZLQmT3Lv7mo3xhgtIjKqtHUxEMTuBVOXb4j0TfGuX1 X-Received: by 2002:a17:903:181:b0:193:3154:625c with SMTP id z1-20020a170903018100b001933154625cmr5994001plg.35.1673292432157; Mon, 09 Jan 2023 11:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673292432; cv=none; d=google.com; s=arc-20160816; b=I61VsP039jRhRxHHt7GXLaR4Y3VDcVRFs88/xsPk0sPBEumEv+hzwlmSDwdsqpbOv1 oiyFBwlMcszmF81CLj4JHKC95L8fo6ycGP1v69sT9mQ9Qvu5ohs+C6IwIYzxgtY9kQ1c eXI/GvWY6OUsnmf6W53mLCB44HpW0nvBvRooqQKoKj8jBpBHc2TrGgoaQQ/iKXsQT3Ph 5IdMugGYuDJoYU0bjKCUCmLjZntvmfxePWxBULCFtyGuxTSB1nMGkzzq6azenzjqcV1h AcLs0rqVkRZfKb6Ntv2xFBgMQ6vsyeee3wEoqazLqhsaH1cILMnGHkSG0OIQ20kYFbnw DbaQ== 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=ciC8Itd05zrc4mqdQW4FAXytrWOg65pDTPIECNA32rA=; b=LXQc2uadDc4ea6OVQC4N7yCNGxbAnyMU56LxNIkHfwA/DoueK+2IdlsxX5b1/0dA9p Ry2LuQECQp15ERmjV0BXcQ2UFXTH+APRgJwA38vI2EXS8eJxuyYlImLoZByJwuINmKBs 94JCxVKI8A0TbiT0no9exH0n7Bv88KrScJhm/Gxmt8mqBDKyCEQJxLcFsrfMsJOaLFB0 LqLctwlYtHAe9eUfjusrMmAcAOJGVGVlaA1icjNLPlyZtJK2eSlufAQHeCv/HKsZPg7f +igGTfQnmZmGctttFo/UJu2Hbkp8LWor/nWZrApA7dKBFTLmgXS/lxD2HMsPDS1lizeW o04A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WycOer6N; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ik24-20020a170902ab1800b0019257c9a252si8961462plb.175.2023.01.09.11.27.05; Mon, 09 Jan 2023 11:27:12 -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; dkim=pass header.i=@linaro.org header.s=google header.b=WycOer6N; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbjAIS17 (ORCPT + 53 others); Mon, 9 Jan 2023 13:27:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237341AbjAIS0v (ORCPT ); Mon, 9 Jan 2023 13:26:51 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D97F71FD7 for ; Mon, 9 Jan 2023 10:24:19 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id g13so14330384lfv.7 for ; Mon, 09 Jan 2023 10:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ciC8Itd05zrc4mqdQW4FAXytrWOg65pDTPIECNA32rA=; b=WycOer6N4iDXZTrEoXCOWDtIFlFKdYnysTq4lttAbZ667wDehkC2KFmWEctX/lwhZR BCymIM97fYFLN6iSU88dYcKULCqgs9sug6hWhW5RPkUA2mimIdRNliXKdL2Ap268kXKQ bV1eP8wFpYs/WBrFIdRR2cQzvKEaSZRuHP7x7MW7xbdFzb/+Un7glAPpUijczorjgUN0 Pu/EpcIv17iKuuboF1d3sK84yv6k2gO7KaZIPFh26BumPLIN2G2Pjqk/tPjqT4Y/9024 wpEmfuFnJHusw/QP/EhqB0Wp/QCBl4hRe9n0fARhQY2d7HOUnQTIOcy+uOoeePCBHX5T AUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ciC8Itd05zrc4mqdQW4FAXytrWOg65pDTPIECNA32rA=; b=2a26QACWw8UOpn7tTw1908EBVehW518qikEQQ/ruKgbOhWsArHKU4j2Ybe+/7hbKNV o/eq1CufexJ0enYxrW667vuv0EF78RyyNMvopp3i2bP/lJ6/829EysYKPVM8v0qN7s3y jnuSFSiYU6K75LO38ZomT+oHMYf+I2IOYcH6AK5L68fy5TVZUvX+zbNsERZLWE8jR2gd XCZ9VthTiwy2wpAdsMUi7uumdxlzmlFULO0WuUl3UzXbgyeERRLNuhCBYbMSrFLmp5dY BjOw5Ye2T04h3RauQLfUo69hR1LLKh4CSb7lia1pUuqV12mGd0iA+qOfoe1j3Ut4GNaq oTxA== X-Gm-Message-State: AFqh2krwVgDNsN4NGMUEmlQoDbyNOHZreVlxhELYnqCUK5XFBuD14QC0 sfyup/KNcKsHm52x64TZVpcogA== X-Received: by 2002:ac2:5fce:0:b0:4b5:850e:6f4a with SMTP id q14-20020ac25fce000000b004b5850e6f4amr19855731lfg.69.1673288658255; Mon, 09 Jan 2023 10:24:18 -0800 (PST) Received: from ?IPV6:2001:14ba:a085:4d00::8a5? (dzccz6yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a085:4d00::8a5]) by smtp.gmail.com with ESMTPSA id w4-20020a19c504000000b004b5812207dbsm1740486lfe.201.2023.01.09.10.24.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Jan 2023 10:24:17 -0800 (PST) Message-ID: <4514a37f-ff75-1aed-2207-426ad846411e@linaro.org> Date: Mon, 9 Jan 2023 20:24:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v2 4/8] drm/msm/dpu: Disallow unallocated resources to be returned Content-Language: en-GB To: Marijn Suijten 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 , =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , 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, Drew Davenport References: <20221221231943.1961117-1-marijn.suijten@somainline.org> <20221221231943.1961117-5-marijn.suijten@somainline.org> <1b872a47-6ffc-1fe9-f283-897dbc37d709@linaro.org> <20230109082357.meebk7udokdfvwle@SoMainline.org> <20230109171223.vjkigcj7xwfwow2a@SoMainline.org> From: Dmitry Baryshkov In-Reply-To: <20230109171223.vjkigcj7xwfwow2a@SoMainline.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 09/01/2023 19:12, Marijn Suijten wrote: > On 2023-01-09 11:06:45, Dmitry Baryshkov wrote: >> On Mon, 9 Jan 2023 at 10:24, Marijn Suijten >> wrote: >>> >>> On 2023-01-09 01:30:29, Dmitry Baryshkov wrote: >>>> On 09/01/2023 01:28, Dmitry Baryshkov wrote: >>>>> On 22/12/2022 01:19, 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. >>>>>> >>>>>> ^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. >>>>>> >>>>>> Fixes: bb00a452d6f7 ("drm/msm/dpu: Refactor resource manager") >>>>>> Signed-off-by: Marijn Suijten >>>>>> --- >>>>>> drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 5 +++++ >>>>>> 1 file changed, 5 insertions(+) >>>>> >>>>> I think the patch is not fully correct. Please check resource >>>>> availability during allocation. I wouldn't expect an error from >>>>> get_assigned_resources because of resource exhaustion. >>> >>> Theoretically patch 5/8 should take care of this, and we should never >>> reach this failure condition. Emphasis on /should/, this may happen >>> again if/when another block type is added with sub-par resource >>> allocation and assignment implementation. >> >> Yeah. Maybe swapping 4/8 and 5/8 makes sense. > > Ack. > >>>> Another option, since allocation functions (except DSC) already have >>>> these safety checks: check error message to mention internal >>>> inconstency: allocated resource doesn't exist. >>> >>> Is this a suggestion for the wording of the error message? >> >> Yes. Because the current message makes one think that it is output >> during allocation / assignment to encoder, while this is a safety net. > > Good. So the patch is correct, just the wording is off, which I fully > agree on. This isn't allocating anything, just handing out what was > previously allocated (and is a safety net). Yes. Please excuse me if my original message was not 100% clear. > > - Marijn -- With best wishes Dmitry