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 9ABB4C636D4 for ; Mon, 13 Feb 2023 18:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To: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=1ri4EcXbHJ2qdsQYtIfbLRzzUKYMXV7S5ftLcIMZ/fU=; b=r3wdjiS0JYp7nZ JT2Kf4lXk+PZ3/E2DugrzX5ZD+yDZs2LZvBumRFm57spFq0vAs5mAz5SCeoh2PdVJBrDPTD/IqRWI bfnb1vkRqx/oI9LSBy2ZSpDvXSqNx53bfpbRUMVRjfZV3u9MyWMJugbhqA3XkJHEBXyMi1PaqGR0m bpMFETjhK+uC+0MY1zDNpFZzbmuidQHqSefM6gpMHZiYv5oILAhLuUbx45AFHukLQevGwWPmx23F/ V9b81rLqPTWTY0ywP0qGFsnjMLzMyh0Fn+vOwwnnsrWg4b608AGpS0nDihbKnnSQlL5n/iAXCXcIP C8nTM08zJYQ8yAczbmdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRdEC-00Fnsd-DU; Mon, 13 Feb 2023 18:07:00 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pRdCM-00Fmkt-Fr for linux-arm-kernel@lists.infradead.org; Mon, 13 Feb 2023 18:05:08 +0000 Received: by mail-pl1-x635.google.com with SMTP id m2so14330628plg.4 for ; Mon, 13 Feb 2023 10:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gp01G0BnFM3UtiZCCxzyTfWZR8Wx0j9sIGOAAei1oMU=; b=mlNWBi4qWOmt9CWXPhLTyfsFtxOYE4aUhkT7NmX8aiwyLhuI/5LKhxAUJ+I+/KaNuP nm/EYaqSF3u/oIgBNxcS2Y8oc3b8NS2fanszcj32o2kE1mBcfiYKKqyb0ZmNadik5/50 JpRAWTdNsaTje/7/HECRCwtzdORJvUq134+BFS42xlwkLL+yDQ1bTqdXgBa80CSOtjEw KAlN5Et1DQM6eIygJc08jb8CMILZu+XH6wnPNDuZrHuZPCzrOCi6PkGz6iAq0PMF/Cam cPP2Lro0A1zpfoN9WgaUUSvM/5NdZvYArlAGr577kURNoBwrG6UCrRLt5oz3/LdUe2Nt aLLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to: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=gp01G0BnFM3UtiZCCxzyTfWZR8Wx0j9sIGOAAei1oMU=; b=h/SHkuzJQWY7qFIQ7E+lJI2yJUxIBd2+GKoG+6NVJ6TwXhYzWnBvdrsKqpTt5G87yy LkY2xe6MrgMq66u03ztM9hL7Nqh/1N62DEZyZIrs3LOWrYtePYLX20BpU+LvjUV9e6Ne lcmdesxI+FqFgdfLZTEJa9Fox2KilS1zesPmpvJIGB73Ih7Zej4jmx0ZySlo21+orSuY JyU/sygcVpJDEJPF0V+GNYocxTWNr33/tUHieqo0mGZIZ/eE3RmpOcehFXCZrP+ODizR bksIXkSTzwbQwnZ2c5Z44EkIawSXxwnafT+CaFsH5gerQq2BT5TtjH1/L333V7LzIL2g 1QBg== X-Gm-Message-State: AO0yUKWd81y55gSfIaYfs7LO/n6v2hIaBr41Vo7hoUrav5dkViA1MVVp 6DKAoqgV2VISHlo1Q+OA7x8oww== X-Google-Smtp-Source: AK7set+Oe+Z/pGux9QGelWq+eQYgY04H3vqJ9vxdOS+0Ac1mT841bzismegHoIlBb0yW8bwOsbUPrw== X-Received: by 2002:a17:902:e193:b0:19a:9890:eac6 with SMTP id y19-20020a170902e19300b0019a9890eac6mr4169728pla.24.1676311501634; Mon, 13 Feb 2023 10:05:01 -0800 (PST) Received: from p14s ([2604:3d09:148c:c800:8b5:7925:cf2a:8bac]) by smtp.gmail.com with ESMTPSA id k19-20020a170902761300b0019a87ede846sm4435273pll.285.2023.02.13.10.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 10:05:01 -0800 (PST) Date: Mon, 13 Feb 2023 11:04:58 -0700 From: Mathieu Poirier To: Peng Fan Cc: "Peng Fan (OSS)" , "andersson@kernel.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "arnaud.pouliquen@foss.st.com" , "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "linux-remoteproc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V2 5/6] remoteproc: imx_rproc: set Cortex-M stack/pc to TCML Message-ID: <20230213180458.GB310433@p14s> References: <20230127092246.1470865-1-peng.fan@oss.nxp.com> <20230127092246.1470865-6-peng.fan@oss.nxp.com> <20230202215629.GC1147631@p14s> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230213_100506_634974_83EB3100 X-CRM114-Status: GOOD ( 37.73 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Feb 03, 2023 at 12:04:27AM +0000, Peng Fan wrote: > > Subject: Re: [PATCH V2 5/6] remoteproc: imx_rproc: set Cortex-M stack/pc > > to TCML > > > > On Fri, Jan 27, 2023 at 05:22:45PM +0800, Peng Fan (OSS) wrote: > > > From: Peng Fan > > > > > > The i.MX8M Cortex-M core not has ROM. It has a requirement is the > > > stack, pc value should be set in address 0 and 4 from the view of > > > itself. From Cortex-A core view, the region is at TCML start address. > > > > > > The stack and pc value are the first two words stored in section > > > ".interrupts" of the firmware, and the section is the first section in > > > the firmware. > > > > > > When the firmware is built to run in TCML, there is no issue, because > > > when copying elf segments, the first two words are copied to TCML also. > > > > > > However when the firmware is built ro run in DDR, the first two words > > > are not copied to TCML start address. > > > > > > This patch is to find the ".interrupts" section, read out the first > > > two words and write to TCML start address at offset 0 and 4. > > > > > > Signed-off-by: Peng Fan > > > --- > > > drivers/remoteproc/imx_rproc.c | 37 > > > +++++++++++++++++++++++++++++++++- > > > 1 file changed, 36 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/remoteproc/imx_rproc.c > > > b/drivers/remoteproc/imx_rproc.c index 295e0e0e869a..f5ee0c9bb09d > > > 100644 > > > --- a/drivers/remoteproc/imx_rproc.c > > > +++ b/drivers/remoteproc/imx_rproc.c > > > @@ -7,6 +7,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -23,6 +24,7 @@ > > > #include > > > > > > #include "imx_rproc.h" > > > +#include "remoteproc_elf_helpers.h" > > > #include "remoteproc_internal.h" > > > > > > #define IMX7D_SRC_SCR 0x0C > > > @@ -634,6 +636,39 @@ static struct resource_table > > *imx_rproc_get_loaded_rsc_table(struct rproc *rproc > > > return (struct resource_table __force *)priv->rsc_table; } > > > > > > +static u64 imx_rproc_get_boot_addr(struct rproc *rproc, const struct > > > +firmware *fw) { > > > + struct imx_rproc *priv = rproc->priv; > > > + const u8 *elf_data = (void *)fw->data; > > > + u8 class = fw_elf_get_class(fw); > > > + u64 bootaddr = rproc_elf_get_boot_addr(rproc, fw); > > > + const void *shdr; > > > + void __iomem *va; > > > + u64 sh_addr, offset; > > > + > > > + if (priv->dcfg->devtype == IMX_RPROC_IMX8M) { > > > + /* > > > + * i.MX8M Cortex-M requires [stack, pc] be put in address > > > + * [0, 4], so the da address is 0, size is 8 words. > > > + */ > > > + va = (__force void __iomem *)rproc_da_to_va(rproc, 0, 8, > > NULL); > > > + shdr = rproc_elf_find_shdr(rproc, fw, ".interrupts"); > > > + if (!shdr || !va) > > > + return bootaddr; > > > + sh_addr = elf_shdr_get_sh_addr(class, shdr); > > > > This isn't used - why is it still there? > > will drop it. > > > > > > + offset = elf_shdr_get_sh_offset(class, shdr); > > > + > > > + /* > > > + * Write stack, pc to TCML start address. The TCML region > > > + * is marked with ATT_IOMEM, so use writel. > > > + */ > > > + writel(*(u32 *)(elf_data + offset), va); > > > + writel(*(u32 *)(elf_data + offset + 4), va + 4); > > > > Here you are writing 2 words at address 0x0 and 2 words at address 0x4. > > Why are you saying the size is 8 words in the comment above? > > Typo. I should mean 8 bytes. > How can I trust the code in this patchset when the "typo" is so obvious and found in the comment above and 4 times in the changelog? > Thanks, > Peng. > > > > > > + } > > > + > > > + return bootaddr; > > > +} > > > + > > > static const struct rproc_ops imx_rproc_ops = { > > > .prepare = imx_rproc_prepare, > > > .attach = imx_rproc_attach, > > > @@ -647,7 +682,7 @@ static const struct rproc_ops imx_rproc_ops = { > > > .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, > > > .get_loaded_rsc_table = imx_rproc_get_loaded_rsc_table, > > > .sanity_check = rproc_elf_sanity_check, > > > - .get_boot_addr = rproc_elf_get_boot_addr, > > > + .get_boot_addr = imx_rproc_get_boot_addr, > > > }; > > > > > > static int imx_rproc_addr_init(struct imx_rproc *priv, > > > -- > > > 2.37.1 > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel