Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2419191rdb; Thu, 21 Sep 2023 19:43:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyFvHtuHakf5W+HWx5JsDBK+y7d6l6V/ZN7xVYv6175tv7FxcZ9nUaNDs09GF+kgbDT4zQ X-Received: by 2002:a05:6870:b490:b0:1b0:2f63:4ff6 with SMTP id y16-20020a056870b49000b001b02f634ff6mr7544566oap.1.1695350594403; Thu, 21 Sep 2023 19:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695350594; cv=none; d=google.com; s=arc-20160816; b=Tk590IwlxeN+Wob9ee8y9/c77eH5NQP7gE9YugcDy9Tk/q1JRI1Jx5ygLDsD5S3t+6 Nx63bXq9ZEO3i+R0xcTRYcV3lo6ErMn5sJoCV0oDHAazQ8juIzT4nXc2u0pV56Y6Frmn Lmnsu0wOnrivuTM+HHi82R6bhFmHdvWT9JLkAAnP8i2o0CiDHvCkvWpirG62Ss4o1HzL AQmQFmoy9HMB2F2qRHIHoVpi7F9viZ9CK30G7xRwKIZoDz1/30zCsHMjlBjZ3lsXye3K 6U0M6NQ1OkBoZL7OyIW4yoMQvAz6uT3+UgaOhWXp5632EGPBbwwAV+V/nRMwuWeHtt3h cQrQ== 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:dkim-signature; bh=Em44ruXjklVxoIC7Tw933C+uCQj1lfYEW9HiUaw9m2k=; fh=JGK+tPYxLAosc5qc0FfxVz+y0n6wqKz4oaplA69wp34=; b=t1i60Ho6o39ewDPgPqci6QfaUeJHPEMp9IwjMSmDk3EH1bq2/k0r/Tr4BDRYN22YVo p/TP3PCal1v0ZMMZZmlgOEEgnAPlR3UPgOeHH2tRKVPuTEQukoP/Wch8vLMVDVTaGmj9 5gQbnAsEvpMrw7i6FS8TEC5t4hym0sIWDoVhBhsdsm7Io2kdMrWjE3T1oemc7GvcQxSX TYLEDzrrJxwd772Pzt7tVdjGCqvaLlM7oNkzR5XW9OmvqdKeIrJ5RMrE/SiXZWJoc7OS IUMv87P+lRxUzqzwWGqL0Qous3WYb/rz0EPhCAr3iePprtIDs2bSWy8oP3FEmdi+5iBb v9Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pe++EJqt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f20-20020a637554000000b00565e2f4ad4esi2802213pgn.213.2023.09.21.19.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 19:43:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pe++EJqt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 767FC8381EE1; Thu, 21 Sep 2023 19:41:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbjIVClB (ORCPT + 99 others); Thu, 21 Sep 2023 22:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbjIVClA (ORCPT ); Thu, 21 Sep 2023 22:41:00 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A080196; Thu, 21 Sep 2023 19:40:53 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27A7CC433C8; Fri, 22 Sep 2023 02:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695350453; bh=8qIsVL6sv2Akw91FdfMBwVa1nZmidwwqy/fuoJa0HVo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pe++EJqt+ieoBhFxCYIpPJrcJiOj+irtamDCPdzxUeWuBGJIH+UXsLFGz2yg2Qh5c 1xM0gdD0UFUW4I2/w7H0QcWsKmRlaDENUsyuhFDcTGopr5MweMWAhoBF7MVKlZr/D8 iDrKwI6U7T628dsJkHEPL9WHGeuLOnBf0TRVN4p8G5kNr3bngpO01kCpKHdIn7A0Jp otBlQW+2g64kqnnR8BPeDk0jQ4KpBUPNtziXsWkCJEWMk7wurZzRWij+LV+he3TJ0P DAvGk3MZ8wh6bNYsH6L6YazWntB2PzCRyl5u+USSUW/qkH3kjLirF3FoNt7PrCmSIc coLZ+QN11+9AA== Date: Thu, 21 Sep 2023 19:44:58 -0700 From: Bjorn Andersson To: Stephan Gerhold Cc: Bjorn Andersson , Andy Gross , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Connolly Subject: Re: [PATCH v3 3/3] soc: qcom: rtmfs: Handle reserved-memory allocation issues Message-ID: <3jscpkqc4jpywcfpo3qxkgajtkjhzncw3kpi6cnmjesyrswpr2@ndwvowbq7vrq> References: <20230920-rmtfs-mem-guard-pages-v3-0-305b37219b78@quicinc.com> <20230920-rmtfs-mem-guard-pages-v3-3-305b37219b78@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 19:41:03 -0700 (PDT) On Thu, Sep 21, 2023 at 08:11:23PM +0200, Stephan Gerhold wrote: > On Wed, Sep 20, 2023 at 07:37:32PM -0700, Bjorn Andersson wrote: > > In the even that Linux failed to allocate the reserved memory range > > specified in the DeviceTree, the size of the reserved_mem will be 0, > > which results in a oops when memory remapping is attempted. > > > > Detect this and report that the memory region was not found instead. > > > > Signed-off-by: Bjorn Andersson > > I dropped these checks in my remoteproc patches because Caleb suggested > maybe putting this check directly in of_reserved_mem_lookup() (or > similar) given that almost none of the users verify this [1]. > > Do you have any opinion on that? I asked back then too but you did not > reply yet [2]. :-) > I'm struggling to come up with a use case where one would like to get hold of the rmem when it wasn't properly initialized. So, let's make an attempt at returning NULL from of_reserved_mem_lookup() instead. Thanks, Bjorn > [1]: https://lore.kernel.org/linux-arm-msm/c3f59fb4-4dd8-f27a-d3f5-b1870006a75c@linaro.org/ > [2]: https://lore.kernel.org/linux-arm-msm/ZIsld-MAdkKvdzTx@gerhold.net/ > > > --- > > drivers/soc/qcom/rmtfs_mem.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c > > index 83bba9321e72..13823abd85c2 100644 > > --- a/drivers/soc/qcom/rmtfs_mem.c > > +++ b/drivers/soc/qcom/rmtfs_mem.c > > @@ -180,7 +180,7 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev) > > int ret, i; > > > > rmem = of_reserved_mem_lookup(node); > > - if (!rmem) { > > + if (!rmem || !rmem->size) { > > dev_err(&pdev->dev, "failed to acquire memory region\n"); > > return -EINVAL; > > } > > > > -- > > 2.25.1 > >