Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp127161pxb; Thu, 14 Jan 2021 21:45:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrybwWIidiILAqD7xHSaSkKgUl20WfGXSltABlDpmppiX6mi71B8mrjRVL/ef+ytGmwIsv X-Received: by 2002:a17:906:4a14:: with SMTP id w20mr7974536eju.192.1610689551019; Thu, 14 Jan 2021 21:45:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1610689551; cv=pass; d=google.com; s=arc-20160816; b=s6YNl7Mi7aNBCUP4s4YYeNQoQMluezMYEEWmvRrIK3l0qdkpRfhLa7J9zcdQmHzo/t 4GwScJsiwq42GRJNQVx0o9CMtE1plSgjGrU22Z/ZKcXCxGWxRGMLsYbONmIgObP683+8 dDQBWGpaSO4M1AAZB5+fPmQHw2LRywVQUda76tM7OuMi1qLO9N57e3knS6hmpA7E9il4 6Cch/zvPkL2kaA26lo+THWT/SqytZsl7c2PV5+bJg/jaN7l8wpA52k2oAUJVoF8amikF FIffFQ2shWixecHojM6GyiumMBFtkEITXsNbojxaKZoQFsBy7Vtz+bWdDSmC0sMaKwvN P6Cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=wyKnZLsHQ9SMvk4MA/sxEr28E38xHlLBaZZrScAOz3k=; b=Po7v6DuurC9JyxnsC32OBqaXfx5ICYD/eAEvRFh87zVKZcR49cuBFPLuwRS2PFznye uw4EKXdxw3x7bK3DJX95HIE1mMXoqMaQvsq5h3L8dv1YGVWv8b0+PP8exyOTaVZdBKHu 8jBcFhdLdvXABczr2KNL2YVHBtKMy7KEA8lj37duFtlXz2C3s39/6EsTHwQiGVxci4km ZcL6qyXjhDZNlKPKFFKQDdZVY3CVw+dEkDwsJxqxL9nAY0Px0nrZsnwR3033VVFg5XxA teqe6ZNFMcFlOQQtFg6ueI+McbDkGIPDfzaD0B0b4ZCZIW9gDgHIbMFUpIRkCMlc1QKr TJfg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Dae6rgUP; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si3532352edv.178.2021.01.14.21.45.27; Thu, 14 Jan 2021 21:45:51 -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=@nxp.com header.s=selector2 header.b=Dae6rgUP; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732496AbhAOD3R (ORCPT + 99 others); Thu, 14 Jan 2021 22:29:17 -0500 Received: from mail-eopbgr40074.outbound.protection.outlook.com ([40.107.4.74]:8415 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732483AbhAOD3Q (ORCPT ); Thu, 14 Jan 2021 22:29:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l7VNW0HTIlRRaUnum66SV1FP1//0uzSIxQtGnZ2Fwmi+BHO+LZoT9RPdkJaluVR5W1mn5RNSxpYvVJ39wRxfy1DrAMlGW2tQEgtqvtWp9EmiiJVhPdq1L9Azu11f4cF5CqdFwnYTAerMK3s+RYDzHgR0yn/6tlePogOANVukeqMC8yXDrUmepYmLDtRz+HTCgian7t8PHmEKhqzecOgB9AgEUI2RtdnTTezppZ5R92w/2Boqpd2YnlBsEldaGZKOMTcj7g1F6kMuyb8Op9qv/UI2qrSFQayxCUKpdPZNN2+cAs6k0dQijnYGuxqNJFo6nTpY1lR3GnG1GNt9KvvS/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wyKnZLsHQ9SMvk4MA/sxEr28E38xHlLBaZZrScAOz3k=; b=gZBSyiqr7dvT0qvTahY5LvZN1jp31zGRTvtb2Trqc4jVaLkTazA3AUxjxXiAzycsESIB/10y2lv7T2yj/kuZhQn8onXB0KrrgP6yRd77YxysrerUmuvrk8gxmuLk+NKnGJkCELGznwpki17xNVctSvLNl0MIfsFV6tJviupXtd4DjOTJ7S4xYbuSoZOSbbfyN8jXqtynSGijHsutS3P9DKxUGQ6UFLG2qJWtdnZIcAPa558N2lKApvEo4Qbe7BxuuDD6+4FShyazo6+yEYjgjwQC+IYE+QGm1YnNo/zc20r21t3mPvc6KCD+rk1S5khGBdfDKG+TJgQyhbOnfDiaHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wyKnZLsHQ9SMvk4MA/sxEr28E38xHlLBaZZrScAOz3k=; b=Dae6rgUP8XBE03Wl2dGJvd5UrvMXHz7xEykT4I70LPcEEG2weVh+uYCZ1XLkRTOd5qYx17qUJoL+a4SD7Jl9N6p/DIUDzkE7PiU1BWjI8sRIERpXPLMm0+A6OC3UUcKF1EcLixvCAksBpmPkPZKz0ZcqDenj5iCvN9UOfFS4Rck= Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB8PR04MB6618.eurprd04.prod.outlook.com (2603:10a6:10:10e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Fri, 15 Jan 2021 03:28:23 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c964:9:850a:fc5]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::c964:9:850a:fc5%10]) with mapi id 15.20.3742.012; Fri, 15 Jan 2021 03:28:23 +0000 From: Peng Fan To: Mathieu Poirier 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" , dl-linux-imx , "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 Thread-Topic: [PATCH V6 07/10] remoteproc: imx_rproc: add i.MX specific parse fw hook Thread-Index: AQHW6MhJLbEvONcdPEK39eatOPUGiqonqYMAgABhi4A= Date: Fri, 15 Jan 2021 03:28:23 +0000 Message-ID: References: <1610444359-1857-1-git-send-email-peng.fan@nxp.com> <1610444359-1857-8-git-send-email-peng.fan@nxp.com> <20210114213804.GE255481@xps15> In-Reply-To: <20210114213804.GE255481@xps15> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [92.121.68.129] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a00e0437-854b-42fc-9e45-08d8b9059d67 x-ms-traffictypediagnostic: DB8PR04MB6618: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t2dEU+7/zh2XKbLMPPOrf5ZpOWpRNf39mp5IAOcXawyrYHrWJWuMes0odDpnaIJe4cYj4dm4qKOdhNndqxonLhQlWsHq98c3/5cNR7p+yHgBQoVioAbq0sHCgydk2+GJUjsr/jCFReO37CoRPoCAqAs/6gTznxYbX1XGQqMYJS/Us8ZJfz8Y1Q83Yer9Kf+rnSAOJPqcRjrqxKUGhChK0wu662BmPpryZZxfbVUMaqpiA1RuTS4FXBbWucHV6naK18F9yOACFLk9Wd5qb37UiGzHuMrGnMh8u7igqxSIVJ9lHuLRFQAR2Jiv8o5mXYBjgFsk8nCa/y94kFkBFEa7YN14OO7q21woq69vsYgBMFnTp79/nejKAcVguc87P0DL6lsPz45LMknqMi2QXMzqPg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB6PR0402MB2760.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(346002)(396003)(376002)(366004)(33656002)(5660300002)(478600001)(55016002)(86362001)(83380400001)(54906003)(4326008)(9686003)(44832011)(316002)(6506007)(8676002)(26005)(52536014)(76116006)(186003)(66946007)(66446008)(64756008)(71200400001)(66556008)(66476007)(2906002)(8936002)(7416002)(6916009)(7696005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?i2Wgb1dxfhgU0uohDnVtvM2mhpY6M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z?= =?us-ascii?Q?/sismdjkFMDk42z+2Y7uAX81C1gGvbHuI88zi3JNp+pS5eyyi7FyZ50CwBxr?= =?us-ascii?Q?2PlwDSZQcSwarUrZc0dskxqDz4/l0i6TaTM6JF8a29E=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a00e0437-854b-42fc-9e45-08d8b9059d67 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2021 03:28:23.8694 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oK0MK8mnC4bVitGkNA4zOpNp3kNG5HKUFGZXi++KdDDfxtCgSipse6V9o9BaKm450+CiK+ylBK8BZrhl1jZV4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB6618 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Subject: Re: [PATCH V6 07/10] remoteproc: imx_rproc: add i.MX specific > parse fw hook >=20 > 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 =3D rproc->dev.parent; > > + void *va; > > + > > + dev_dbg(dev, "map memory: %p+%zx\n", &mem->dma, mem->len); > > + va =3D 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 =3D 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 =3D rproc->priv; > > + struct device_node *np =3D 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) =3D=3D 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")) >=20 > Because you are doing a V8, please use "vdev0buffer" and make the change = in > the .yaml file. V7, I have not post out V7 yet. Seems I forgot the change this to vdev0buffer, I recalled you have same com= ments before. Thanks, Peng. >=20 > > + continue; > > + > > + rmem =3D 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 =3D rmem->base; > > + > > + /* Register memory region */ > > + mem =3D 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 =3D imx_rproc_parse_memory_regions(rproc); > > + > > + if (ret) > > + return ret; > > + > > + ret =3D 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 =3D { > > .start =3D imx_rproc_start, > > .stop =3D imx_rproc_stop, > > .da_to_va =3D imx_rproc_da_to_va, > > + .load =3D rproc_elf_load_segments, > > + .parse_fw =3D imx_rproc_parse_fw, > > + .find_loaded_rsc_table =3D rproc_elf_find_loaded_rsc_table, > > + .sanity_check =3D rproc_elf_sanity_check, > > + .get_boot_addr =3D rproc_elf_get_boot_addr, > > }; > > > > static int imx_rproc_addr_init(struct imx_rproc *priv, > > -- > > 2.28.0 > >