From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 References: <20200304142628.8471-1-NShubin@topcon.com> <20200406113310.3041-1-nikita.shubin@maquefel.me> <20200406113310.3041-2-nikita.shubin@maquefel.me> <20200414164519.GA24061@xps15> <45761587100993@mail.yandex.ru> <20200417202653.00002500@maquefel.me> In-Reply-To: <20200417202653.00002500@maquefel.me> From: Mathieu Poirier Date: Fri, 17 Apr 2020 16:24:21 -0600 Message-ID: Subject: Re: [PATCH v2 1/3] remoteproc: imx_rproc: set pc on start Content-Type: text/plain; charset="UTF-8" To: Nikita Shubin Cc: Nikita Shubin , Ohad Ben-Cohen , Bjorn Andersson , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , "linux-remoteproc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" List-ID: On Fri, 17 Apr 2020 at 11:27, Nikita Shubin wrote: > > On Fri, 17 Apr 2020 11:01:22 -0600 > Mathieu Poirier wrote: > > > On Thu, 16 Apr 2020 at 23:40, wrote: > > > > > > Hi Mathieue, > > > > > > Hi Nikita, > > > > > > On Mon, Apr 06, 2020 at 02:33:08PM +0300, nikita.shubin@maquefel.me > > > wrote: > > > > > > In case elf file interrupt vector is not supposed to be at OCRAM_S, > > > it is needed to write elf entry point to OCRAM_S + 0x4, to boot M4 > > > firmware. > > > > > > Otherwise firmware located anywhere besides OCRAM_S won't boot. > > > > > > The firmware must set stack poiner as first instruction: > > > > > > Reset_Handler: > > > ldr sp, = __stack /* set stack pointer */ > > > > > > Signed-off-by: Nikita Shubin > > > > > > > > > The address in the SoB has to match what is found in the "From:" > > > field of the email header. Checkpatch is complaining about that, > > > something I would have expected to be fixed before sending this set > > > out. > > > > > > Noted and will be fixed. > > > > > > --- > > > drivers/remoteproc/imx_rproc.c | 16 +++++++++++++++- > > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/remoteproc/imx_rproc.c > > > b/drivers/remoteproc/imx_rproc.c index 3e72b6f38d4b..bebc58d0f711 > > > 100644 --- a/drivers/remoteproc/imx_rproc.c > > > +++ b/drivers/remoteproc/imx_rproc.c > > > @@ -45,6 +45,8 @@ > > > > > > #define IMX7D_RPROC_MEM_MAX 8 > > > > > > +#define IMX_BOOT_PC 0x4 > > > + > > > /** > > > * struct imx_rproc_mem - slim internal memory structure > > > * @cpu_addr: MPU virtual address of the memory region > > > @@ -85,6 +87,7 @@ struct imx_rproc { > > > const struct imx_rproc_dcfg *dcfg; > > > struct imx_rproc_mem mem[IMX7D_RPROC_MEM_MAX]; > > > struct clk *clk; > > > + void __iomem *bootreg; > > > }; > > > > > > static const struct imx_rproc_att imx_rproc_att_imx7d[] = { > > > @@ -162,11 +165,16 @@ static int imx_rproc_start(struct rproc > > > *rproc) struct device *dev = priv->dev; > > > int ret; > > > > > > + /* write entry point to program counter */ > > > + writel(rproc->bootaddr, priv->bootreg); > > > > > > > > > What happens on all the other IMX systems where this fix is not > > > needed? Will they continue to work properly? > > > > > > Yes, my bad, it is also needed for IMX6 (but even so i need to > > > study this topic more carefully), this should be applied > > > exclusively for imx7d for now, and if will be needed someone with > > > imx6 hardware to test on can extend this on imx6 also. > > > > > > > > > > > > > > > + > > > ret = regmap_update_bits(priv->regmap, dcfg->src_reg, > > > dcfg->src_mask, dcfg->src_start); > > > if (ret) > > > dev_err(dev, "Failed to enable M4!\n"); > > > > > > + dev_info(&rproc->dev, "Started from 0x%x\n", rproc->bootaddr); > > > + > > > return ret; > > > } > > > > > > @@ -182,6 +190,9 @@ static int imx_rproc_stop(struct rproc *rproc) > > > if (ret) > > > dev_err(dev, "Failed to stop M4!\n"); > > > > > > + /* clear entry points */ > > > + writel(0, priv->bootreg); > > > + > > > return ret; > > > } > > > > > > @@ -243,7 +254,8 @@ static void *imx_rproc_da_to_va(struct rproc > > > *rproc, u64 da, int len) static const struct rproc_ops > > > imx_rproc_ops = { .start = imx_rproc_start, > > > .stop = imx_rproc_stop, > > > - .da_to_va = imx_rproc_da_to_va, > > > + .da_to_va = imx_rproc_da_to_va, > > > + .get_boot_addr = rproc_elf_get_boot_addr, > > > > > > > > > How is this useful? Sure it will set rproc->bootaddr in > > > rproc_fw_boot() but what good does that do when it is invariably > > > set again in imx_rproc_start() ? > > > > > > The priv->bootreg is the address where we are writing Entry Point > > > and it is fixed, 0x04 address is translated to 0x00180004, so don't > > > quite understand you we are writing rproc->bootaddr into > > > priv->bootreg, not wiseversa. > > > > > > > What is your reason to set ops->get_boot_addr ? How does that help > > the work done in this patch? > > The reason is the following : > > remoteproc_core.c: > | rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > | rproc->bootaddr = rproc_get_boot_addr(rproc, fw); > > remoteproc_internal.h > | static inline > | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware > *fw) | { > | if (rproc->ops->get_boot_addr) > | return rproc->ops->get_boot_addr(rproc, fw); > | > | return 0; > | } And as I said above the value of rproc->bootaddr is set to priv->bootreg in imx_rproc_stop(). What am I missing? More over imx_rproc_ops doesn't have a ->load() function and as such rproc_alloc will set it to rproc_elf_get_boot_addr() > > > > > > > > > }; > > > > > > static int imx_rproc_addr_init(struct imx_rproc *priv, > > > @@ -360,6 +372,8 @@ static int imx_rproc_probe(struct > > > platform_device *pdev) goto err_put_rproc; > > > } > > > > > > + priv->bootreg = imx_rproc_da_to_va(rproc, IMX_BOOT_PC, > > > sizeof(u32)); + > > > /* > > > * clk for M4 block including memory. Should be > > > * enabled before .start for FW transfer. > > > -- > > > 2.25.1 > > > > 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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15966C2BB1D for ; Fri, 17 Apr 2020 22:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFC24221EA for ; Fri, 17 Apr 2020 22:24:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Spf98Qg5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728617AbgDQWYd (ORCPT ); Fri, 17 Apr 2020 18:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728496AbgDQWYd (ORCPT ); Fri, 17 Apr 2020 18:24:33 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 263A9C061A0F for ; Fri, 17 Apr 2020 15:24:33 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id e127so4096761iof.6 for ; Fri, 17 Apr 2020 15:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9l7ReVXML5iC1lUXKjwrOgZKOV8ZzgKkL7y7FQ7TRC8=; b=Spf98Qg5qFQCzvnqgZgRv9fmE2Syrwc7Gqbh4i98GT3U8W9nhHwgX5Fcoc//T54NMd 0uY892q8flmpGYSSbSgi5bH6fe3fDZ7klazcneNNR3pbC0X5zgLLwFCm4VfMXd5hZgos +8SamfzzVfSj/m1igwp6sMozIYa9LWyURM0yc30+WMlTJP2dN2pZHnBWatc+oBu6HXyN Eqfu5VFV6290Xm9etLyap+97UVMongeQ90ZfalwAGBQqKt0xKzYuiKRBxP5cBP4YiCx2 0LK61hzM0pcDfDj2SKcLvZxWrT+LWLhyCIUQUrftJOz0ZCi2pf8748pbsVL+kCKxU51d 9oXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9l7ReVXML5iC1lUXKjwrOgZKOV8ZzgKkL7y7FQ7TRC8=; b=iJQJTFd3WXO8k56ejc8R9EuD+Ky4nA7BidrM/uuZfHT+SC5lrnxD9Im+4f/fla3XYq jX1SZTTL+X5OEPG0P7vAB01t84lHUZa6m4N9d+dSUY/GEAknZ0FkJ2G6/jNLsgUyaD0s 6zPOlk2fa630URh3yIVJRLr5q2hHTza7xAZojYsT/36fLXXl0TCagELmEnS/1YxIWPco IhjGn1pxvUUZBnPmCDEQ+t2bXQAoLlyRGI6aj/YrIswU0922WMiIPEF4X1l+aURdh0kE BhVNHDH7JpzU7f9VrtW/80PWba263RkHRqLa+CTym51jp8EsDRfi8Tf9bf63cq1FoN66 1EpA== X-Gm-Message-State: AGi0PubzolX7/ZD1xWCUpZY5mP9ogfWbptxBlbEtrblOeweSOBU5Ubhh dPrZ94QsLzyNLNNH5chqH2OSMVFmvmadsq2RtF0yew== X-Google-Smtp-Source: APiQypL6PL6+MLLIpNc0SmvY24c0Q4ez5CT8xBF/CqHav+Y7obUoOyXH/xedbXEuqARaRaw8L9lptDwOz6Nj/dxncHY= X-Received: by 2002:a6b:8bd2:: with SMTP id n201mr5392033iod.131.1587162272197; Fri, 17 Apr 2020 15:24:32 -0700 (PDT) MIME-Version: 1.0 References: <20200304142628.8471-1-NShubin@topcon.com> <20200406113310.3041-1-nikita.shubin@maquefel.me> <20200406113310.3041-2-nikita.shubin@maquefel.me> <20200414164519.GA24061@xps15> <45761587100993@mail.yandex.ru> <20200417202653.00002500@maquefel.me> In-Reply-To: <20200417202653.00002500@maquefel.me> From: Mathieu Poirier Date: Fri, 17 Apr 2020 16:24:21 -0600 Message-ID: Subject: Re: [PATCH v2 1/3] remoteproc: imx_rproc: set pc on start To: Nikita Shubin Cc: Nikita Shubin , Ohad Ben-Cohen , Bjorn Andersson , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , "linux-remoteproc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Message-ID: <20200417222421.5l4qjD9nSazG4Y6OgSjRdNzjKwfgEW7uu4lotI9Q7zg@z> On Fri, 17 Apr 2020 at 11:27, Nikita Shubin wrote: > > On Fri, 17 Apr 2020 11:01:22 -0600 > Mathieu Poirier wrote: > > > On Thu, 16 Apr 2020 at 23:40, wrote: > > > > > > Hi Mathieue, > > > > > > Hi Nikita, > > > > > > On Mon, Apr 06, 2020 at 02:33:08PM +0300, nikita.shubin@maquefel.me > > > wrote: > > > > > > In case elf file interrupt vector is not supposed to be at OCRAM_S, > > > it is needed to write elf entry point to OCRAM_S + 0x4, to boot M4 > > > firmware. > > > > > > Otherwise firmware located anywhere besides OCRAM_S won't boot. > > > > > > The firmware must set stack poiner as first instruction: > > > > > > Reset_Handler: > > > ldr sp, = __stack /* set stack pointer */ > > > > > > Signed-off-by: Nikita Shubin > > > > > > > > > The address in the SoB has to match what is found in the "From:" > > > field of the email header. Checkpatch is complaining about that, > > > something I would have expected to be fixed before sending this set > > > out. > > > > > > Noted and will be fixed. > > > > > > --- > > > drivers/remoteproc/imx_rproc.c | 16 +++++++++++++++- > > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/remoteproc/imx_rproc.c > > > b/drivers/remoteproc/imx_rproc.c index 3e72b6f38d4b..bebc58d0f711 > > > 100644 --- a/drivers/remoteproc/imx_rproc.c > > > +++ b/drivers/remoteproc/imx_rproc.c > > > @@ -45,6 +45,8 @@ > > > > > > #define IMX7D_RPROC_MEM_MAX 8 > > > > > > +#define IMX_BOOT_PC 0x4 > > > + > > > /** > > > * struct imx_rproc_mem - slim internal memory structure > > > * @cpu_addr: MPU virtual address of the memory region > > > @@ -85,6 +87,7 @@ struct imx_rproc { > > > const struct imx_rproc_dcfg *dcfg; > > > struct imx_rproc_mem mem[IMX7D_RPROC_MEM_MAX]; > > > struct clk *clk; > > > + void __iomem *bootreg; > > > }; > > > > > > static const struct imx_rproc_att imx_rproc_att_imx7d[] = { > > > @@ -162,11 +165,16 @@ static int imx_rproc_start(struct rproc > > > *rproc) struct device *dev = priv->dev; > > > int ret; > > > > > > + /* write entry point to program counter */ > > > + writel(rproc->bootaddr, priv->bootreg); > > > > > > > > > What happens on all the other IMX systems where this fix is not > > > needed? Will they continue to work properly? > > > > > > Yes, my bad, it is also needed for IMX6 (but even so i need to > > > study this topic more carefully), this should be applied > > > exclusively for imx7d for now, and if will be needed someone with > > > imx6 hardware to test on can extend this on imx6 also. > > > > > > > > > > > > > > > + > > > ret = regmap_update_bits(priv->regmap, dcfg->src_reg, > > > dcfg->src_mask, dcfg->src_start); > > > if (ret) > > > dev_err(dev, "Failed to enable M4!\n"); > > > > > > + dev_info(&rproc->dev, "Started from 0x%x\n", rproc->bootaddr); > > > + > > > return ret; > > > } > > > > > > @@ -182,6 +190,9 @@ static int imx_rproc_stop(struct rproc *rproc) > > > if (ret) > > > dev_err(dev, "Failed to stop M4!\n"); > > > > > > + /* clear entry points */ > > > + writel(0, priv->bootreg); > > > + > > > return ret; > > > } > > > > > > @@ -243,7 +254,8 @@ static void *imx_rproc_da_to_va(struct rproc > > > *rproc, u64 da, int len) static const struct rproc_ops > > > imx_rproc_ops = { .start = imx_rproc_start, > > > .stop = imx_rproc_stop, > > > - .da_to_va = imx_rproc_da_to_va, > > > + .da_to_va = imx_rproc_da_to_va, > > > + .get_boot_addr = rproc_elf_get_boot_addr, > > > > > > > > > How is this useful? Sure it will set rproc->bootaddr in > > > rproc_fw_boot() but what good does that do when it is invariably > > > set again in imx_rproc_start() ? > > > > > > The priv->bootreg is the address where we are writing Entry Point > > > and it is fixed, 0x04 address is translated to 0x00180004, so don't > > > quite understand you we are writing rproc->bootaddr into > > > priv->bootreg, not wiseversa. > > > > > > > What is your reason to set ops->get_boot_addr ? How does that help > > the work done in this patch? > > The reason is the following : > > remoteproc_core.c: > | rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > | rproc->bootaddr = rproc_get_boot_addr(rproc, fw); > > remoteproc_internal.h > | static inline > | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware > *fw) | { > | if (rproc->ops->get_boot_addr) > | return rproc->ops->get_boot_addr(rproc, fw); > | > | return 0; > | } And as I said above the value of rproc->bootaddr is set to priv->bootreg in imx_rproc_stop(). What am I missing? More over imx_rproc_ops doesn't have a ->load() function and as such rproc_alloc will set it to rproc_elf_get_boot_addr() > > > > > > > > > }; > > > > > > static int imx_rproc_addr_init(struct imx_rproc *priv, > > > @@ -360,6 +372,8 @@ static int imx_rproc_probe(struct > > > platform_device *pdev) goto err_put_rproc; > > > } > > > > > > + priv->bootreg = imx_rproc_da_to_va(rproc, IMX_BOOT_PC, > > > sizeof(u32)); + > > > /* > > > * clk for M4 block including memory. Should be > > > * enabled before .start for FW transfer. > > > -- > > > 2.25.1 > > > > 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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7CA3C2BB1D for ; Fri, 17 Apr 2020 22:24:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 99B7E20776 for ; Fri, 17 Apr 2020 22:24:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IJddAVK5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Spf98Qg5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99B7E20776 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+kicZ97oaU6TsShIDwmAG8A7JeiYVekefYnNUoZ3Lak=; b=IJddAVK5DK/DYf IHukTvC/8Oc8JcwKqGvgUEvFB7VS/0PLObVsLcoWGGQMqrLtfLoJgvtsl9WLYgYmOcf6HonwH9/VC 9Qob/o7iZBCXSH8A28Fqm5IJyclvRqyKLYomiYFdXdsJ64ureOvqn3+uiBoCHLRjDk8/jS/4OlRyb VDGc3LYKqyroY4SI/7ps3B/xthw6AXbtRXV+R+WsqRwB87A6Ub4006r9VOOMod0I+1i3U1WmcoLfW eRbHX6F5VyqHIwqFRg9lgJmYa5BosHJ2EgYu1Sk9YPin6rtM2RC44MYuICalNe7cMb5D4UDqExyV0 aVgsTXthSEH/uXghMNnw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPZPb-0002rw-LN; Fri, 17 Apr 2020 22:24:39 +0000 Received: from mail-io1-xd43.google.com ([2607:f8b0:4864:20::d43]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPZPW-0002pb-8t for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 22:24:37 +0000 Received: by mail-io1-xd43.google.com with SMTP id o127so4137935iof.0 for ; Fri, 17 Apr 2020 15:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9l7ReVXML5iC1lUXKjwrOgZKOV8ZzgKkL7y7FQ7TRC8=; b=Spf98Qg5qFQCzvnqgZgRv9fmE2Syrwc7Gqbh4i98GT3U8W9nhHwgX5Fcoc//T54NMd 0uY892q8flmpGYSSbSgi5bH6fe3fDZ7klazcneNNR3pbC0X5zgLLwFCm4VfMXd5hZgos +8SamfzzVfSj/m1igwp6sMozIYa9LWyURM0yc30+WMlTJP2dN2pZHnBWatc+oBu6HXyN Eqfu5VFV6290Xm9etLyap+97UVMongeQ90ZfalwAGBQqKt0xKzYuiKRBxP5cBP4YiCx2 0LK61hzM0pcDfDj2SKcLvZxWrT+LWLhyCIUQUrftJOz0ZCi2pf8748pbsVL+kCKxU51d 9oXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9l7ReVXML5iC1lUXKjwrOgZKOV8ZzgKkL7y7FQ7TRC8=; b=llPXudN+M/wrd0Qieaa6FwNUuO3M/G06l+o4RkA7/DHnP9q+32fNUT/2RCdBOGlxMn jo5HjeZIsWUQfWBnNynSYa6wz/bE+820fTKriY2EYPVOxJRiArPMLcrfxMho/aIrBRJ8 jq2SFon/ZLnZ9JbRXO5tVBrVzyURHiD3fK70lv2iDIO8dSgA+xjYOciIcB/fxvV5LeVb mPqSzG/tspx6vPHF9ZOrDqiZXjVeKTLqYZnqoiH6n9vtYeaC+ii+/yDfZy4eJ8IbXK1v wn99R13b2FzITwlbGng7o7pHsa/ruay4/9a0cHPbEQv6ZrxvR9SYsgPdtyX/w++q22LO +ong== X-Gm-Message-State: AGi0PuYPOxopHuXmV85+exYyg4VU+TmP9NbIGDv3jXeCQgdILkeCqS1Z LgD96jXQtrl427Lxvm4XRm//3XqZo0uDNXC9A4F32A== X-Google-Smtp-Source: APiQypL6PL6+MLLIpNc0SmvY24c0Q4ez5CT8xBF/CqHav+Y7obUoOyXH/xedbXEuqARaRaw8L9lptDwOz6Nj/dxncHY= X-Received: by 2002:a6b:8bd2:: with SMTP id n201mr5392033iod.131.1587162272197; Fri, 17 Apr 2020 15:24:32 -0700 (PDT) MIME-Version: 1.0 References: <20200304142628.8471-1-NShubin@topcon.com> <20200406113310.3041-1-nikita.shubin@maquefel.me> <20200406113310.3041-2-nikita.shubin@maquefel.me> <20200414164519.GA24061@xps15> <45761587100993@mail.yandex.ru> <20200417202653.00002500@maquefel.me> In-Reply-To: <20200417202653.00002500@maquefel.me> From: Mathieu Poirier Date: Fri, 17 Apr 2020 16:24:21 -0600 Message-ID: Subject: Re: [PATCH v2 1/3] remoteproc: imx_rproc: set pc on start To: Nikita Shubin X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_152434_356858_63C3BDC5 X-CRM114-Status: GOOD ( 31.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ohad Ben-Cohen , Fabio Estevam , Nikita Shubin , Sascha Hauer , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Bjorn Andersson , NXP Linux Team , Pengutronix Kernel Team , Shawn Guo , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 17 Apr 2020 at 11:27, Nikita Shubin wrote: > > On Fri, 17 Apr 2020 11:01:22 -0600 > Mathieu Poirier wrote: > > > On Thu, 16 Apr 2020 at 23:40, wrote: > > > > > > Hi Mathieue, > > > > > > Hi Nikita, > > > > > > On Mon, Apr 06, 2020 at 02:33:08PM +0300, nikita.shubin@maquefel.me > > > wrote: > > > > > > In case elf file interrupt vector is not supposed to be at OCRAM_S, > > > it is needed to write elf entry point to OCRAM_S + 0x4, to boot M4 > > > firmware. > > > > > > Otherwise firmware located anywhere besides OCRAM_S won't boot. > > > > > > The firmware must set stack poiner as first instruction: > > > > > > Reset_Handler: > > > ldr sp, = __stack /* set stack pointer */ > > > > > > Signed-off-by: Nikita Shubin > > > > > > > > > The address in the SoB has to match what is found in the "From:" > > > field of the email header. Checkpatch is complaining about that, > > > something I would have expected to be fixed before sending this set > > > out. > > > > > > Noted and will be fixed. > > > > > > --- > > > drivers/remoteproc/imx_rproc.c | 16 +++++++++++++++- > > > 1 file changed, 15 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/remoteproc/imx_rproc.c > > > b/drivers/remoteproc/imx_rproc.c index 3e72b6f38d4b..bebc58d0f711 > > > 100644 --- a/drivers/remoteproc/imx_rproc.c > > > +++ b/drivers/remoteproc/imx_rproc.c > > > @@ -45,6 +45,8 @@ > > > > > > #define IMX7D_RPROC_MEM_MAX 8 > > > > > > +#define IMX_BOOT_PC 0x4 > > > + > > > /** > > > * struct imx_rproc_mem - slim internal memory structure > > > * @cpu_addr: MPU virtual address of the memory region > > > @@ -85,6 +87,7 @@ struct imx_rproc { > > > const struct imx_rproc_dcfg *dcfg; > > > struct imx_rproc_mem mem[IMX7D_RPROC_MEM_MAX]; > > > struct clk *clk; > > > + void __iomem *bootreg; > > > }; > > > > > > static const struct imx_rproc_att imx_rproc_att_imx7d[] = { > > > @@ -162,11 +165,16 @@ static int imx_rproc_start(struct rproc > > > *rproc) struct device *dev = priv->dev; > > > int ret; > > > > > > + /* write entry point to program counter */ > > > + writel(rproc->bootaddr, priv->bootreg); > > > > > > > > > What happens on all the other IMX systems where this fix is not > > > needed? Will they continue to work properly? > > > > > > Yes, my bad, it is also needed for IMX6 (but even so i need to > > > study this topic more carefully), this should be applied > > > exclusively for imx7d for now, and if will be needed someone with > > > imx6 hardware to test on can extend this on imx6 also. > > > > > > > > > > > > > > > + > > > ret = regmap_update_bits(priv->regmap, dcfg->src_reg, > > > dcfg->src_mask, dcfg->src_start); > > > if (ret) > > > dev_err(dev, "Failed to enable M4!\n"); > > > > > > + dev_info(&rproc->dev, "Started from 0x%x\n", rproc->bootaddr); > > > + > > > return ret; > > > } > > > > > > @@ -182,6 +190,9 @@ static int imx_rproc_stop(struct rproc *rproc) > > > if (ret) > > > dev_err(dev, "Failed to stop M4!\n"); > > > > > > + /* clear entry points */ > > > + writel(0, priv->bootreg); > > > + > > > return ret; > > > } > > > > > > @@ -243,7 +254,8 @@ static void *imx_rproc_da_to_va(struct rproc > > > *rproc, u64 da, int len) static const struct rproc_ops > > > imx_rproc_ops = { .start = imx_rproc_start, > > > .stop = imx_rproc_stop, > > > - .da_to_va = imx_rproc_da_to_va, > > > + .da_to_va = imx_rproc_da_to_va, > > > + .get_boot_addr = rproc_elf_get_boot_addr, > > > > > > > > > How is this useful? Sure it will set rproc->bootaddr in > > > rproc_fw_boot() but what good does that do when it is invariably > > > set again in imx_rproc_start() ? > > > > > > The priv->bootreg is the address where we are writing Entry Point > > > and it is fixed, 0x04 address is translated to 0x00180004, so don't > > > quite understand you we are writing rproc->bootaddr into > > > priv->bootreg, not wiseversa. > > > > > > > What is your reason to set ops->get_boot_addr ? How does that help > > the work done in this patch? > > The reason is the following : > > remoteproc_core.c: > | rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) > | rproc->bootaddr = rproc_get_boot_addr(rproc, fw); > > remoteproc_internal.h > | static inline > | u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware > *fw) | { > | if (rproc->ops->get_boot_addr) > | return rproc->ops->get_boot_addr(rproc, fw); > | > | return 0; > | } And as I said above the value of rproc->bootaddr is set to priv->bootreg in imx_rproc_stop(). What am I missing? More over imx_rproc_ops doesn't have a ->load() function and as such rproc_alloc will set it to rproc_elf_get_boot_addr() > > > > > > > > > }; > > > > > > static int imx_rproc_addr_init(struct imx_rproc *priv, > > > @@ -360,6 +372,8 @@ static int imx_rproc_probe(struct > > > platform_device *pdev) goto err_put_rproc; > > > } > > > > > > + priv->bootreg = imx_rproc_da_to_va(rproc, IMX_BOOT_PC, > > > sizeof(u32)); + > > > /* > > > * clk for M4 block including memory. Should be > > > * enabled before .start for FW transfer. > > > -- > > > 2.25.1 > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel