From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4891C5479D for ; Mon, 9 Jan 2023 18:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237603AbjAIS2C (ORCPT ); Mon, 9 Jan 2023 13:28:02 -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-Google-Smtp-Source: AMrXdXvIr6JDWXylhCd83Kbg77UPE81swhmMPkPrl0hoB7kDLxXgvcpoYZqWOL8YI6s9nAZLYyMJTw== 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 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