From patchwork Sun Sep 27 06:41:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6540112C for ; Sun, 27 Sep 2020 06:15:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A426223A04 for ; Sun, 27 Sep 2020 06:15:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ra0wWNOw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729125AbgI0GPd (ORCPT ); Sun, 27 Sep 2020 02:15:33 -0400 Received: from mail-eopbgr140088.outbound.protection.outlook.com ([40.107.14.88]:64518 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726382AbgI0GPc (ORCPT ); Sun, 27 Sep 2020 02:15:32 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IsvEqRy3ogDDaZ/uIMGQF7fgbtWDx2o+rQl6h46xHUGOm6uAZ/iDuGDfrZP80PZs5R12wilsG0wFiKBqjeI/rLVnOeO87QyNtQQb6xo0vJqtfEKBrfsgAbarI1pKJXHMK8j/JFH4gGAdxZS0UNo2XazTtq0MCqkWZmjZvqlG49talfYdj1dX/mj5NmcSuNHglK+nNevHRcl1rox0xx2QAWJvHQK4p+87UTz3/+kTtrKW6rQS/FpZiRnNfEnaTVfzDQKih9bSjTL+lDSmqCYr3gLFqldSIFiajcZI3KtYaNjk/FtGz5rtV/mdnH22CghY9JFSOVkJfpnascNWQC5YtQ== 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=mnD7zR6yW4Wrxd9g9IZdK+5bpkY4Iazc+CVkdXkyw6E=; b=OQwwzytZi53MABQ67NistOLmcQo6WXlq6jOf7kvIggLVjCf4etvzmUBcOZwwt+uVCr7faId+qttkpW4mhZf3oHChnk4PfkULHGCxs2eJCEu45MROqhawtjjsfEVu26yOJHEkXS4LiW803qOq7cZJ6gaIFCSVr++unGdzei+1nUMfDV2e/qpmJiTojAWdcT9zRTUslzqH2VcmfbCYbn0p0AzVqEJeE0bDoO7u7AnIqnsBzaFsBndPQeKrcnE5ftV8Hndcex/KY3DH1C2cbkbtGwGgpkPbjvuvJ016eFFw1pYBbaQckBQf2cl7af7qqbjYOA6sMr3zoZ1HOc6nr9fC/A== 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=mnD7zR6yW4Wrxd9g9IZdK+5bpkY4Iazc+CVkdXkyw6E=; b=Ra0wWNOwmx/XECLloqkV6pZSssRDTj1cwiW7ssMKmZ3YSnooCrk3GEuGBRaE0pcCzfYVxCfWehOhXhpefFcn8j5gtQ2m4DH6Rqa3Fb9OASyRstD36D4dNvzurZe1WOQA3SVRmTs4yUgcZjOtiFcdXnliojTfUFHog1j/x291RUc= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:28 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:28 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 1/7] remoteproc: elf: support platform specific memory hook Date: Sun, 27 Sep 2020 14:41:25 +0800 Message-Id: <20200927064131.24101-2-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:24 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d778e600-688c-4a2b-b6c2-08d862acbabb X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r4jCCkPrrNe3ESE1SkCZ0aEvYV6TSLRmeqNVHVFnuMEecr4CqYHEQnh9xnEJ56wionILLM6W2ji0/SUn7TyI8iVwLvWHwe1KJaGRxQhEUXhDHvA6mOTMwMXV7k/OMgWejlYBoNRp3R6fhppqPuz9NFPNGXUz+2EMMwLaEW48GbAp0koTdNYfNudv0d48QrjgHnBwdWMLTKmiPQHfBi2Bi+mjLXpFbgpjGLA50NVRbC14kJ+ewauC6QBzN/T07Vf8NVY0x3qLgqxCoXRO5QWVL4HkB1mNNLaipSQrLBcbJr+h4rbivWvcSGLOwcODYBGXCLRW9wYpBjNxOeftzj8cJRh/VzJczx6eLiYOfV/m1eD8bPW7E9+M1ZMj8Dubrjye 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6486002)(54906003)(316002)(36756003)(1076003)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(83380400001)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MCbHYMHQ1D7uwQuSbwN8EnFj6vYaInGO7frxBglo0MlAEokbR5ZmPk09qCglojQTjw0Tf2iIebC4u+xMo/B3V//ReIzYxoK5SqxjsJEBH5REHm4oMhtUUUNJByct+/dQe4kGG0BNn9v5NTrc018/xEO7VsTUVMs1w3aUVGV86Y9XtOKwudcuGTeAPt4M9gMVppuWx/unArNPeRmsYEDUIgkzgkkO7sFk2Y0HWPXNlc2mCRPlIQOFbmqlJ3cqZG8IXCA71MFBQqC4VMylWb/azgM+l8wxt2pI2MIGevgJmxlcHmQSR1rD2CCHkin8gmhXcyYFL/KpfhiPMKNDOs3ZrukNtiGtuTbjq4Xpnv261e3iLIowj7SrRRBovSDwsZCkTpb1qW6kCNLyU+wwy2r2XaNgBBdfDmsDlLOzFJOARGuAHPTK6WcfTwo/euYw5nBi2QvfRlFpylj0qb1tS0rQdDHL6UoYGKFxQb6JeB4yDXHV2IyctwJtMQ4LPJTzBHYV5efexI6Ko0xyU/mCz4/BuqYiquLfGNbW8uxND21wtwOlPk/zH/zcuotIwdpmHTilFLaEvn1qBzhunKf7LEaLTcBdfwFKOmgMRK9inzeYxPF8PEenQUt+5J1VRAZIbn2rufAI2WZ0IteQbwx3yu4RHA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d778e600-688c-4a2b-b6c2-08d862acbabb X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:28.2275 (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: aBhi45HAt+MIKxndig7mZKyZT5IfkZHqrc/BqUypaVfjaUcHnFhYqk98NlsDGaIfzCraSl3n5GqDQXLu1B+WkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org To arm64, "dc zva, dst" is used in memset. Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA, "If the memory region being zeroed is any type of Device memory, this instruction can give an alignment fault which is prioritized in the same way as other alignment faults that are determined by the memory type." On i.MX platforms, when elf is loaded to onchip TCM area, the region is ioremapped, so "dc zva, dst" will trigger abort. And ioremap_wc() on i.MX not able to write correct data to TCM area. So we need to use io helpers, and extend the elf loader to support platform specific memory functions. Acked-by: Richard Zhu Signed-off-by: Peng Fan Reviewed-by: Mathieu Poirier --- drivers/remoteproc/remoteproc_elf_loader.c | 20 ++++++++++++++++++-- include/linux/remoteproc.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index df68d87752e4..6cb71fe47261 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -129,6 +129,22 @@ u64 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) } EXPORT_SYMBOL(rproc_elf_get_boot_addr); +static void rproc_elf_memcpy(struct rproc *rproc, void *dest, const void *src, size_t count) +{ + if (!rproc->ops->elf_memcpy) + memcpy(dest, src, count); + + rproc->ops->elf_memcpy(rproc, dest, src, count); +} + +static void rproc_elf_memset(struct rproc *rproc, void *s, int c, size_t count) +{ + if (!rproc->ops->elf_memset) + memset(s, c, count); + + rproc->ops->elf_memset(rproc, s, c, count); +} + /** * rproc_elf_load_segments() - load firmware segments to memory * @rproc: remote processor which will be booted using these fw segments @@ -214,7 +230,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) /* put the segment where the remote processor expects it */ if (filesz) - memcpy(ptr, elf_data + offset, filesz); + rproc_elf_memcpy(rproc, ptr, elf_data + offset, filesz); /* * Zero out remaining memory for this segment. @@ -224,7 +240,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) * this. */ if (memsz > filesz) - memset(ptr + filesz, 0, memsz - filesz); + rproc_elf_memset(rproc, ptr + filesz, 0, memsz - filesz); } return ret; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 2fa68bf5aa4f..1f5fa2c772df 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -392,6 +392,8 @@ struct rproc_ops { int (*load)(struct rproc *rproc, const struct firmware *fw); int (*sanity_check)(struct rproc *rproc, const struct firmware *fw); u64 (*get_boot_addr)(struct rproc *rproc, const struct firmware *fw); + void (*elf_memcpy)(struct rproc *rproc, void *dest, const void *src, size_t count); + void (*elf_memset)(struct rproc *rproc, void *s, int c, size_t count); unsigned long (*panic)(struct rproc *rproc); }; From patchwork Sun Sep 27 06:41:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79DC3139A for ; Sun, 27 Sep 2020 06:15:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 597C323A01 for ; Sun, 27 Sep 2020 06:15:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="eUdISZ/W" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730341AbgI0GPg (ORCPT ); Sun, 27 Sep 2020 02:15:36 -0400 Received: from mail-eopbgr140040.outbound.protection.outlook.com ([40.107.14.40]:38062 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726382AbgI0GPg (ORCPT ); Sun, 27 Sep 2020 02:15:36 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FiUWoq0dwgHdRLcadbVTIjAlHwoUlaZ77zhcbRfsb98m6YKj5aIswqqiF4In/3C9YlScnqg0NM4dv8GfGuptdxW9JRCoTnT+Nh/jq5tvIJ44NAc+bARmzLNww47hYsKFRmQ0rWrv3jawi/o7kMS1L3W3xyosgQ9Xo4bVdNLg9PTQHpcHFx5oSn5WS9xH5Y7xy8FeRKYOgxHbJ4dqp9aEuNbhdE5ChtbXXjZ7HIh85BtZKYWrVKJL/XIXMr3qFuepsBcwTtKh57p2vg9fGXSoWWWYMe/1VBU2WxiapP9NQkFd29soFEwJ7r/75hQpggPLXgdvEIQFf+z+1GpkFLWa8Q== 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=A1ufFCrXLohwqXvo9epGDFyJ+Lt3G1kTh9Y1fPu0SPA=; b=c6uAVmpmMztp/yfJAyOksa4FRdk7/6gb2muhfvp6HdKsYP2MUjXK1RiIto2ngZhd5s4ata1faTTlek0qESMwz0KhvSbuJUMW3JWLHtzLl4zYHU2KV1lAKGg6waYAX707SHac07eyUZCF4B/PveSVGv4Tq+D85kSwSKARYrq6c3E5N+bokTLv3wpn+Q3zne4KFksc7yNGP3v8thQJxapqsw6/VdvId3RjavsCzevG70bxCptHBuTTmJFL5vmwH41D7HFZklVwm+Vmn+ytJlUdYECCiSOrxSbt42ZFztCtd91VC0YnFOzB1CpZmido8bUjZTLIbYmOTKXOwYmF+TMvdA== 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=A1ufFCrXLohwqXvo9epGDFyJ+Lt3G1kTh9Y1fPu0SPA=; b=eUdISZ/WdjuyH5EkViFl8FtGnXloFWFoVfxlZD5Lz+NF83tzmheOKxio4V0kheW1WSNPZ5L0L09KjfhPqw/5+DNe1ZoPMO/P9aA6sg7cCDNk3rvyOiXYxtw0sBCKmeQg4GGMGhZa/txqFPgDdnKGn3QQrZxccru4pldtEbYKnZs= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:32 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:32 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 2/7] remoteproc: imx_rproc: add elf memory hooks Date: Sun, 27 Sep 2020 14:41:26 +0800 Message-Id: <20200927064131.24101-3-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:28 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ba938894-6fcf-4f6f-d7cc-08d862acbd5d X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Oek+gZLAMG4FTt/wKOwduDC494YzEAyo7dwr16sinwDJfqj01J2u8VU5dxPUz9jnBRNtDwtvlXsjTDVonths8bP+yS2AW5STcJNJR2+UhD1ruvWSQ+8uscQ7rrYnPmXWSUw0ecOCviTAJdEmq+nDrhdT5zUlNmyrPkWuNQ+QdB1ZnL0rEp0Ot6j2k1hjBpAc4VGFLU9bD6xB4w81Hvy8jcrfINj3PAN3SNo9DRkGb1OgwntI2IrWQk+FWQCHFZzcS50D2zyjAWNT2EWFl9mcjDJe3lfppIZrKyarDVmNlajXgKj1TLLGh7VEHvnjgfeUtQdkytawFC2ycKbPw/ATAEOlZH2dCDpACdIxt2wBbR/LoI1C1Z98hdjBcOa6nnld 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6486002)(54906003)(316002)(36756003)(1076003)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0ade2zpT9vV6Yq2Te8jBbyNxPh/VT5QFxOg3kJxyrnHVb3U6Ld5CAQ+M54n/u26OE2zNuKTvsgBUhbt8qVULbzBHdomVxQumvnI6I/XWlmoI3YErgaeymMnbnru1Q9t+0P3Phb2j9Q1oKNIt55EGQOazuXcYDEqbM5rVyBUu5kJnLV83dbU7dKVTkFoGf/zX8lvrPZdFD5gjvRHnZETG3B/HRJBS/LE17eo/sm0ah0iJVfu/PGvsJUSRcpaj+SBOTYe9Hmn1Y6UN49IYg2899c/hW2ANTu4ubevMCdmfQNBTc/rgyS8kt3W4sXyvPC2R2atMRu3m1CzqlAX6eYaCt0d3trHwks6Ys75o4xIZvspddrrSHn1HVF25sDLNTAAcdH8jybe5k+CRnIL2A5so2KPzCJqGejhDHMp/JDh36CkjK1AWsFXGG7F+EzuY/TZiCsA76hWNh1mKy5HzaotzQZi8HI6XsXn/BK8Plkye/E9LUAozRFd+P6NwdmKJyQTeAFUT4pSw5GyPXIbt8YdsMNmk3cX+4r7skRDdRBncEpkkHPJJzSqdlhnGVRh5O5F/sKtiVT3woTcPFU2hmY14PECBACqi8hGcxqCOomecITtkw8l1ipE65kzj3Pfq5RPnEyw5vKOXekvfU2bLph9Y1g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba938894-6fcf-4f6f-d7cc-08d862acbd5d X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:32.6005 (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: GKg62lxt9bFWpNqnyPJXAKDEjXxakOlC7k4JAIyGZqHtrxJq/CWLcNzSIKnRxmsyI7g3DQziNu7JDR6LR/s5DA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add elf memory hooks according to elf_mem_hook setting in the platform configuration dcfg. Acked-by: Richard Zhu Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 8957ed271d20..d1abb253b499 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,7 @@ struct imx_rproc_dcfg { u32 src_stop; const struct imx_rproc_att *att; size_t att_size; + bool elf_mem_hook; }; struct imx_rproc { @@ -310,6 +312,16 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, return 0; } +static void imx_rproc_memcpy(struct rproc *rproc, void *dest, const void *src, size_t count) +{ + memcpy_toio((void * __iomem)dest, src, count); +} + +static void imx_rproc_memset(struct rproc *rproc, void *s, int c, size_t count) +{ + memset_io((void * __iomem)s, c, count); +} + static int imx_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -340,6 +352,11 @@ static int imx_rproc_probe(struct platform_device *pdev) goto err_put_rproc; } + if (dcfg->elf_mem_hook) { + rproc->ops->elf_memcpy = imx_rproc_memcpy; + rproc->ops->elf_memset = imx_rproc_memset; + } + priv = rproc->priv; priv->rproc = rproc; priv->regmap = regmap; From patchwork Sun Sep 27 06:41:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6C80112C for ; Sun, 27 Sep 2020 06:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C24A223A01 for ; Sun, 27 Sep 2020 06:15:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="QTgIQOsF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730356AbgI0GPm (ORCPT ); Sun, 27 Sep 2020 02:15:42 -0400 Received: from mail-eopbgr30056.outbound.protection.outlook.com ([40.107.3.56]:25733 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726382AbgI0GPm (ORCPT ); Sun, 27 Sep 2020 02:15:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDrPqo/jL4+p7B08HpS0b7TVEXa3wOo0Y95uw4gYbZLcGrPfXZh7NVdFuXRBsLEK5dlS5bVs5dJIwWUF5gBJ6w9GDk7BFdD9pbVqtRUYNMeMt03PENHnPDYfdIB8IX4FjMe2LLqJU1PvJMx+av34JcMyNP7BQW162f+DrF5joAAHQRkQMqReOgq11hz07YNA8TspyPQ5Xc721pDxO1xsVll921CxOFtAuZR0dQhRty1jvBolsjjN3KYyAyRy3eCCoeC4Yv3fbtzSn9qYzRRif2kBol1zXaHjFD+cBXK/eMAALpUrlw75A8gEBlu6dsY5kVTgx38phgI9v2Sbzd7NlQ== 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=D1iNRtvNk0gmd2Qh2e0U8a5WKa89gIXMcfiVUBBaOVI=; b=OJldqWGB5jM5T6n3AO2/WE9YiD1r1AIOJeSRziwIhqAjsrpRSkAmMZ//NeVmYu6aopNQpw0LhTxPqNECjGJSyO2VXv3LRMGs4KgsTYR12UBgWoMXntC7/wm526R1qi5JofeArLoTQ3CyJPy5TuWxyyqi2sQ5SePxGjyOGq/RCaCESl94MEsQWF3SHMfiwV4+c9A4DEiDU9W93HYxnP2OpzrYxawlOgkOkeeyOaUTz3nXmNwgjAtPGKm5R9ywrWCcl/rk7sN1Jv3e+KeZbXIApkuMh4IQ+JoZ68jqGtK+LZVx6wUINluvC2rxBHm7AYCS/QqpbzF+0guy+w5aXrpJgQ== 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=D1iNRtvNk0gmd2Qh2e0U8a5WKa89gIXMcfiVUBBaOVI=; b=QTgIQOsFp7eh9HaioVGrvlvu+34WKHFf5HISqEQICAWuUiDBssV/qmC/N5qLamOcMXxJ5DU7v+NdsKDz8OpGrlU6jQfgw9qsVltyoIR5O/SAclgc6w1eWBD3c3Kg4+vj81ymqfivrO48mxhvOBPy+95BiImQ9P43ipSSYAsdHBA= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:37 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:37 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 3/7] remoteproc: imx_rproc: correct err message Date: Sun, 27 Sep 2020 14:41:27 +0800 Message-Id: <20200927064131.24101-4-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:32 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6ffdea49-05f2-47c3-01b4-08d862acbffc X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:935; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BMNDdaZOGfdRVXv71IhLCJDx6l+SXKmwHdMW9pta/h6lQhKvkNwhLB7h6uA6C/1c5yBmeKDavlISfklxaZcy5pk5qAEtNuYKGbHh8xVzuhTog0JwraGnhuMofjEdwAHcvPx+zE4HY6K8Uik5I0+eV+QFUIOoC0z+zIe7QXcOMJx8Sruzydp5CAX/hc6JTeVaV3Dl1JqWhFDu0HSTDmy/zwv653Gdbp2QoxLLwU79kAoyc2QTyQqC4aVqDx1SCCZkZOwCy3lQFRq648bQp0H/utzVnZSXoDMatdbGZnQ3EyACxElwwZGAIXS9r2g5w89G0wpQWO8QuNVZ4pGqNWoqW+SBf+2fT6bWPqtyLqEKVf4sew7bJCmp3wZZ0l+j3Rbm 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6666004)(6486002)(54906003)(316002)(36756003)(1076003)(4744005)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(15650500001)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(83380400001)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iGE1C5Xk8NIHWbOsnRJ5Qu49E08y9EH7LhhbWcW6JRYn+wzRenqiT6Qe2JNjXu055eVFYYnVVw/YtZKYj/KBOj7TqHUT5rzEGKbK8iU0d/8QHoRWkHOc73SZLsL3CNNp6/w+pwTki0mfdzmSCfVWPjVQ5iUu/CxR4fKSH7Ryi9pzxeky9nREMPoTnM+I5KMlQ8LbiDgdrbl+v3jkZd810FOQ/gWHV5gFeJYmQ9Km5rtQKAGi7+Io4DIBUuCc/3I/Jz7BiSMphUVLUqaoXH8hCGHtykh2LEn5S7ycnxl6rwRB6qqj2vK0+aNB+luPHDrI6sEcDNe24SfEQRvPRKD7pNomuVr85SW721LG8CKjzxfcviP2v7CTJRx0tkLarnbMoQ5Ld5iggvzS7FiJ4L+oqxl3M3TJzvQOvFTchanzpJhfZYNMTj2uw+OM+c/i12RwUu0qXwNlnWLttQZ1vrLhR+ycXOBdfdgxvT26OzIz/Y4L50NCqjCWKfObx8CTh57TwezI+NdN9QNd+cz4GXJmOonYaNumkLtLiOmrZxYgCZQy1snuGSouYhXBv9Kegarr/GVcxLy0VJpjajFPI7/QJrvNBP2YCWHIT1IZSfjilmBMaZC8OZ8paKaw2xGakeU2t1kvlDO7zj/+FtwxCjCXAg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ffdea49-05f2-47c3-01b4-08d862acbffc X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:37.1164 (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: JR7OVrU815hZ9ppjuIAotJ3QHqGQwuuvcIynwFFIHaW4EQ3j13OAmQ9rDI1P2eSCokx/PFz/PAXwL6mxL+8pPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org It is using devm_ioremap, so not devm_ioremap_resource. Correct the error message and print out sa/size. Acked-by: Richard Zhu Reviewed-by: Mathieu Poirier Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index d1abb253b499..aa5fbd0c7768 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -270,7 +270,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev, att->sa, att->size); if (!priv->mem[b].cpu_addr) { - dev_err(dev, "devm_ioremap_resource failed\n"); + dev_err(dev, "devm_ioremap failed\n"); return -ENOMEM; } priv->mem[b].sys_addr = att->sa; From patchwork Sun Sep 27 06:41:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23382112C for ; Sun, 27 Sep 2020 06:15:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05A9E221E5 for ; Sun, 27 Sep 2020 06:15:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="L0+R/4z7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730370AbgI0GPr (ORCPT ); Sun, 27 Sep 2020 02:15:47 -0400 Received: from mail-eopbgr30056.outbound.protection.outlook.com ([40.107.3.56]:25733 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730355AbgI0GPp (ORCPT ); Sun, 27 Sep 2020 02:15:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZXVqj0cqqO+SoP1yOMxo4W+aiZWWNYFbxXh7YZsO66zSp720eLNnCXPDD/xoCYzLM7aySHOKj8+j9AHPEsQsz49Kltozf/rPjbKwyg7sJhw+FzTFPAj2gvm3O/ISktBubyMFtJaEeNZRuSrr15/985Yv5dxJ0k6Yy0gLXZcsyjgyFKtvOBD5cpUOjn63S/JhYk+Pyms4WHpFTouZ1Ppr9PNEhaeuJ1Ol7+7do7QoVzi8vDj3MjrWAv2G0n54IFluE/iZavJClzkAF4R2I/CumGJEgS12quY335dJdYj/3l1qP/Px83Py8WlF9jyYJxaI1r8IvKQJvlodH/YvdQGLZg== 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=8WvGSGcKYc3VMskfmZvqWpDA0bc+3FaTKmuy9Rjb6Dc=; b=iy5YKYlPNqHjHZFbHMsXPaYkZX6TlCYG5H153W3ZLyJfS/0GwS6Mty1xE692nGdKZ+IqdcrsDEaS5SbX7qavFfhiuKxxABXDcqh7lYWIvRXPbA9SmZmKo0oUcok9ktJxWHTPcR3nd9QxJudr+x9wMpYWH2mrzVK0QfNEtH+Q6nApRxmc0eFteco/fsL8nqBg2x1+xQaNnbSdxXKCyMz5MAywut8I50/EKuY3JTqFM4M3S1eGXxOIa/ZPQ19I01mgSFK7YWu4Qp+4iqqLyjYeTWmPHtBe2ctB03UFItobDRUmmItvV2Q2H32XX2L1R8B7miL32xlZ4rA7Hqnm3fp7Rw== 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=8WvGSGcKYc3VMskfmZvqWpDA0bc+3FaTKmuy9Rjb6Dc=; b=L0+R/4z7R6msmFxcwOVsVs5+EYUlmeWplKt5IdIXIE2CIF27ewAmg0W+SGeG0BbA2gGDPSo7eqRUYI0lpiOV/eD5lWqCcQNo274cmDrxvSpacSEF95zs219Dgmj2ZNsSxRVjgRBUdi2AkOQXv20Cbhrse/H2DfNZTOV40q5SH9g= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:41 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:41 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 4/7] remoteproc: imx_rproc: use devm_ioremap Date: Sun, 27 Sep 2020 14:41:28 +0800 Message-Id: <20200927064131.24101-5-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:37 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4ce5f486-4ff1-46ff-67d0-08d862acc2ab X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:660; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GR6VDWtohUMF0SxMOKJvEW30GgUmuQX2pExXiI3lLi+7lhFsYmn4SDOhxa+9MDsZjZ5Ir3VJttPoZ9OtJ7nVUNWvVpJHojTFNX1mblRxeUwKhcr/IS8CEcMP76AUEpg8MvDnAHSDlN7b6RdNdEmJeJM5KNeYcDquK+sgn3bE9ObA5btJigqIyBviRc75hghNUD2fVemjp+4ddYfFDDlH4ghIuO/BZRvaFIdKMl6M580G8w1efIG6aGu+7fgBvkBChZ93Pd+DMq5PbXjKa/zPXWDwtVzc4P1xV9HwCZsOFB/ismHperRPPOHOr6/XdTIbFRZeSCRsZlI+xOJHhxxRpDTFJS0KCr3LY3poJuJcV667yAM9M/7GR8fNBbarfzyX 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6666004)(6486002)(54906003)(316002)(36756003)(1076003)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(83380400001)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: z/n3/HYegAA03bh7l5Bx/SPPUb+IcjYqjgMYj6aWVXENdRPiP6t6KuTV0rbpOiV3mAZN/Jw3t6bVCq9Ht3Sw+TzuwiODX9zKq0xMOulcaX/uOfBshOZK7th/kMHL9Eqjc4MFxKcJDpa9J5URnuMKfpj7TLsVsJjpI4L994zxf9X/RG5BB47pWNC7NTRB4hSaPcWmUVIULNE2auRYfZpiX7fTJsKtJT0G0GztUHHpd+PxbJsgraQO2ly7Os6QrvZSSIzUKgVfQq9OHf2xM0N7O5xrBVm7jQe05wbeX1SUC/PH1YydtVlOMKV86r3C7sIQ2NLgrVJcjdiH50P6Y9IZlQ7FWXi4gENGIGbEFVWBqoNTs2IWCwlWGsugYIjC0m+OeRZb02kNKnZqx1YZsq2J98UeGVOxAKHDHb2co6BD2b7rW+d3FdvFgEeZH7Fyjm8MR+qk7C34mLrhdB19IcFA82fOgQEWNb2cm0eH8XPBwcnudWgwrYKVwgRBcocDMdX7ZWf5rtrGWovgbWYMz190D603f0SSaGxIHClDT3KWZIv1TB8lvCPYjKO4HpTtodJCi2HEI444As+dn7wxzkJzezHu7qbiSxUDfE8qdiyAX8mkhQs98FenGYLwiG7WVrEPRW4v6ZUSTFlVQoW+w3EOog== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ce5f486-4ff1-46ff-67d0-08d862acc2ab X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:41.6123 (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: 1MLPjEJtaMWzJxyCJp75x6Eozf1cJEalBMVAlFhlBfcN3UCwAh0/Ur4UCevYC3qTOQfGDOYWUbNSixzCRVPYUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org We might need to map an region multiple times, becaue the region might be shared between remote processors, such i.MX8QM with dual M4 cores. So use devm_ioremap, not devm_ioremap_resource. Reviewed-by: Oleksij Rempel Reviewed-by: Richard Zhu Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index aa5fbd0c7768..48ce09e857ee 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -298,9 +298,10 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, if (b >= IMX7D_RPROC_MEM_MAX) break; - priv->mem[b].cpu_addr = devm_ioremap_resource(&pdev->dev, &res); + /* Not use resource version, because we might share region*/ + priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev, res.start, resource_size(&res)); if (IS_ERR(priv->mem[b].cpu_addr)) { - dev_err(dev, "devm_ioremap_resource failed\n"); + dev_err(dev, "devm_ioremap %pR failed\n", &res); err = PTR_ERR(priv->mem[b].cpu_addr); return err; } From patchwork Sun Sep 27 06:41:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1A40112C for ; Sun, 27 Sep 2020 06:15:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFBEC23A01 for ; Sun, 27 Sep 2020 06:15:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="itr8EP6c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730379AbgI0GPw (ORCPT ); Sun, 27 Sep 2020 02:15:52 -0400 Received: from mail-eopbgr30056.outbound.protection.outlook.com ([40.107.3.56]:25733 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726382AbgI0GPu (ORCPT ); Sun, 27 Sep 2020 02:15:50 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GTAgEYO0lrxl9lmNcL2Vkg5kpKXEz5LcGs/0F/haQqbzfTG2629r0dwwWgRsI0awS+W39UjOW6iUN4rZvQy7QtGI48J/Z2pajg6wvb2U4VjA4sh0QLae4NAebHXKIVkYE1go4uZMY21ejzgy93jzotEe1uYiVAfzGBRaglzdIEMKxc1XfN6EtB4CtfOdTN6QlquTP/QFVOnL+e/fFqAvLsS8SBzYs7Dc1FCTUuZ1EXMRsl6skmcP4iP9V6awrHk2sYBGrvu9/LSJr16MSvDsw52iB+tFV0UM3L47MrQE6uchBjfqjkkBR4CXS5MOeq6I+IR9PD5ZSS00/Dh4z6NU2Q== 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=vtKEcLCPQXATmwARlbWInIvBYGuhb7U7HNELcesSE48=; b=CZgZVM07/MxpAi5aB4/HrK2qYQWASD4PKThqKrWzlD7V93VW41RLzStsRY/gUTtjnv9ZZJ/WGC+Yw5TzXfLl9ita7TE3DfFoiatkTxxZD2Ntfoa662aRoMdfNYB3s3jrZ8zjDGfbD/bqBrjDUma5+2h5Gt0m3MW1a9oz9EZVc3ozlu/7lm/oUqW/71AOIZo/7rPgHX1kbo/XVU8SQUWA+DB4gqRDzg0NVNzIi+WSFg+S95WbHdCLD2kSmHWZze1oIb4NhLrQknBWs1YtivdMq6yv42OIBkr2Z/NWa8nAQl0RkX8qtz9ezfxZajBh8gmagFfQVGIVe03unjdcMLUNRg== 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=vtKEcLCPQXATmwARlbWInIvBYGuhb7U7HNELcesSE48=; b=itr8EP6cF2vHkWzTzbmCe4uI9/Q56HtKzglhOdSmcNYn3dhFLog0+TKi8Y53Bzoce9/pf9wNZW5mcIQLpz1Jq8wubZfadQq9KneRakxFamWIIx9Cy4g+D2/ff+I5KczC6g4aixvpKyNML/cvF7S5xvW7oMG1mTvczPLRQtn3VwY= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:46 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:46 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 5/7] remoteproc: imx_rproc: add i.MX specific parse fw hook Date: Sun, 27 Sep 2020 14:41:29 +0800 Message-Id: <20200927064131.24101-6-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:41 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 55973492-6fd1-4d1d-5426-08d862acc55c X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +eep6h6xX6nZ+DoQ6X0qEqh/FbgpjQxptz4476yDrsXGg1pcEWKrphYJyMxTOoeC+8JpfvcmrmrBrFPaXo+RfddRFbilB/cPJyKTkOEGR17K1XRVsur/XLeDGCeFfzgQCHlDmD11mHrD/kJDu88DHTc3r05R//HBFTVlMy1Jg6ptlu5qNgdW1EBiek8skvqxzDJNYpY2menUwSProeGAiHjPEkIgnT1jRUfc/y2cExx2oqnUGB1kBeXabHgcRWp8PxtD99rwg80+2oT/sad8LCkr9UkqHWMUQ2Mi5UVBv2v9lHrH0s3gX7yHlo7lnllbTpp3KeR0z3UYLnsFG7oMSxdO0ougT63XAbdi/M1n9hY44750CWOvtGX0BbTIZJNP 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6666004)(6486002)(54906003)(316002)(36756003)(1076003)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(83380400001)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: QSbCEMhe3PzwQhpwJBPDBwx9YbvLDZiLn21OLbgTnbiXwrHZuzkGSXfl7rxrIoHkwvqJvsgULb2ab6ux79o673Uyy6QBrh2Qzv0WqcRG0nDwgIqmPywL2DV9W8mnR4DzZ5YXbfVWEt1YI8xh/t2WfE1s6j5e9y6fXqhFS1slXYZBmvIZg6AHkyDsdNMJw9A2gmUzi9yfOTs8c/UWjdpu8UkFXM6msCdD2TstrjiausKlxbHu6H1jagtl5/8I8RIXxrbdALt/Lxjvjrze3jrvzN7FksFnE7+r4vM4wgUIbVF/hxeo73F46lQkiDnK4NJ/b6EyuvQdsfbfAP+VwU4RnBLAqAi5B6ehA2cxp/hHsFuWUu5qM1x9pvdIjLobsPtW8PKXKNyf8vZbfYFMJwxWfWIbuegnwAnYV1Qyt1gB0r9AfGH2+0YHNYK0Ai4CgBu3dusdqgurN9ZL00oDbLB3QAJ4DU1OhEz3xoIa+vhHQqYu6ILaFSTkM9R+W0zwa/cAZhKP9e7mUbPyJc5MEs8S1cCERNCrNJxyvfV0RV2b1wxDTxOpLBPyeRpSVOT8kIhqxDLBlLim7YKaBT9v6n7lphA9/IZekeUM3u/JNTKGm5PvexsFdn+seyO42NdrAvrzySQd7kiBc6/awkYucuwqog== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55973492-6fd1-4d1d-5426-08d862acc55c X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:46.1123 (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: pMlu84NWsXqQPgpVJXsL7VGqRzcwX4TYL5LQsZCwv4HjO7eB8ftpwCF6Qbwa49OB4S7Kw+z5ZJbzpWNliYOHMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The hook is used to parse memory-regions and load resource table from the address the remote processor published. Reviewed-by: Richard Zhu Signed-off-by: Peng Fan Reviewed-by: Mathieu Poirier --- drivers/remoteproc/imx_rproc.c | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 48ce09e857ee..bd3a42892b22 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -243,10 +244,106 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len) 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; + int index = 0; + 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 (!index && !strcmp(it.node->name, "vdevbuffer")) { + index ++; + 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); + index++; + } + + 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, From patchwork Sun Sep 27 06:41:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CD99112C for ; Sun, 27 Sep 2020 06:15:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18E0023A03 for ; Sun, 27 Sep 2020 06:15:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="iyod7ab3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730388AbgI0GP4 (ORCPT ); Sun, 27 Sep 2020 02:15:56 -0400 Received: from mail-eopbgr30056.outbound.protection.outlook.com ([40.107.3.56]:25733 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730355AbgI0GPy (ORCPT ); Sun, 27 Sep 2020 02:15:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvCSNgS+4TdMu3nMwBpmg0TRLre6gK6RKOn0uvBY2PSy5naZfeH/Ldzj0rSIxUwnZ+5lITWxu7H4DdxzNfdiDb2uMmsmCcZwR9co45r5NzW/0Cv3PRSdErSvrg/EauxxR1FloUiA2A0izL9ZiWsy5aqLtavBb/yM8tRyGw4cY0NruViQyD1GTq+V4cF7kbYDKoWJG0i5YNLbC363Zq/2rb0n8BmNhg4GkjDGnE3Jfd8LnLWTs8OLkMjpYWFtNaCbwsNmK4cXuGvRwH3EcwXK1TlUYgoHxMPjOEUANGg59tdqGybaVtXSPLeJytZBnXBE8oxuoAF+TpH2UtwECzMp5A== 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=iLHy9TdHMuar6HQLEmP4ngP5zCUv1sC2Ykb5EK17H7c=; b=LkgPZcnR7WJhq51IgAwmpGS9T6Q4/Q4/1yp0AxuMAFAjuvrR25ShtjGa1jbKgp8O9WJJ5Rft1+nPXI33naieIf+6s2yasTVdtA+HC5xbtYkq7zBO3i4OQ5O47/DLTzH5BRk7xEU3/0ivv1qsoU7CdfCXYJLTdWRUn8sPlRIvm8TAC4Wm0/7H0TrxTN6bNjCPZ1phqi2o+MsLuVoy/osIlW2kYQEGpI0chKhNTKjBD1yahTn6ML/HcZdFDcIlSEJ2lnMLhSW7wHp6gMCui1gFjQZnzb8A6TpZ11VY4s0payOdUOu+ApCxZbpFH8IXZibtdAuWl2m7fUyo59ypDk3uQw== 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=iLHy9TdHMuar6HQLEmP4ngP5zCUv1sC2Ykb5EK17H7c=; b=iyod7ab3pRtQtF+K8smWxvY1Or2GSD0g2CGb3qhPwt0DF4NDZse82HPO1Dzr+AsSAJf7S3oCPeC6RBo+s6qJSDARlV7id1RXaQhow5jE7J6O6iJ5GdzuOGQgigSkMk1K0DU0QPxGujP+uU+xk1SSgbVwaxHGeNJlLILYv03VZWk= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:50 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:50 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 6/7] remoteproc: imx_rproc: support i.MX8MQ/M Date: Sun, 27 Sep 2020 14:41:30 +0800 Message-Id: <20200927064131.24101-7-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:46 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6a179988-a961-4541-67b0-08d862acc80d X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:61; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ysNuyvYLI/m8GJHKBxL53FehO9g/BWkOhuPxMJ0EYvUV2YPn3AYV63SxnP+haES+a+4qu/gAekf9qIPE8uSX/vlMouuDJd8xaoKsoMaKpVcbGbDzstbkvAsyj39SFmI+p98b7/5TmErNpQoatmmzuex34wHQTmNvYBqdM6ITEFbuYv5R5HeIHxaovbuQtIj5kItIHgKivTsAZdoNZyIDD23z2U38pStKS3vFqcumVryFQqKrWWiPCyjhQHDF+ICwZU/Ot3omOpQ++NrFnXfz4rsW7t1h05CDxICEwo9jbfuP+aoBcX/YGRv+bV/NHOD+qjDZ/eVyHPMxIhfz4BZfKCngF9FE0Wo6v7UG6FLTw8NWOW5ZwZIlze5b0MYhK4A4 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6666004)(6486002)(54906003)(316002)(36756003)(1076003)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: BjqbWIC5ljyL/NGxEc+yrQ+T66gYTLCiRdsiByp1PQvO9iN2g6mtxxCuiZtkfmSU3Y835yCm4HQILhfl0HDjjWq6O3JIWvhFkYtE8hVaDHIy93KURDI/jxxFNOtKKbbZcxKRqgEG77ztG9kJ0dEAqpxkwZ5aOmeCltvVE8Cmm78SGYRCjvng9dIl8uhS2MgVDBaZA7BmdaNGCNMYy0iLx8kZgUUjYGOFgdkR2aVtkvBiggeAMexNlrRapl50GKx37CJr7OXXY0XVX2ai6KgTjThiFjpGlWg9RWgpltYJg5SqSbKlo/l1JfsvyQeRcGmxngOsWDXaboh+dLzncx484f/lnPdeQ2c6jxkztTKnek49bgBvyU7cmgTw4TJMiHDQOE1FlnMHmPg5R4m2t+FJUn9guf1DKmkOBBS+gs0bf6yr8dEsZkjBbuVcSRY1FKloqWyApXX0HCyqo9Yysp6HqM6RU8vDJ3wll9MiKliYnYVDF7sJHip2ZmTiIaBBmJR/aeE9n0m0jfMgcfRBgMAAsfF140BsJi0pB+RjcPRL3i2uMfAbnRz2uQizNrdidjkzZGPu8z3c1xmALgjSXnbN5nkZxlvANwJrMM/OE2lKPmv5JlSKxXKmk1tXKtFUTDNyAF8f7VJQXNVdnzJN3eUJWw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a179988-a961-4541-67b0-08d862acc80d X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:50.5302 (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: f6enlH1+MR2uapp0qE+5Vc2rlzidQ1xfbuPmpOJv1q7atsWLIE6w+DcQ92lC5aC5Jr5Xnttv/GcVp/2dIoVYDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add i.MX8MQ dev/sys addr map and configuration data structure i.MX8MM share i.MX8MQ settings. Reviewed-by: Richard Zhu Signed-off-by: Peng Fan Reviewed-by: Mathieu Poirier --- drivers/remoteproc/imx_rproc.c | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index bd3a42892b22..0f69f3f745ab 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -90,6 +90,34 @@ struct imx_rproc { struct clk *clk; }; +static const struct imx_rproc_att imx_rproc_att_imx8mq[] = { + /* dev addr , sys addr , size , flags */ + /* TCML - alias */ + { 0x00000000, 0x007e0000, 0x00020000, 0 }, + /* OCRAM_S */ + { 0x00180000, 0x00180000, 0x00008000, 0 }, + /* OCRAM */ + { 0x00900000, 0x00900000, 0x00020000, 0 }, + /* OCRAM */ + { 0x00920000, 0x00920000, 0x00020000, 0 }, + /* QSPI Code - alias */ + { 0x08000000, 0x08000000, 0x08000000, 0 }, + /* DDR (Code) - alias */ + { 0x10000000, 0x80000000, 0x0FFE0000, 0 }, + /* TCML */ + { 0x1FFE0000, 0x007E0000, 0x00020000, ATT_OWN }, + /* TCMU */ + { 0x20000000, 0x00800000, 0x00020000, ATT_OWN }, + /* OCRAM_S */ + { 0x20180000, 0x00180000, 0x00008000, ATT_OWN }, + /* OCRAM */ + { 0x20200000, 0x00900000, 0x00020000, ATT_OWN }, + /* OCRAM */ + { 0x20220000, 0x00920000, 0x00020000, ATT_OWN }, + /* DDR (Data) */ + { 0x40000000, 0x40000000, 0x80000000, 0 }, +}; + static const struct imx_rproc_att imx_rproc_att_imx7d[] = { /* dev addr , sys addr , size , flags */ /* OCRAM_S (M4 Boot code) - alias */ @@ -140,6 +168,16 @@ static const struct imx_rproc_att imx_rproc_att_imx6sx[] = { { 0x80000000, 0x80000000, 0x60000000, 0 }, }; +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = { + .src_reg = IMX7D_SRC_SCR, + .src_mask = IMX7D_M4_RST_MASK, + .src_start = IMX7D_M4_START, + .src_stop = IMX7D_M4_STOP, + .att = imx_rproc_att_imx8mq, + .att_size = ARRAY_SIZE(imx_rproc_att_imx8mq), + .elf_mem_hook = true, +}; + static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = { .src_reg = IMX7D_SRC_SCR, .src_mask = IMX7D_M4_RST_MASK, @@ -517,6 +555,8 @@ static int imx_rproc_remove(struct platform_device *pdev) static const struct of_device_id imx_rproc_of_match[] = { { .compatible = "fsl,imx7d-cm4", .data = &imx_rproc_cfg_imx7d }, { .compatible = "fsl,imx6sx-cm4", .data = &imx_rproc_cfg_imx6sx }, + { .compatible = "fsl,imx8mq-cm4", .data = &imx_rproc_cfg_imx8mq }, + { .compatible = "fsl,imx8mm-cm4", .data = &imx_rproc_cfg_imx8mq }, {}, }; MODULE_DEVICE_TABLE(of, imx_rproc_of_match); From patchwork Sun Sep 27 06:41:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11801803 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F7661580 for ; Sun, 27 Sep 2020 06:16:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48A0723A01 for ; Sun, 27 Sep 2020 06:16:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="nElZ73hH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730355AbgI0GQA (ORCPT ); Sun, 27 Sep 2020 02:16:00 -0400 Received: from mail-eopbgr30056.outbound.protection.outlook.com ([40.107.3.56]:25733 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726382AbgI0GQA (ORCPT ); Sun, 27 Sep 2020 02:16:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ElayPiuHMXZFMzytIVsrBxlMafjGJY9oJR8s2LMDdBIuULukjP2RoWvZiEFa7EHwPtisMKyOjqGf/Y0R1IAlpZgm9TWjy9SWmFrxT4wDG4Rr+cFpVCMjczy8meurlhNw+OkuwOdY4S75Kb3v2rTje44yLghyyhnlexEd3ocyXO3ofU0wRfX98J37Ao3hFWq25Ea+IfDPE2hM6rfPq6knJrJlxE+eenvtubFFLXP471HyYIHbFJfgFOtwqzlfjdtvyvGzOr7CIftSx1l1Q2aeS3GAWN6f/hL27pUMXIiM93YeW/9kcRCxcupMTgATJv42Mzf/Z9psxnVgBMIhDFDNww== 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=xavbuV6lIwJY5oDAI7hT6YynOQprNT52DhNUM80TqUM=; b=Qqlgs4k6W7vU1oYSSH0o2G3r08tHhVgzqVLvUGT6coac25jRNy3WLsSzH8vT23KdQeb+zbHVy4AER5emBCo/y3KqgpQ4OxbLLEYIGAmE5qAAng4cWIYwEwFts4w816ektdUD6iSTw+7t234WFY2MvLqdpcZHt+w7DAYfqv/jaT1NgB31MdMym+Qihv2H5xDPwrFeVC+Z8Utw8cBUcmDgmrFsjsdPFpXj14OlNFqSTGN8dE2niPpp4AqlGHymLURjn2qEjn8zoGEUwjBTjklcDTW3aCXvQscQ4kdEO/Tmv1b6eZwsMCDcVEKpbHWouCdn414blsaL1D93t8bwLzs8+A== 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=xavbuV6lIwJY5oDAI7hT6YynOQprNT52DhNUM80TqUM=; b=nElZ73hHd9hUK3NY+qZIuvmBBs9y80J3yPumHmc5X+8aqNFkFAQdRM2KT1KvdnlCiL96LEJ/faHjb1/yoDc8KRi9nPmkFlkl3v0lrlnGjQcG4/Q9tYestmVNPfpQlHJOngesy1Td8ZllFNrIY4b47/vaFI5gvM6hiO3RGDvhrVY= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4633.eurprd04.prod.outlook.com (2603:10a6:5:36::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Sun, 27 Sep 2020 06:15:55 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::35c5:8c71:91f3:6bc6%12]) with mapi id 15.20.3412.028; Sun, 27 Sep 2020 06:15:55 +0000 From: Peng Fan To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de, robh+dt@kernel.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan , Richard Zhu Subject: [PATCH V2 7/7] remoteproc: imx_proc: enable virtio/mailbox Date: Sun, 27 Sep 2020 14:41:31 +0800 Message-Id: <20200927064131.24101-8-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200927064131.24101-1-peng.fan@nxp.com> References: <20200927064131.24101-1-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR04CA0178.apcprd04.prod.outlook.com (2603:1096:4:14::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Sun, 27 Sep 2020 06:15:50 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 44220112-fcd6-4ce3-481a-08d862accaa9 X-MS-TrafficTypeDiagnostic: DB7PR04MB4633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:114; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: taS8xliWKdWVYmmH9sIajY9fp/DERE3ERYPv3kFZ5phnJ+6TvVSIakbdQkn9UH8kXeNQ5gxZ/k/Jt6BbZBDna5Fv8rkUJOFlSAIKIdmAyhGQkn58Fyiyi11sqOuWOc+k4mrbj182hQaWYVBMPeyRlD39czuOo6WiOe9O8Ss6I0WNWeB+OUFP6/Ru1+KiHrtBxkTX6YgkgmAjUyprGEllNY8q1dBvPdhrsPwaDvUe58TwKqC9kUOIOd9prTTEXnK8PPxBCKupM4EGLxSWboI/XGhIRSXZxEVNjJJFwvsyu+CRUw11gVsGpwdiDdMYBlxfWpZSVGOgu4iAvJdTdG24KQsQqIqIJyy8bqkHQY8XaVsPfHLCtpmGD0a9WuLkXtDv 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)(366004)(376002)(346002)(39860400002)(136003)(396003)(16526019)(186003)(52116002)(7416002)(6666004)(6486002)(54906003)(316002)(36756003)(1076003)(44832011)(5660300002)(4326008)(8676002)(2906002)(86362001)(26005)(956004)(15650500001)(478600001)(8936002)(66946007)(6506007)(6512007)(2616005)(66556008)(83380400001)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WGmmeUrHI0B4iwTy5iVQlsfsk+KPcxoqmcTeUgyHqjtPdM6psVjT4USDYjhLTJHT4PNENmQVhS+LbIRAeCW4vdlrRgRU7HfbR7Rk39Mh4pfYMwrdgYeqPwwb83LWDPeXpdiG40PI0rR0IIz2T2XcT1cyWwa7VPnEovOkyMNsuCpjvb1CP94V/kBwnZU051EK2QX0gRmWN7kkbTtfZMYwxQvEq/BoUjf/AP4phzXC21KYTNhu9bYYtF/sm49LbPpFxToEctkMnDNYNc0blal+2csuySJS8EhO5Eu8k/1flr3C9o4RkEpJAUrnaj3YzGnSAvQ0sef5FBporssmnlrIXIIsnC1f9e8G/iRubWDWYuc6M7oz60q5a8/DRkKeiOI0jQmF5pK5NPqR8rI1sJyqCA3aiI78bsoha7z5AwuKF9YO6le3jjzA4HiNTKqevAbfPKbvpF95eUha83zvO+7JCrvt42uiCgmvLwcRx+3KThLYv46rT2S80TukzfOwEIZnMvIFAh/3DC8DH1o6YR/MApNw2dzTg5hVMNgo/xiTd9lmklvao0cHCxzPZ6eNCM1r8rN9+ZFhm945cntNRJi7MB/WqsFUTsM7A+pWURVyuULQZywpKGgEcF/3SXJtUT6xeV/rMBnwFBP3B1k8cPGMYg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44220112-fcd6-4ce3-481a-08d862accaa9 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2020 06:15:54.9132 (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: lbIvmLNX9QLrtmM6XEhDCbLHZvzOT1EwHEKC+rIgJrOabf1sOM/G3tHHdE6f2vJlsh2/8mLW6uMj5YEEa0TYJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4633 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Use virtio/mailbox to build connection between Remote Proccessors and Linux. Add delayed work to handle incoming messages. Reviewed-by: Richard Zhu Signed-off-by: Peng Fan --- drivers/remoteproc/imx_rproc.c | 112 ++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 0f69f3f745ab..c514d7ca7c81 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +18,8 @@ #include #include +#include "remoteproc_internal.h" + #define IMX7D_SRC_SCR 0x0C #define IMX7D_ENABLE_M4 BIT(3) #define IMX7D_SW_M4P_RST BIT(2) @@ -88,6 +91,10 @@ struct imx_rproc { const struct imx_rproc_dcfg *dcfg; struct imx_rproc_mem mem[IMX7D_RPROC_MEM_MAX]; struct clk *clk; + struct mbox_client cl; + struct mbox_chan *tx_ch; + struct mbox_chan *rx_ch; + struct delayed_work rproc_work; }; static const struct imx_rproc_att imx_rproc_att_imx8mq[] = { @@ -373,9 +380,30 @@ static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) return 0; } +static void imx_rproc_kick(struct rproc *rproc, int vqid) +{ + struct imx_rproc *priv = rproc->priv; + int err; + __u32 mmsg; + + if (!priv->tx_ch) { + dev_err(priv->dev, "No initialized mbox tx channel\n"); + return; + } + + mmsg = vqid << 16; + + priv->cl.tx_tout = 100; + err = mbox_send_message(priv->tx_ch, (void *)&mmsg); + if (err < 0) + dev_err(priv->dev, "%s: failed (%d, err:%d)\n", + __func__, vqid, err); +} + static const struct rproc_ops imx_rproc_ops = { .start = imx_rproc_start, .stop = imx_rproc_stop, + .kick = imx_rproc_kick, .da_to_va = imx_rproc_da_to_va, .load = rproc_elf_load_segments, .parse_fw = imx_rproc_parse_fw, @@ -458,6 +486,70 @@ static void imx_rproc_memset(struct rproc *rproc, void *s, int c, size_t count) memset_io((void * __iomem)s, c, count); } +static void imx_rproc_vq_work(struct work_struct *work) +{ + struct delayed_work *dwork = to_delayed_work(work); + struct imx_rproc *priv = container_of(dwork, struct imx_rproc, + rproc_work); + + rproc_vq_interrupt(priv->rproc, 0); + rproc_vq_interrupt(priv->rproc, 1); +} + +static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg) +{ + struct rproc *rproc = dev_get_drvdata(cl->dev); + struct imx_rproc *priv = rproc->priv; + + schedule_delayed_work(&(priv->rproc_work), 0); +} + +static int imx_rproc_xtr_mbox_init(struct rproc *rproc) +{ + struct imx_rproc *priv = rproc->priv; + struct device *dev = priv->dev; + struct mbox_client *cl; + int ret = 0; + + if (!of_get_property(dev->of_node, "mbox-names", NULL)) + return 0; + + cl = &priv->cl; + cl->dev = dev; + cl->tx_block = true; + cl->tx_tout = 20; + cl->knows_txdone = false; + cl->rx_callback = imx_rproc_rx_callback; + + priv->tx_ch = mbox_request_channel_byname(cl, "tx"); + if (IS_ERR(priv->tx_ch)) { + if (PTR_ERR(priv->tx_ch) == -EPROBE_DEFER) + return -EPROBE_DEFER; + ret = PTR_ERR(priv->tx_ch); + dev_dbg(cl->dev, "failed to request mbox tx chan, ret %d\n", + ret); + goto err_out; + } + + priv->rx_ch = mbox_request_channel_byname(cl, "rx"); + if (IS_ERR(priv->rx_ch)) { + ret = PTR_ERR(priv->rx_ch); + dev_dbg(cl->dev, "failed to request mbox rx chan, ret %d\n", + ret); + goto err_out; + } + + return ret; + +err_out: + if (!IS_ERR(priv->tx_ch)) + mbox_free_channel(priv->tx_ch); + if (!IS_ERR(priv->rx_ch)) + mbox_free_channel(priv->rx_ch); + + return ret; +} + static int imx_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -501,17 +593,24 @@ static int imx_rproc_probe(struct platform_device *pdev) dev_set_drvdata(dev, rproc); + ret = imx_rproc_xtr_mbox_init(rproc); + if (ret) { + if (ret == -EPROBE_DEFER) + goto err_put_rproc; + /* mbox is optional, so not fail here */ + } + ret = imx_rproc_addr_init(priv, pdev); if (ret) { dev_err(dev, "failed on imx_rproc_addr_init\n"); - goto err_put_rproc; + goto err_put_mbox; } priv->clk = devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) { dev_err(dev, "Failed to get clock\n"); ret = PTR_ERR(priv->clk); - goto err_put_rproc; + goto err_put_mbox; } /* @@ -521,9 +620,11 @@ static int imx_rproc_probe(struct platform_device *pdev) ret = clk_prepare_enable(priv->clk); if (ret) { dev_err(&rproc->dev, "Failed to enable clock\n"); - goto err_put_rproc; + goto err_put_mbox; } + INIT_DELAYED_WORK(&(priv->rproc_work), imx_rproc_vq_work); + ret = rproc_add(rproc); if (ret) { dev_err(dev, "rproc_add failed\n"); @@ -534,6 +635,11 @@ static int imx_rproc_probe(struct platform_device *pdev) err_put_clk: clk_disable_unprepare(priv->clk); +err_put_mbox: + if (!IS_ERR(priv->tx_ch)) + mbox_free_channel(priv->tx_ch); + if (!IS_ERR(priv->rx_ch)) + mbox_free_channel(priv->rx_ch); err_put_rproc: rproc_free(rproc);