Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5937203rwl; Mon, 9 Jan 2023 01:46:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsg7cbG0DoZ+uDcyxTno8/vDFvPq5a8s2Svw8ZMYgohp8NjL0eMjGhlPo+FiLPMnaZ++9lW X-Received: by 2002:a05:6402:360b:b0:491:ad51:33f7 with SMTP id el11-20020a056402360b00b00491ad5133f7mr15449768edb.22.1673257563713; Mon, 09 Jan 2023 01:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673257563; cv=none; d=google.com; s=arc-20160816; b=DhKin7ewb3/w5wMayQpNi9NFDI8R6ksRZ5JQnw3rGgZ3BejpkXLKnIbEUJhcRTk160 EDmMWadqXL0QaDoiZ7Y73D2WHesoBqePKABIHsP/J1hl92s1Ramk3bkPFosnRNR+CM7p apAQLOvU/JVnzuVZntXPQSsRmJwlnKtTVo26ef1snp8zk9pM0F1BKqTh3t/CGPXlHicY GnsRPUtHnSX4ocMYguMTbxEoJLIHvvcuePEEAX2mAJ4Z5Q9C6BTFvWw87Jj512odCpGc KmlJalqBdDtI6zx2HrI4ze/whBKGTyd8RwKu6hFlbatFq8N+/0g5ozVNlrYrIYzNmSNR /TKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pk8HoU5sl6UY7My5Q7QXvnwfSNOwL/YVw0rPqcw5wI0=; b=F0JN2dnplle80LydFBoN/UXutytoTOZjL99TcSNh7gAgkU5p06IozEDNMaoLWfuWY/ XI6mlTntfk1V5gH97B6X6ZufpDNoqfGLfFPTZZIEAkMqI6CpZNggjxC2vWdUFcwAQ0is 6sNNVwtq9ZJPbxKCcw0CLRRxvhlAVCzVNnRYjQYdB/P0A3pHPC7jyXSnYJJ8SVAoXdn5 oHV9kQauKO2vpxVLbwJLHC7WSm4ycqVIFXAKIWQNLaJNL4iZGfSjmU5cybnLeOPuS73C RxnZVnTEoyqWHR+UbC0nJ+qCBoheyLms4hakdrjjcIBdx3xwiMcUe57R8D4jOlbKhuV3 I3vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uxJqcr/v"; 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 k26-20020aa7d8da000000b0048ee8cf8bb8si7818938eds.53.2023.01.09.01.45.50; Mon, 09 Jan 2023 01:46:03 -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="uxJqcr/v"; 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 S234471AbjAIJLQ (ORCPT + 54 others); Mon, 9 Jan 2023 04:11:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236996AbjAIJKT (ORCPT ); Mon, 9 Jan 2023 04:10:19 -0500 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46787165B5 for ; Mon, 9 Jan 2023 01:06:57 -0800 (PST) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-4b718cab0e4so104787247b3.9 for ; Mon, 09 Jan 2023 01:06:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pk8HoU5sl6UY7My5Q7QXvnwfSNOwL/YVw0rPqcw5wI0=; b=uxJqcr/vA16Jbso7FMrCavP3Cf2jhnnlPgVnsuBsvS/o+Z1jwaAnN1AQdnbbe+GJc6 ixviHjNm2JTcHR4e5QhHj1v3nXBUyMlCCBLXphPY6Q+qVkTzrxjlykCBgc2y7oRrP17s A5bSkfDmbgJreYllwN7sl/4BZpeZJ/z9eUcIoENMIMYTupxqrttaUSwQCj8s/SrP+sIQ 6wbCC9UCbTxxCG3hCIRwUkCdwfAGRw4ZfRIfAuJDLhTbJR+AerCjSUWlZklTY53Ts7Et bD4pvNfviMu91QcLX9ba5HawO/FK9vk9Bayawpaj1Wn4PcYxCp7iUlPdFSLxeLu0MHla foSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pk8HoU5sl6UY7My5Q7QXvnwfSNOwL/YVw0rPqcw5wI0=; b=0ZfWKQsF/i+n9kDdbVO8feI2N2zucoSkYYstwu0ZvQ1ze7NRmzpNPwf1PMDxzwO+zQ ZBiHcnPFWuM8SAPlzcVFn3OYw7CusjKu/AH6d/sxf53FsBB4u5ThX6ea8Z1SXzTUrK7d r1wwE4wlX5ENCZTvnL5gpyPS0LIX9Acq2s4yBS23YwxiDRu8Y70Ez7r8SWbOofi8Ffrz CXsl6Yp2z4rjLnEB5+rrRfh1hKafGMQjFfa7JNq3bq30fLnpk2WIaRkteFjkzEEcJADC 2JDLTROI2jes1ZUuq1oeW9+6+K/ZB+pHEIvN+NZ1sYITTAoRUdnkL3gRaW4ApMlhijcZ fnaw== X-Gm-Message-State: AFqh2ko70Q9Zro+VxzDhYoc89yGMymgTE4AuSZCz6RYMX7m3ow4Fsaw4 t15G4fFLNZ/qysI85J0jYFDrSgT9ZHifeOT6lrwPYQ== X-Received: by 2002:a0d:d692:0:b0:477:b56e:e1d6 with SMTP id y140-20020a0dd692000000b00477b56ee1d6mr6161ywd.188.1673255216324; Mon, 09 Jan 2023 01:06:56 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <20230109082357.meebk7udokdfvwle@SoMainline.org> From: Dmitry Baryshkov Date: Mon, 9 Jan 2023 11:06:45 +0200 Message-ID: Subject: Re: [PATCH v2 4/8] drm/msm/dpu: Disallow unallocated resources to be returned 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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. > > > 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. > > - Marijn -- With best wishes Dmitry