From patchwork Tue Jul 28 09:31:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11688761 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 D321014DD for ; Tue, 28 Jul 2020 09:37:19 +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 ABA2320786 for ; Tue, 28 Jul 2020 09:37:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VwnDpjJB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Lr2wbsA5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABA2320786 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: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:In-Reply-To:References:List-Owner; bh=MlQgO7+hZ3g0amwAA9W1diQZbN9f8sFHBgdiu/AnDHI=; b=VwnDpjJB1tq62yBxxghOhO5XFx YGA9eEPmhaT+GQ0M8uBDmw7Clc46U18Bm5/jrYpGqF5WJdpt0IL8CveucLL4gyQLXDGfO1whGElb+ Z6O1UXFyDfmjsx/MMZs7VOxGE84vldH3BLdqPYrhlrLYKwYFWY2Ip/BBCEn0YwLhDXrdndQ4B5RoT /zJnPcEWalCH03Gn4w/72nZC7g/8W3gqd0YbNC2GZsbv1kzyq3krtziDA+Q1xLL2bs7h63ZAl/Km5 RJMWHEDWbMwbLZ7ROCBXO8tqvgi7cgtKuAJAGg11lvLpVg3WTYP4kbxNGqIM1Na9krbvGgwy4tCal IFZ/aXUg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0M1L-0001JF-SB; Tue, 28 Jul 2020 09:35:39 +0000 Received: from mail-db8eur05on2072.outbound.protection.outlook.com ([40.107.20.72] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0M1J-0001IU-TX for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2020 09:35:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g3FbfMmrlwIPe+O7PUwgrCKFGicyQdGG0Eaz5EHHDqTEjsaNvbhX1uR2iNNN3YRJHeB09WV7FZuqu/yUTVbiC8x3cr2sWwst/BeVJb3JSH5q4zR5odfUDHAVX1DSxV9mRLLSmBJCKHEAJw0qIMpBZpcRnA79yTG5yIIYAc2WAVAX+ku7BtEd8Nkek5LsYVXB9g9ptEbQpE+4VrOZHuNTRh5SX3c2ULDPYaV/XGtOsJ6zSkumSkE1L2FRBkaq1oeZ0YishIwxPM6f7HCA9HKe74xGcuApJ5nK0v0OjHHHiHUCEjPS7boW8rvHX9g6DdxCgcQngl7jOhQnxPMJnftHwQ== 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=tfRm6nqee1zmGaYQWM9juc8qUzO05Kv9PEjJTwzzaOI=; b=UsmPSvwi+09IHZ0C3JrwvwEwr9yslA9HTrlLNUNqJJ8PUZe/16l7KLhqSKhEYk7gVjRAhpn6ioub5iSkFCAgcgEdUci70V7SpqzYLlUigtMFEGEH1SYAZ45ha71OhkAs3BIXqh7yuuUrsl4b4jcAKFE5fJJhQVGURtW7uyaKu0bx3kJ0z4aaOzLfGyB5lziQMmU4Z38WKysjxLsHd8ZtOPQaJ05HRwqrP7p9fcfdGTz4I54XhFS6bUb8uXRtoYAwHSm0cbf6SE7BxiOWRZUZIFuhyDtSyzU4oAN9gY9ai/ZVej0RrJiqwDWZwFoJykOGL9uctaGPaSb3/kvPNxClhw== 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=tfRm6nqee1zmGaYQWM9juc8qUzO05Kv9PEjJTwzzaOI=; b=Lr2wbsA5mJR8WUQOWnWbP4L/LpypmgIpHhDS0Dc3YZbxrKwHo5w1lJ4C/lTy+9hBIyAtTl+SKNjSsD9EX1ibPUUW4kpHYgLWcBd/FH3sGEMoxmfaQ9NE+8XhprMGufIJDrf7W2MlhWL6LEA+/A/4Hu3Cj5LO8PMN/6dhPSRxIdk= Authentication-Results: wizery.com; dkim=none (message not signed) header.d=none;wizery.com; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4490.eurprd04.prod.outlook.com (2603:10a6:5:36::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Tue, 28 Jul 2020 09:35:35 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::2d36:b569:17c:7701]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::2d36:b569:17c:7701%4]) with mapi id 15.20.3216.033; Tue, 28 Jul 2020 09:35:35 +0000 From: peng.fan@nxp.com To: ohad@wizery.com, bjorn.andersson@linaro.org, robh+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, mathieu.poirier@linaro.org, o.rempel@pengutronix.de Subject: [PATCH 1/2] remoteproc: elf: support platform specific memory hook Date: Tue, 28 Jul 2020 17:31:12 +0800 Message-Id: <1595928673-26306-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.7.4 X-ClientProxiedBy: SG2PR06CA0101.apcprd06.prod.outlook.com (2603:1096:3:14::27) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.67) by SG2PR06CA0101.apcprd06.prod.outlook.com (2603:1096:3:14::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3216.23 via Frontend Transport; Tue, 28 Jul 2020 09:35:30 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2776d49a-1e91-41b2-de18-08d832d9949b X-MS-TrafficTypeDiagnostic: DB7PR04MB4490: 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: 0zdRTzd7IglJQ4JbGK9wQbPZItBu/NG7gXi3CUAuv1rAmp6+cEnpL1+zTbyHsLz5IgB604mp/riCw7DNgAajufzTBfoVFXVHO/Q3LfMCHr/bs7r3tjDhtHVTCaFsf7KvHnFhsJtOc3Aa/9PtipY+yPfn+gtT1aP9hy7T/VUwruS8uM+6EYAVoyVE9y6JkTYu7w5v+de6NGH8wx75WGrSY75wFqFuvZBfNKqUSlbAl9UOTUKHg4QD4MZtcU10ctuM2gbtywm3ag0wH6qilgTSBDudJl17TL5d3gsCv4VPMyhUm55H4ZgUl6R171F6aptzWRX8BxfMvAiOJkSKaNmvEjd5robgN/jkaVEXqgEoeeB38c4y1bIlwG7iGBt+8EI+ 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; SFTY:; SFS:(4636009)(136003)(376002)(346002)(366004)(396003)(39860400002)(83380400001)(186003)(956004)(478600001)(6666004)(16526019)(2616005)(36756003)(6486002)(5660300002)(4326008)(316002)(52116002)(6506007)(7416002)(26005)(8676002)(2906002)(86362001)(8936002)(69590400007)(9686003)(6512007)(66556008)(66476007)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PlwMI6gbTcuYwA7fUFmrElSuN/A77UXphxaXzuJVNRqNg0dd2FYwI2sm7n8EATwqAVoL7mCgR3b5HI/ulHm30TEq9nPoPrDgqPLAEOIMzesCnMyyPSm7naE5FSNKHrVzlk3DwoC6qeU9NK+X620TvAgveys5zw1k/ciA/UKM2OR9A7OhffMIUa94XEkvFAzZ0JswEwUqtpNqZv4XpanRanmnfDbZauSDQvzkuWZqNqNBDqBBbCyY238WrwWehr+SMwhW7l5e3wNW7kMh0e/iIMZfHpDpXrrsNDU4eaVYc1j12S6MZv3RFgm1S8YE8mCaYjO5Dr00Iaq1gv6sE8WBoIYe/AoTumHzd7veqWzQ6p+bDXqe3AzNqL9i3PMqonFqaLBX4Iaq4p5Wbn0mKyhWEkL8g8MV5XIlC+hGzBImMH8F8OlGXxVUMTyoqI5bTnlQFnCEFuknY0OGwHnF4HgLw1h5Kzy5vuM+0653m/QdpS/PbMs8Rb4ptiD70HYuzab4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2776d49a-1e91-41b2-de18-08d832d9949b X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2020 09:35:35.8578 (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: zACKdwNM1dfvdkVsAlNc4N5kb4oDUJkUzc6uPQXLd1VT2gNZL1iALyO1+k6YxwWfYN8bksTDGrx4nbaZRMWAUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4490 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200728_053537_991189_38DC0252 X-CRM114-Status: GOOD ( 15.12 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [40.107.20.72 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.20.72 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 , linux-remoteproc@vger.kernel.org, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Peng Fan 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. Signed-off-by: Peng Fan --- 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..f442bac64432 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->memcpy) + return memcpy(dest, src, count); + + return rproc->ops->memcpy(rproc, dest, src, count); +} + +static void *rproc_elf_memset(struct rproc *rproc, void *s, int c, size_t count) +{ + if (!rproc->ops->memset) + return memset(s, c, count); + + return rproc->ops->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 0e8d2ff575b4..88fc9643c1a8 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -391,6 +391,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 *(*memcpy)(struct rproc *rproc, void *dest, const void *src, size_t count); + void *(*memset)(struct rproc *rproc, void *s, int c, size_t count); unsigned long (*panic)(struct rproc *rproc); };