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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5108DC30658 for ; Fri, 28 Jun 2024 18:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=H+ruGPETppbEAZdscNhJIuUHT64dVUBzmWwyvnp1b7w=; b=KfYG3noNn/xD7yQKySbFUwvKb9 XoNtWrSXCD4156Er6POZpHQHfIj9vJOSrKK66mptOOuiWFdMSNin7WA2aNZQyPl8y7SuwJHbixBHS r6gxgCrZkNpHBZUC2Puy8M6W2mK0es80ymBwXwIXoCxBLGG7/kxD4m2JVTAchS1H93x20uGRelRd1 0MOVOty7M8s5cI3OQFJZKEccdryNR82qv2cT59bx0haaTadPJDCQzGoTeOLdYRbrIfxxa3y4ztc9g bImdhMRr2lgOdxCEJuxyq4jri5+Xef8NnYK/uvKI/RuG6HoeeJ74ad6t++urMD4u53354baAQ4QFY RFW4ySlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNFxj-0000000EZdF-0oIT; Fri, 28 Jun 2024 18:04:43 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNFxZ-0000000EZZ8-12XH for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 18:04:34 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1f9aeb96b93so5611575ad.3 for ; Fri, 28 Jun 2024 11:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719597872; x=1720202672; darn=lists.infradead.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=H+ruGPETppbEAZdscNhJIuUHT64dVUBzmWwyvnp1b7w=; b=VkmY19ypvy9myetvIIuYD478puTVJlc89YauZnLEUmMc6CP+sFuFkjTH06rhgljRb/ 7GBfHxdjUNxvqkM+i3wsm3PVe0lhua/vGyXw9hT7IBx/VZxnLn8Sw519LDhVY5No7sIf tyvXeJTbYRQBYZx6h1cQtYtFUjuzwnbCPTmP2VTzhl1C64irlvb+qYbbYmLJTUllfs0c 1PBON+HLqCvN4TdMhhS8gKDh9S5pK20Wsy5xJ9LjpEQbnwjrOcWiaj9Zd9rEjFXBRpp2 hSKla9+mVdq2RniXKg15Zh4rpjiAFWZOMK7d4otzFgWIgCiJunp/5OXJqhA21XGjnrYB ul7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719597872; x=1720202672; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H+ruGPETppbEAZdscNhJIuUHT64dVUBzmWwyvnp1b7w=; b=KhK54o7m1nU99c7bvj4kJ964aeix1ofJWS/GtrVBxJpAbHiaL3HZQEKCl80Ti3Fs7K MnoV1f6T7HgXcU7gn7U2TgPO7iNVlLPTzLOSi87aD7XYTJyY8nfKUzXMFjnsFosov6y3 2nz/bdiEO1wrsBDKkaBhSSP6coRBbZZZe3nRySLjKdCeXlyGURa+v0T9ef20zVN3w5cb sReI4Gxcv7Zuz5ql1QahhRbB/XalVZCpXnlOnxLkpKus2o2YakGx0xo+wAF6mC9LQkwC UUn9OU85SW5n/Xa6U0bPbIYGuBkiA7Sz6879RrEF2gObtdbSXcLHs6fK1ecLUunkboca 73bg== X-Forwarded-Encrypted: i=1; AJvYcCUkiHZT7826u8hc6k9Dr3IZGOSDTSO2+IeFYpSgdEACbJNILs8DkLf08paowN/mqoxAtU55cQtUOSDJ+yFACmvx3JUs1AzPkTbfd3ZJFxu4GtzL5S0= X-Gm-Message-State: AOJu0Yz0luA8nlyfa5gfC+MxGpY2T8AN1yiZo0DPy8t/n7PrajQoKpDe CuHmtL48lBNe8i7NZSETnkRoci5WOOnmc1gajIsJYqDZbd0I/owhLTb2lfycKCU= X-Google-Smtp-Source: AGHT+IGCvLrXWzySAlrNqbCAvh3eBYrqwRFPdz21iCBkv/nqIVi2SUvaRkJ9vc+Fe8iroSuxGmGXCw== X-Received: by 2002:a17:902:ce81:b0:1f7:2bed:226 with SMTP id d9443c01a7336-1fa23ecee77mr197498935ad.36.1719597871540; Fri, 28 Jun 2024 11:04:31 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:e53e:a53d:f473:181e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac11d8695sm18341165ad.109.2024.06.28.11.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 11:04:30 -0700 (PDT) Date: Fri, 28 Jun 2024 12:04:27 -0600 From: Mathieu Poirier To: =?iso-8859-1?Q?N=EDcolas_F=2E_R=2E_A=2E?= Prado Cc: Bjorn Andersson , Matthias Brugger , AngeloGioacchino Del Regno , Tzung-Bi Shih , kernel@collabora.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] remoteproc: mediatek: Don't attempt to remap l1tcm memory if missing Message-ID: References: <20240627-scp-invalid-resource-l1tcm-v1-1-7d221e6c495a@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240627-scp-invalid-resource-l1tcm-v1-1-7d221e6c495a@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_110433_297873_15013D13 X-CRM114-Status: GOOD ( 24.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jun 27, 2024 at 05:20:55PM -0400, Nícolas F. R. A. Prado wrote: > The current code doesn't check whether platform_get_resource_byname() > succeeded to get the l1tcm memory, which is optional, before attempting > to map it. This results in the following error message when it is > missing: > > mtk-scp 10500000.scp: error -EINVAL: invalid resource (null) > > Add a check so that the remapping is only attempted if the memory region > exists. This also allows to simplify the logic handling failure to > remap, since a failure then is always a failure. > > Fixes: ca23ecfdbd44 ("remoteproc/mediatek: support L1TCM") > Signed-off-by: Nícolas F. R. A. Prado > --- > drivers/remoteproc/mtk_scp.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c > index b885a9a041e4..b17757900cd7 100644 > --- a/drivers/remoteproc/mtk_scp.c > +++ b/drivers/remoteproc/mtk_scp.c > @@ -1344,14 +1344,12 @@ static int scp_probe(struct platform_device *pdev) > > /* l1tcm is an optional memory region */ > res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "l1tcm"); > - scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res); > - if (IS_ERR(scp_cluster->l1tcm_base)) { > - ret = PTR_ERR(scp_cluster->l1tcm_base); > - if (ret != -EINVAL) > - return dev_err_probe(dev, ret, "Failed to map l1tcm memory\n"); > + if (res) { > + scp_cluster->l1tcm_base = devm_ioremap_resource(dev, res); > + if (IS_ERR(scp_cluster->l1tcm_base)) > + return dev_err_probe(dev, PTR_ERR(scp_cluster->l1tcm_base), > + "Failed to map l1tcm memory\n"); > > - scp_cluster->l1tcm_base = NULL; > - } else { Much better - I have applied this patch. Regards, Mathieu > scp_cluster->l1tcm_size = resource_size(res); > scp_cluster->l1tcm_phys = res->start; > } > > --- > base-commit: 0fc4bfab2cd45f9acb86c4f04b5191e114e901ed > change-id: 20240627-scp-invalid-resource-l1tcm-9f7cf45c17e6 > > Best regards, > -- > Nícolas F. R. A. Prado >