From patchwork Wed Jun 14 16:31:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Gerhold X-Patchwork-Id: 108060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp105948vqr; Wed, 14 Jun 2023 10:15:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5kM7GGC/GSCr1XPGl6+6HLdRfy1fD66s92l3CIOjpm89FWFgaaqU3id+ykCmkmJBGO/Xq0 X-Received: by 2002:a05:6a20:1584:b0:10c:467a:536f with SMTP id h4-20020a056a20158400b0010c467a536fmr3005862pzj.14.1686762945911; Wed, 14 Jun 2023 10:15:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686762945; cv=pass; d=google.com; s=arc-20160816; b=yIAEi2759+DkzMYfPEJZOAOUPRC/+r9GNh4q0H1HZuvYAOPJw8F2jvnLz3frkRbLYY HMA2xoxKra/FKL+3V4SBysp3Vp/DPkjr4XqkTBcmnbj+LOvbn16biue5DY0OOoi7PELO NM6eoxtI8eb2u0HQNpMbonhud/Lwpufy12/9ZkkXnHQBLYxhzF3JqoeOOded+gptGxFE Xl+ZIvub33XWVsS6wtq/2jnFasAE5qk8NPdzNJ58kguPkxbu4EvhQNHHvIq7wkDtfYwc xT40Zw4adTFB0LE8uS2LSeK0wyUjyw+WmVvtKEV4rnPaMBcCog4oRJzCoT4/8AnBydCt AgrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature:dkim-signature; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=NxP14r70eB5qGXsJ+xlouX1fitPsCHvJoPYKtOXJt+uKKJktvGXXRROA+YITv6ntkW paAc9jYBEldU9NHYcnV+qnxTAmrOuz2a8oitqVqbNaYjnydTO7rDuQgXrwLDzPG5Dg7J qNtSbkbQRuf5F6eHE5ExTE1S2NE2yfScCpqHv8yOOQbsRXnz8f3XVqjTnmGSPS27TlL3 SCvZCQumtO7ulRUGHcLHaTjsIIJoxw55h8x2a7nQ8Oo8DTdGxLgJHAtW3lWEzywZL2YD CnCNn5FOMmQn3JvTg8UyGHXAbPVSggx626mHVZjKySLsE020N5kFbK9+2dT/qUdLM9Wc G9wQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gerhold.net header.s=strato-dkim-0002 header.b=JcxBcGPa; dkim=neutral (no key) header.i=@gerhold.net header.s=strato-dkim-0003 header.b=qciHgIC2; arc=pass (i=1); 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020aa79a41000000b0063b64166faesi11301053pfj.157.2023.06.14.10.15.20; Wed, 14 Jun 2023 10:15:45 -0700 (PDT) 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=@gerhold.net header.s=strato-dkim-0002 header.b=JcxBcGPa; dkim=neutral (no key) header.i=@gerhold.net header.s=strato-dkim-0003 header.b=qciHgIC2; arc=pass (i=1); 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 S233996AbjFNQcR (ORCPT + 99 others); Wed, 14 Jun 2023 12:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjFNQcP (ORCPT ); Wed, 14 Jun 2023 12:32:15 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [81.169.146.164]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426E91A3; Wed, 14 Jun 2023 09:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686760325; cv=none; d=strato.com; s=strato-dkim-0002; b=svbPe323u+L4XXWIhtfqYnowXOJoDHc8+oHjEl5Qt7DhVydd6t1Hh+COLm1+mKS7F9 nxe9UJaA9459NAlfTLRRX3beZeEwqB4JeZv2s0zb++8hzTfq32QdppKPowfb+eonzlpj CSRkjH8EmZr0hbtAnfP+CxUJ1y0bfI4NXZjWjiNLNxqEQJ7wZT/x/9gpuv/tIneJKOrB ONWfYcRxPlGBgJ5m+iCBR/JbycDSUA9Z2u0UxSdeijjM4gMNN84giG6+To6BylzJzbPX Y3Bo747cCRFB4h9HnoaWSIBxzVnEFJXunY3yMkPOVMdDtmc9jcoxuLaaogDlM2Clw2lS K9WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1686760325; s=strato-dkim-0002; d=strato.com; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=pLWXrq/l7HJWkttzP11zi3TVWFU7s2t7O5HR6TkhIo8FwgPP0hOF62j6uYLu8P+1Or NUSI4BWpc2JIIUOMG0M+IsajVrkVIceE+yFj/ABzPuNTOW4aIYQJmQO3y9p59TceoB2i +tBu0VrHJGLo9MwDm+vMlzEyCQtMqCXWI9ijy+XJGQmXjQMMI2bCd04OQSgB6KbuUejo jYRpvwe9sWpRTDO27C3YUJXKFK+wNRnw+8HoHJyo8sfGk6UgTCoQ4cS4rQS42yk8T2cU L86gmlZ3rHV6wXr7LXuV+A/xbtxlrJrinVDsvw8w0BbSTH71rnIUU85EhlepmLfuN+Cd CunA== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1686760325; s=strato-dkim-0002; d=gerhold.net; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=JcxBcGPaZqH2eE+/LNMff7DL9IRVol6Q5Dyp5d0r1AXlaWe3GPYtFOPYuSj59zdIud Ec6NRiwXwuWG0OF75PvkU3bcrZwNZwpM3MyFinfsIqhjIn7GFzZoPtFKLswbOjvenT9F vIdutPC4AOd4HjQcwXwo6HQbVKhsbLn34Pa1XbHJxOm7wKqlACrYKVhd02tgNjYNv7P1 QshQOleyHGBj69Wyot4xm5CwD6AsM3nVXEu+nvjgfBAL8wg+MChRry1/s1RUC6LleoCm 9Nfck7F1gJt6I1Dtnbo1wPEppR7MOUNVan4H1iXToDs/NwtKU9VjsRqTZZlqZJ/LkCOt 1a5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1686760325; s=strato-dkim-0003; d=gerhold.net; h=Cc:To:In-Reply-To:References:Message-Id:Subject:Date:From:Cc:Date: From:Subject:Sender; bh=7CZkh2tsWk1KLyX3MYfuwePFgnEoOOmuyhey9E40TaI=; b=qciHgIC2hl9TZ//hlpzHC4kgh7sXed9uT58ElvtBAAxkJk5E1j6V21RwxcAMFLGuiD f+f/EvEkWMXCH2I9OcBg== X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVOQjVd4CteZ/7jYgS+mLFY+H0JAn8u4xxmw==" Received: from [192.168.244.3] by smtp.strato.de (RZmta 49.6.0 DYNA|AUTH) with ESMTPSA id D0d0a8z5EGW50U3 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 14 Jun 2023 18:32:05 +0200 (CEST) From: Stephan Gerhold Date: Wed, 14 Jun 2023 18:31:54 +0200 Subject: [PATCH v2 1/2] remoteproc: qcom: Handle reserved-memory allocation issues MIME-Version: 1.0 Message-Id: <20230529-rproc-of-rmem-v2-1-95e39b959585@gerhold.net> References: <20230529-rproc-of-rmem-v2-0-95e39b959585@gerhold.net> In-Reply-To: <20230529-rproc-of-rmem-v2-0-95e39b959585@gerhold.net> To: Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Mathieu Poirier , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Stephan Gerhold X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768699142380573053?= X-GMAIL-MSGID: =?utf-8?q?1768699142380573053?= If Linux fails to allocate the dynamic reserved memory specified in the device tree, the size of the reserved_mem will be 0. Add a check for this to avoid using an invalid reservation. Signed-off-by: Stephan Gerhold --- New patch in v2, I wasn't aware of this until Bjorn posted a similar patch for rmtfs: https://lore.kernel.org/linux-arm-msm/20230530233643.4044823-4-quic_bjorande@quicinc.com/ --- drivers/remoteproc/qcom_q6v5_mss.c | 2 +- drivers/remoteproc/qcom_q6v5_wcss.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c index 70bffc9f33f6..a35ab6e860f3 100644 --- a/drivers/remoteproc/qcom_q6v5_mss.c +++ b/drivers/remoteproc/qcom_q6v5_mss.c @@ -1932,7 +1932,7 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc) return 0; rmem = of_reserved_mem_lookup(node); - if (!rmem) { + if (!rmem || !rmem->size) { dev_err(qproc->dev, "unable to resolve metadata region\n"); return -EINVAL; } diff --git a/drivers/remoteproc/qcom_q6v5_wcss.c b/drivers/remoteproc/qcom_q6v5_wcss.c index b437044aa126..9edab9d60c21 100644 --- a/drivers/remoteproc/qcom_q6v5_wcss.c +++ b/drivers/remoteproc/qcom_q6v5_wcss.c @@ -882,7 +882,7 @@ static int q6v5_alloc_memory_region(struct q6v5_wcss *wcss) rmem = of_reserved_mem_lookup(node); of_node_put(node); - if (!rmem) { + if (!rmem || !rmem->size) { dev_err(dev, "unable to acquire memory-region\n"); return -EINVAL; }