Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp597938pxb; Thu, 14 Jan 2021 13:41:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDzqFOvfQ+nEhmc7TUKitwn1PvmFmiwZV/ytaKizYYJbOZlnfS74az4q+2BnHQ59aXPtIU X-Received: by 2002:a17:906:fa9a:: with SMTP id lt26mr6789772ejb.439.1610660498747; Thu, 14 Jan 2021 13:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610660498; cv=none; d=google.com; s=arc-20160816; b=dlajgmO6VfracrznM6S14sm563uB3dn1z61gksx5NWOlQ5bbTOCT7/9eZ3Zrafn2wd jFIBu8FvIQqaLUqtX0/oDnHCb7kDk7jed0mOa/D8x00ZadKvm2ghRlYRsGFRKYry3r6i jfOiMIsDJ19r7akfIbnPu1Hi9f5ux5khWXlDZTr5EdsvLOH6VOCzRsdvB4nAn79mT3IG 5h3FqzvhClt6UHIqWOCjZs8+aTdJefZb+ad1UhbuN1t0tn3KYUXb+BckmxqTIdZsq58b 40fIGmjMb5hp5Cpt47i0BYW+0YhQ/MkeQbSboeO1d0x+Q9AEoZOHsQYJRMH/ok5HTJn8 nm/A== 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=M25f2Urs67ewtW9Uctz0Ma+cdGhcJesg41jWdEvlv+A=; b=ZePWv4y0W9KC98pPmRyaNJGzy0PqxW69f1JpYVWha/Mwr9G+YgDPrMRFUIDNmxDIDT VS9+ayRa+qEJW8YbO4RftuVtwVRn7Ml4aMWldo17KTVliT6x10N+FBICb3BsC4M+qbQp Al7nDfSrPYR3kSd3iqqZCfZZ7BbN9M7G5ioAltj0QLE5VpNSUUyQR7fWDiB2J2fJ3Whz Ohu/QeokRF7tLi3bF/nJ/ItO5lh+zAJO3JQ+aONXcgtFlIIPEMYUzNUH8vIK8m1C4wjx YiZwAe4Z1GTGWjllBMr6+UQFbaGlSw6cmzxAoy1mVyoc4yF01NcgP8WEvLnFKlYah3Vx 2ctw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uqmdvUhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f8si2812453ejr.517.2021.01.14.13.41.15; Thu, 14 Jan 2021 13:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uqmdvUhe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729671AbhANViv (ORCPT + 99 others); Thu, 14 Jan 2021 16:38:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728533AbhANVis (ORCPT ); Thu, 14 Jan 2021 16:38:48 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 451E2C0613D3 for ; Thu, 14 Jan 2021 13:38:08 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id x126so4149417pfc.7 for ; Thu, 14 Jan 2021 13:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=M25f2Urs67ewtW9Uctz0Ma+cdGhcJesg41jWdEvlv+A=; b=uqmdvUhePZHvP+/tQJW6RM3qU8CZvdbDhob1c2l0dpQjwtQecqMjOumtUyjdUNBKCm IIBgLOuSPwwjDKTn+AuU/brQuU9JQK3X7iaD4rGlVnyk3okjqE3ydvwkI85MsVoGs3or ua7PXg6Vvj5+qBChVRxteAzc98FwM0YG/21w9V9Naq9y6ODjy8aLxPp5ES4YwVb5om9H SXmdAbHIjeUYLha7KX7HntlGiDcZhbNufugBp7jVoy/VXZKQl1xzZGrXf6KbwcA6396D twI9GzCdChg1W3bOXIBfIE0mFhT/6NK/MufyeCEVGGxCSs3cZ0YKugzZp8YYQ2xMyMg8 mlqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=M25f2Urs67ewtW9Uctz0Ma+cdGhcJesg41jWdEvlv+A=; b=j0bkpuAwZJtPrAsDfDGOYx9hv5kgw9oh2BaY3j6PnrtOIfHWCzWVr4E3JOVyORjBks a7t2ynezzKnB3elyPEnLdw0jdG5ImLtNgWHqnHedIaRH6lR8VTFd8+mekLNM9xfeJ8q9 y6gmTQNhUhkH/7NKccAqGFcwJurT7JMa3dVWa7F0GhBMl9ZIYffCVjpatcQYjqBAx5bz yOe7aEpJPmKrPe4h8Sa7pD45+WrVXYEMMoTzMAGIqwatlIfzAyx5NLIN2itsKwNaApK7 OenrybmlMG1kvnFS1R3h7AOyuQHI9XV46ir/lXpzHiAOoa58x1NC799Y1L4X0OE+IYXL Zv3Q== X-Gm-Message-State: AOAM5338vE+o+aGwig8tOxxTrSTWJazRiNq2cfrcc4kalPSFZTEpJoZe jYd6p67AyZYhnL1WJ8Fe2oqjWw== X-Received: by 2002:a63:dc56:: with SMTP id f22mr3631737pgj.106.1610660287861; Thu, 14 Jan 2021 13:38:07 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id b22sm5955823pfo.163.2021.01.14.13.38.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 13:38:06 -0800 (PST) Date: Thu, 14 Jan 2021 14:38:04 -0700 From: Mathieu Poirier To: peng.fan@nxp.com Cc: ohad@wizery.com, bjorn.andersson@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, paul@crapouillou.net, matthias.bgg@gmail.com, agross@kernel.org, patrice.chotard@st.com Subject: Re: [PATCH V6 07/10] remoteproc: imx_rproc: add i.MX specific parse fw hook Message-ID: <20210114213804.GE255481@xps15> References: <1610444359-1857-1-git-send-email-peng.fan@nxp.com> <1610444359-1857-8-git-send-email-peng.fan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1610444359-1857-8-git-send-email-peng.fan@nxp.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 05:39:16PM +0800, peng.fan@nxp.com wrote: > From: Peng Fan > > The hook is used to parse memory-regions and load resource table > from the address the remote processor published. > > Signed-off-by: Peng Fan > Reviewed-by: Richard Zhu > Reviewed-by: Mathieu Poirier > --- > drivers/remoteproc/imx_rproc.c | 93 ++++++++++++++++++++++++++++++++++ > 1 file changed, 93 insertions(+) > > diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c > index 47fc1d06be6a..3c0075dc1787 100644 > --- a/drivers/remoteproc/imx_rproc.c > +++ b/drivers/remoteproc/imx_rproc.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -241,10 +242,102 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *i > return va; > } > > +static int imx_rproc_mem_alloc(struct rproc *rproc, > + struct rproc_mem_entry *mem) > +{ > + struct device *dev = rproc->dev.parent; > + void *va; > + > + dev_dbg(dev, "map memory: %p+%zx\n", &mem->dma, mem->len); > + va = ioremap_wc(mem->dma, mem->len); > + if (IS_ERR_OR_NULL(va)) { > + dev_err(dev, "Unable to map memory region: %p+%zx\n", > + &mem->dma, mem->len); > + return -ENOMEM; > + } > + > + /* Update memory entry va */ > + mem->va = va; > + > + return 0; > +} > + > +static int imx_rproc_mem_release(struct rproc *rproc, > + struct rproc_mem_entry *mem) > +{ > + dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma); > + iounmap(mem->va); > + > + return 0; > +} > + > +static int imx_rproc_parse_memory_regions(struct rproc *rproc) > +{ > + struct imx_rproc *priv = rproc->priv; > + struct device_node *np = priv->dev->of_node; > + struct of_phandle_iterator it; > + struct rproc_mem_entry *mem; > + struct reserved_mem *rmem; > + u32 da; > + > + /* Register associated reserved memory regions */ > + of_phandle_iterator_init(&it, np, "memory-region", NULL, 0); > + while (of_phandle_iterator_next(&it) == 0) { > + /* > + * Ignore the first memory region which will be used vdev buffer. > + * No need to do extra handlings, rproc_add_virtio_dev will handle it. > + */ > + if (!strcmp(it.node->name, "vdevbuffer")) Because you are doing a V8, please use "vdev0buffer" and make the change in the .yaml file. > + continue; > + > + rmem = of_reserved_mem_lookup(it.node); > + if (!rmem) { > + dev_err(priv->dev, "unable to acquire memory-region\n"); > + return -EINVAL; > + } > + > + /* No need to translate pa to da, i.MX use same map */ > + da = rmem->base; > + > + /* Register memory region */ > + mem = rproc_mem_entry_init(priv->dev, NULL, (dma_addr_t)rmem->base, rmem->size, da, > + imx_rproc_mem_alloc, imx_rproc_mem_release, > + it.node->name); > + > + if (mem) > + rproc_coredump_add_segment(rproc, da, rmem->size); > + else > + return -ENOMEM; > + > + rproc_add_carveout(rproc, mem); > + } > + > + return 0; > +} > + > +static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) > +{ > + int ret = imx_rproc_parse_memory_regions(rproc); > + > + if (ret) > + return ret; > + > + ret = rproc_elf_load_rsc_table(rproc, fw); > + if (ret) > + dev_info(&rproc->dev, "No resource table in elf\n"); > + > + return 0; > +} > + > static const struct rproc_ops imx_rproc_ops = { > .start = imx_rproc_start, > .stop = imx_rproc_stop, > .da_to_va = imx_rproc_da_to_va, > + .load = rproc_elf_load_segments, > + .parse_fw = imx_rproc_parse_fw, > + .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, > + .sanity_check = rproc_elf_sanity_check, > + .get_boot_addr = rproc_elf_get_boot_addr, > }; > > static int imx_rproc_addr_init(struct imx_rproc *priv, > -- > 2.28.0 >