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: 11801801 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 C8DD6139A for ; Sun, 27 Sep 2020 06:16:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 776D1221E5 for ; Sun, 27 Sep 2020 06:16:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bQM4WP9d"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Ra0wWNOw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 776D1221E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OSGEamofyI3CmWAdTKkokAAvDoAsenxWyO6F1tk0p+g=; b=bQM4WP9d9g3Wwu7c8YZ4t16kt bhSvNoJdHBnzQBkUATyaag5cRDrdMeZwbJ+z1TpWqPUWeAZI7b+8xgrZk+jy2sFk03gyJ6xEPHrlN RRXFDFonUtWQcgQdgvWUjZd9TTFXKIZKA/ZXXjPsg2osocylhlS6pDtXluL2SAK+sOLyOSEfoxri8 kuQz8+M3BLjZDmvUTdIsj0ORzOFqJQl4o5ClanEb3XXEmzPVpJou/g/vO0Qymhw+JbR+rYWz3k9oB ltKtMK8uhZcKqqFO4mH94IEGMmIGjrQGeoPAYjdADihUU/3skMQxNdI27PPxO1j0LdqN0GxpRUzwy rnvTij/oQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMPyC-0001m0-RT; Sun, 27 Sep 2020 06:15:36 +0000 Received: from mail-eopbgr30044.outbound.protection.outlook.com ([40.107.3.44] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMPy6-0001kG-K0 for linux-arm-kernel@lists.infradead.org; Sun, 27 Sep 2020 06:15:31 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200927_021530_665469_D2BD20AB X-CRM114-Status: GOOD ( 14.41 ) X-Spam-Score: -1.4 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.3.44 listed in list.dnswl.org] -0.5 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.3.44 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 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: Peng Fan , Richard Zhu , festevam@gmail.com, s.hauer@pengutronix.de, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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); };