Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6527554rwl; Mon, 9 Jan 2023 09:25:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGRU8Ko2/CY+7TCohpMBrs15xZJdNQiSLzrn/7cxY2PueLleWPUdSCpEINphDDk9JKpa0L X-Received: by 2002:a17:906:17d2:b0:846:fafa:5c77 with SMTP id u18-20020a17090617d200b00846fafa5c77mr47609759eje.48.1673285107823; Mon, 09 Jan 2023 09:25:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673285107; cv=none; d=google.com; s=arc-20160816; b=iwATzGznN2iZhLrVFVj4ONEcs1bLOKcPPHmU3iQifk3Kk38K91lJqk3nQvkw2WpzBG hYs9RdDo0eB2qSE6+8v9VytR3RSJ0mqTzwta4xO96Hr0V4XPWXuYf1LAzqZnw1pfCRn1 /JK3yVmG63saKfwSOpRjaWqdItNx1XxITjyh4BjkwFG5hPtah8mwFj1CTUDQB1dAZkCj 8JiUPfr+JYnrcZCjkAfZ+Cb84FsjYgfLZDW8/OWJjtDWfv3bSKsHN+3WWihnkSto0DGU zelPQqDbwomGOjRKu8hpKP8ZRM1XO0nJXHvpCQuVgss7+f1Sf/Ud+ULMIo3vVFOPDhgV xqIA== 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:message-id:subject:cc:to:from:date; bh=PY4d+ER8fBhslALl6G92OnjNf1Az/WQ6y76qGAdxVIw=; b=L1WMxX3PkJ4TJOTlUyqE7cXaD7IUdwAM6JbeAUV6bY7MpHofmWOzPe3c4/2pWuZpb9 A6Wb9HS8s2fx4KAkDIVeSkhSkWKfaapu1yWmZEHQnW/P89LQufzBiQbY3Z1M4kZcFf4t tPy/4dtotHV67MlMxFp8tna6X1j58Q0+mM9YRI19lUVd1tgGPmkwYC5dOp/C+cfvQhLK Ixl6/mfE7nJ5ynngJJ2c93t5k3vrQYEwQka2YBS0XczLFOrEnNvaECLkq9ruvedI3rg/ N0ySI0SgeMzbJPRv1/ud9OxRfnNodcfeg6i/Df76LuVW/a/QfBztJlKGWr5E2fpZ30wp Z5lQ== 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 ho11-20020a1709070e8b00b0082372aef3bcsi9374300ejc.583.2023.01.09.09.24.55; Mon, 09 Jan 2023 09:25:07 -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 S236994AbjAIRQg (ORCPT + 53 others); Mon, 9 Jan 2023 12:16:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237123AbjAIRNK (ORCPT ); Mon, 9 Jan 2023 12:13:10 -0500 Received: from m-r2.th.seeweb.it (m-r2.th.seeweb.it [IPv6:2001:4b7a:2000:18::171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CA573884 for ; Mon, 9 Jan 2023 09:12:28 -0800 (PST) Received: from SoMainline.org (unknown [89.205.226.190]) (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-r2.th.seeweb.it (Postfix) with ESMTPSA id 422543EBA8; Mon, 9 Jan 2023 18:12:25 +0100 (CET) Date: Mon, 9 Jan 2023 18:12:23 +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, Drew Davenport Subject: Re: [PATCH v2 4/8] drm/msm/dpu: Disallow unallocated resources to be returned Message-ID: <20230109171223.vjkigcj7xwfwow2a@SoMainline.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 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). - Marijn