From patchwork Mon Oct 21 13:31:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13844201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 540EED15D96 for ; Mon, 21 Oct 2024 13:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ssq82j9Qbkmg1cRToienkjgOiLGK2G6nnz6q05Vjq1k=; b=cBlb39hVJEp459ydbDfixw69th KIybR41LJaJL7kb6FXn5ExgGVqQU5k/wolV60jWf2heJM/25r6mxw1fpdjJFImW7eMAycoi+VK+Ef VFkBltqCsyFr1dvqUgMXJKD/nFNAYfUjrgHuxHV6y1TqKeBIt/ZebSBSwtuupbNG7QfjXPIMGai1G 7NUnUHb2NYdAe8CLetfHuLgPVGY6uN7hEcmbkF23srdV6/vDB1saI/8GkKq7R2DjBsIo8BgP83H9X JxCmIglCrarort6/UtTVVL/mdHsRNIaEClatz2Tx09y1BZPFaMELL0jNni7vhg23KKwm6xiiPtyPa X3uMIYaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2ssT-00000007Vn3-24U7; Mon, 21 Oct 2024 13:55:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXJ-00000007Qhx-45bm for linux-arm-kernel@bombadil.infradead.org; Mon, 21 Oct 2024 13:33:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=ssq82j9Qbkmg1cRToienkjgOiLGK2G6nnz6q05Vjq1k=; b=j+/vQDcQKTGAQJBWfaezohsgOS DT8xpEb91/azSIisD9qeghSRnLnivTufWldmCp/VMRvZ2R0ZqX7X6BK8n3K23CbwjiM54ayxUqyge h+d9Fu3urTSy37zNU4nDmkN7Z4bzpYfgpsPrtad2kRdGLl5xynb5ZKJGTpqEIRPSKJfP4ynxFVgVP sZIWcE2tApO1zE5HaF/zAQktpXuularmiuAUCELmHEuDsvEVaYRod5dbNmyNQJytPeSOkUQs2YZD8 CVuSzBfnlNnTQOrAcHVm2ZY7Rc41VscSx+4Rz1N8LQn+4A2vFRf63dQd+QDndCkkCRzr2AD9pEvE3 WuGvxQxw==; Received: from smtpout34.security-mail.net ([85.31.212.34]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXG-00000007xVQ-0Ge0 for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 13:33:28 +0000 Received: from localhost (localhost [127.0.0.1]) by fx304.security-mail.net (Postfix) with ESMTP id 134962A3EB7 for ; Mon, 21 Oct 2024 15:33:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1729517588; bh=uICJ8KJLfrjysdrGIsRkiSWaussGKWwSuhXsz9g1G+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bDTdP4Zn7uDz8h9jCbZkZ0jPy7ya+AycQUHPxA7nCsyRp34sLFg4DMFirF4jtpsyK LzWViO3z7IXzo7o9ao5pQftCpWO1IVq/iLjWP8xhFUf+8/6zE6c3IOinQBLsMIzZCB YD6Qsc6nWDnLc57k4UtdwwgCnJxKxo5D/yGnECU0= Received: from fx304 (localhost [127.0.0.1]) by fx304.security-mail.net (Postfix) with ESMTP id B4E092A4530; Mon, 21 Oct 2024 15:33:07 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012055.outbound.protection.outlook.com [40.93.76.55]) by fx304.security-mail.net (Postfix) with ESMTPS id 24E5D2A4528; Mon, 21 Oct 2024 15:33:07 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by MR1P264MB2339.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:34::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Mon, 21 Oct 2024 13:33:06 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%3]) with mapi id 15.20.8069.027; Mon, 21 Oct 2024 13:33:06 +0000 X-Secumail-id: <10612.67165813.23051.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bG8lQkaTl9BFftfNkXkOtqvHZEMhyUfN10o10RkEpwEMvehp0pTwzaXgfXIJy8BMTLDRDT1TLekc691ADk0pNElvaA8mNWuK/kTlkn6xXKLLWNheAYP9HNhNFEspW29VSDWzfKLaNGAPSpDZIMpWRljrwnunehNcsWUZYY1x4iOaw5dQzWfaeF3PVQk3zYBoszGG9UKege6kNt2ed/1Ty5WqMsHu9cQAXjb84xHf1gKAMYCpWag/4AuPBzA6HExtgRM9CXQ3G2y0PFkf32pjipczl4fj0LQhg5uaHzbrORK/lT+ypCdtxp7I1QVdj6U5SDK4uXaiyqO+lETJ3dRiRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ssq82j9Qbkmg1cRToienkjgOiLGK2G6nnz6q05Vjq1k=; b=LszJjhX2obncatXYEPqhSzhJb03MgimIfgkVrQVCHyWCS7NuWDPjtpB+ioYfVrR931G8tYnv8/AdyhB0eSqfnX4f3yUtUmTsqeYkff8Cr9HTyUhSPoCvcwJXeonjw5Tc/WmglP72sl81qQ3j9QAYJR5vKW9lsW10Jdjvf9sYh0ZlzTQ0N/a1D02ZBoyGj1EhM2DkIJICAOgQbfv/hKkS8iqo6vb2FiGheTmh5qrtzSPzmpVgDQAQETdG10wz4UuEDFbI5M2F8hzQ6IM3szsLO/oK33AEAdSuoHT/6YBoZi48dwjjDdrjN0AWhaA3cz1kIx8MqLegCol+wBu28Om4DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kalrayinc.com; dmarc=pass action=none header.from=kalrayinc.com; dkim=pass header.d=kalrayinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ssq82j9Qbkmg1cRToienkjgOiLGK2G6nnz6q05Vjq1k=; b=OwNwMtRCqmAc5i3L8GL1tB3wuttljJvSz1P9Bc/IQsA9W1u/MX3yqZQwCWXtZVWQain9owl5iNTvF4Nf/JSMJ990qgJFFmYztJ76kbKxdgWqbIwFhqffnwSITzZM1uA3K7ascd+2BLHWQ8/a620Q+Ood8TeAYQvf+7jNc89TJyRuFNE8iKLNkvOaMhM7HjnqjJJID/fgmlFx9pj1e9qo7rGyUJ8QHjVjpwCFOTSjsTxTYTW7rbBNuLjJsjqoW6eKgP5DjdPE4xPSvjh2G7/BRW4S1pC24/18nBS74EP+zrPYCgVEJLXaV9KO4Q9hAu+8F22c5qFB/DNZmwp9yQ4XPA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kalrayinc.com; From: Julian Vetter To: Arnd Bergmann , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Andrew Morton , Geert Uytterhoeven , Richard Henderson , Niklas Schnelle , Takashi Iwai , Miquel Raynal , David Laight , Johannes Berg , Christoph Hellwig Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Yann Sionneau , Julian Vetter Subject: [PATCH v10 1/4] Replace fallback for IO memcpy and IO memset Date: Mon, 21 Oct 2024 15:31:51 +0200 Message-ID: <20241021133154.516847-2-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241021133154.516847-1-jvetter@kalrayinc.com> References: <20241021133154.516847-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::20) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|MR1P264MB2339:EE_ X-MS-Office365-Filtering-Correlation-Id: ddda53a6-32b7-44c0-261b-08dcf1d4e517 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: 98hQq+5lkcCAg/EK51k5jG1vryOKtBAkUUflHalRWC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F6QCaQ0xUVqiqaAqCv32FnIsop2n/ACFZSI7K4b+B17mxbczHBP6YTNgh24bypgqmJdfH4iJAvqePd/nPGdsU7l57HZVFT8aNbwTFa6usoImJtbVx8ymfQ53UIYnVOg8dKg0qxPQlEMJEez/fFSsE/IeH9rv6KiSrAupyEknxAAJQgT2sw1iwcrxvDNziMl3fOEs3gbtao49u38XLS5YfUvIzci/cpS6UFwTwQ26+ztUkkSHhC847nZiRC9Wpv43yJiv5M3MIynsrpQ7TG9JnX0ReKVlWvN5DRJ7pmDEKfphb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3ubZV3yvhvw9wEueJwvx2rvWza3xDYpADHyqSkXK371JOYWP9oGN6VVYJuda9B38VAjvoPGyBUqcGTzzl6fY9gZ7Xl6GWE5qGKq0oxodViUjDeeHUmUgYltC8nPEsx4PWs4fpw41IHN0My/xDVjlpoU8bEbCqyfJVlA0NHIDS0micMef1eeYM1G5hd35HwRNSDROODshfeIAyoD7VBepB3jUtZ8pn/DRaB1cauLRurl3LASNdDWIpy1UGyLvei/8dEGF/IySipsdrHfG4eZTg/qMvs1bvCWCPkQgFIaW3rNPa/20Nlu1Zq4wkrdKSUq5qc6noIFUEWt3wPVSvKHIvwf92fr4Bu4dZaZjfrTuUJ/6teCFUEYpz3ZB2HdZGz6upSD1xnrWsP/zN8y6xSdYiqlNaymdPjlV+y/OkC8jdZQqOTvn6eUO27N0uIZVMbHPgUaSbaWV65qyvV3SzyiLrKLh/YsP+yEl6QhpQRyFzkBLnEGutrJar60H0+xyieCE2VBBqdV5/eBEzMX1tPz5X53/KVfotbOHv7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Tenant-Network-Message-Id: ddda53a6-32b7-44c0-261b-08dcf1d4e517 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 13:33:05.9537 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8931925d-7620-4a64-b7fe-20afd86363d3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8kIwMtCS1VKi8eonl3y2a3vllahimyXhuL5sXFvpWtOeJvdK/EkQQUaUiK9GUHKlpTlzrPvtYQtZJFmPbRfA2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB2339 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_143327_128575_61EDB246 X-CRM114-Status: GOOD ( 20.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The fallback for IO memcpy and IO memset in asm-generic/io.h simply call memcpy and memset. This might lead to alignment problems or faults on architectures that do not define their own version and fall back to these defaults. This patch replaces the memcpy and memset. The new versions use read{l,q} accessor functions, align accesses to machine word size, and resort to byte accesses when the target memory is not machine word aligned. So, architectures that were using the old fallback functions (e.g., arc, mips, riscv, etc.) now have more resilient versions that take IO memory constrains into account. Moreover, architectures with similar implementations can use this new fallback versions as well, not needing to implement their own. Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v10: - Removed iomem_copy.c again - Updated implementations directly in asm-generic/io.h - Updated commit message to reflect the changes made in the patch --- include/asm-generic/io.h | 116 ++++++++++++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 20 deletions(-) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 80de699bf6af..00cbf8587586 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -7,10 +7,12 @@ #ifndef __ASM_GENERIC_IO_H #define __ASM_GENERIC_IO_H +#include #include /* I/O is all done through memory accesses */ #include /* for memset() and memcpy() */ #include #include +#include #include #ifdef CONFIG_GENERIC_IOMAP @@ -1154,16 +1156,40 @@ static inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) #define memset_io memset_io /** * memset_io Set a range of I/O memory to a constant value - * @addr: The beginning of the I/O-memory range to set - * @val: The value to set the memory to + * @dst: The beginning of the I/O-memory range to set + * @c: The value to set the memory to * @count: The number of bytes to set * * Set a range of I/O memory to a given value. */ -static inline void memset_io(volatile void __iomem *addr, int value, - size_t size) +static inline void memset_io(volatile void __iomem *dst, int c, size_t count) { - memset(__io_virt(addr), value, size); + long qc = (u8)c; + + qc *= ~0UL / 0xff; + + while (count && !IS_ALIGNED((long)dst, sizeof(long))) { + __raw_writeb(c, dst); + dst++; + count--; + } + + while (count >= sizeof(long)) { +#ifdef CONFIG_64BIT + __raw_writeq(qc, dst); +#else + __raw_writel(qc, dst); +#endif + + dst += sizeof(long); + count -= sizeof(long); + } + + while (count) { + __raw_writeb(c, dst); + dst++; + count--; + } } #endif @@ -1171,34 +1197,84 @@ static inline void memset_io(volatile void __iomem *addr, int value, #define memcpy_fromio memcpy_fromio /** * memcpy_fromio Copy a block of data from I/O memory - * @dst: The (RAM) destination for the copy - * @src: The (I/O memory) source for the data + * @to: The (RAM) destination for the copy + * @from: The (I/O memory) source for the data * @count: The number of bytes to copy * * Copy a block of data from I/O memory. */ -static inline void memcpy_fromio(void *buffer, - const volatile void __iomem *addr, - size_t size) -{ - memcpy(buffer, __io_virt(addr), size); +static inline void memcpy_fromio(void *to, const volatile void __iomem *from, + size_t count) +{ + while (count && !IS_ALIGNED((long)from, sizeof(long))) { + *(u8 *)to = __raw_readb(from); + from++; + to++; + count--; + } + + while (count >= sizeof(long)) { +#ifdef CONFIG_64BIT + long val = __raw_readq(from); +#else + long val = __raw_readl(from); +#endif + put_unaligned(val, (long *)to); + + + from += sizeof(long); + to += sizeof(long); + count -= sizeof(long); + } + + while (count) { + *(u8 *)to = __raw_readb(from); + from++; + to++; + count--; + } } #endif #ifndef memcpy_toio #define memcpy_toio memcpy_toio /** - * memcpy_toio Copy a block of data into I/O memory - * @dst: The (I/O memory) destination for the copy - * @src: The (RAM) source for the data - * @count: The number of bytes to copy + * memcpy_toio Copy a block of data into I/O memory + * @to: The (I/O memory) destination for the copy + * @from: The (RAM) source for the data + * @count: The number of bytes to copy * * Copy a block of data to I/O memory. */ -static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer, - size_t size) -{ - memcpy(__io_virt(addr), buffer, size); +static inline void memcpy_toio(volatile void __iomem *to, const void *from, + size_t count) +{ + while (count && !IS_ALIGNED((long)to, sizeof(long))) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } + + while (count >= sizeof(long)) { + long val = get_unaligned((long *)from); +#ifdef CONFIG_64BIT + __raw_writeq(val, to); +#else + __raw_writel(val, to); +#endif + + from += sizeof(long); + to += sizeof(long); + count -= sizeof(long); + } + + while (count) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } } #endif From patchwork Mon Oct 21 13:31:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13844202 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF1ECD15D96 for ; Mon, 21 Oct 2024 13:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=k/Pgfr4aqWNaoWCaK9VM3FAG6Mrhm2a/4ETZWcrPJJs=; b=f/rrmoA//7M3z0SSFbExxQ7WSD y18KjQv+FsLqLjiMS62ne/EesGYW+iMp2V7jWp93vU7xH0h7OovDQnbUOr1cJxdmYSX6LYudCzz/W hUtVL7GheEHMPDgIJ8k0G3hI/j4m10xEzWgNhP/njA6vMZRIsT2kcChmboMS6YmgdRw5isuVOxlu1 bhJPuNMziHLWMbSuiN9Eza1mifP2Wn5Ocfv8I8Nmdr/cfYfOhIuRbzh+vFo8YLtXpodE/uq9tEf71 A37ArNd+mrALIVHG3fMA+DpUghRIL6hA1rKh90D49GlmdSk6VHzLA7MSHYgLbgFPsq82oLfM4sZ7s RIQHsXUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2stv-00000007W4z-3U5G; Mon, 21 Oct 2024 13:56:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXS-00000007Qjw-3na4 for linux-arm-kernel@bombadil.infradead.org; Mon, 21 Oct 2024 13:33:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=k/Pgfr4aqWNaoWCaK9VM3FAG6Mrhm2a/4ETZWcrPJJs=; b=coB1BGfUKiGDTWxlZrMhxMYPez T9o7PHyutbO5FFs4Ej7Ue+YUGe+ZCqLN13OvJ0oBcGvGHxI/sAYV/1gnvF/dgnqSqwZxE0t7G66mI nv6S1W/1DV9F+ar1phsHAeoIsXqBUdm0f0sqWSkiLUWnCfiexkQbQvyBcXTaCLt2Ahp2dzg/1QAxJ 8Y3WIeSz2rcQgp50jBAl6BHTNGiT9r2WdokXhtDGEF2/Hr4Oox7mcjBDq9MERb+G6iXPPQhPTL79a UhVrD4R9Yj9GV3P8iFt/pgdLoZ7tIO7LfRfsFnRJoVkavhUDh9gy3NFCc0qNTVhouIyYmZ56bDS0R IKv1jZOQ==; Received: from smtpout34.security-mail.net ([85.31.212.34]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXP-00000007xWn-45ZD for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 13:33:37 +0000 Received: from localhost (localhost [127.0.0.1]) by fx304.security-mail.net (Postfix) with ESMTP id C852F2A414B for ; Mon, 21 Oct 2024 15:33:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1729517588; bh=/ocSKZKP1X1oscswsJlqywTbmenaHDpKiNI1VPu/Qp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Omjxj7MlpOpYtYHF/CtwYtN6ApmbbScLxy2FFjfT4DQyTHAYPtTVTCcpLmbkSOZo0 AjlO/QaTaE7qzXEs71i9Xyuw2eClX8BXFfOV7YX0e4Jbz4Dvv4vTlDrpqcs8oBty8G SCNuS70cNmHVsI9hIY8YbF9XGJqOA6XU0TwBzvso= Received: from fx304 (localhost [127.0.0.1]) by fx304.security-mail.net (Postfix) with ESMTP id 8F6772A4580; Mon, 21 Oct 2024 15:33:08 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012050.outbound.protection.outlook.com [40.93.76.50]) by fx304.security-mail.net (Postfix) with ESMTPS id E7A2A2A3BEA; Mon, 21 Oct 2024 15:33:07 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by MR1P264MB2339.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:34::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Mon, 21 Oct 2024 13:33:06 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%3]) with mapi id 15.20.8069.027; Mon, 21 Oct 2024 13:33:06 +0000 X-Secumail-id: <106e4.67165813.e5c9e.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iOEwvfpp4QNRW6gno77VwtnPc1kRrVfoUKXBbtcx3oSxzZw91WvEJhRk9ytKQd9byZx5ftZBhPiBYnVtjn27Yhnf040F7hdw4Pwt+n3Tg+YnnE3il/qKZ9EpMc4g/jbvqyzf6gbJeYk7IAED1rYtC2pXXGLAy7+MthQqgZtWegFsUqYLrBWq2xM7IPpT2S/j1RoXgfN7Ye+g+f4lIMbdkLIgIWzmqJuRPW8iofSqbR93fd2zTuEqPlaBxHoDoJsB03ogs9LHs3T0VwIELxjT3b3WM8F9x0GAXEoQqi/68Gc3m0SZ+scBtaVCupg/jFjGM3Wxo/yxbN06GH1Ei0zw+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k/Pgfr4aqWNaoWCaK9VM3FAG6Mrhm2a/4ETZWcrPJJs=; b=okkVWtDIhjrzPP/MXE9GnmqCzMR0tA1SpCOspsylsKHZHTK0+xYpzafYplbrz4XUdEc0VZpb9PuaAj5HmQcRd0CeOWfa42bqcv9+7ManuT7WOcp+YcAzLuJL/Itp/cOdRb+5s+Njm5UfKTivNKq3WsbO07AcN4iHCRGaB+ANToVtUknNMIYGqCYU1j5GKyUGPtayFxz1blR7xxnTzfLIHSceyxhZp6+Uld2bv8+IUsDpufMrKKQ/LGmzawa073iX8/tllbSlhcpku02aWPBKEGtn5DVDQlikKHY06ySPAExOq6WeTuGuocz1oM1VoSJof/rUPs9uS9l5JlK0omMIgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kalrayinc.com; dmarc=pass action=none header.from=kalrayinc.com; dkim=pass header.d=kalrayinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k/Pgfr4aqWNaoWCaK9VM3FAG6Mrhm2a/4ETZWcrPJJs=; b=L/J9OjrLY8hmAKFnRwd9IQIXt/O9SLNkfcmhJhF96apdywjybuDg6m4udCjGJRe8nMqFcGBWV4fFoRVVjI+T8gmIbkfCIpzzDwE2RVc92RTExsiXxcD3CWNHL7PpScuN+YqMqRXsY8uUR1wr+hr0edLeUbHpzm5+fTuXGra0hqY6K3q9wlu8dXGTFX7CoIbzRuarFQ1/q5pR1N4njETbLzhEQRKVLalloXD/NOLFcEe0eRxB/giWM7UBgkm1YmPPckqZDoy0hY87mMtxl6ebCSN9tABv+IGXfU71uvvLfptOW+eyWpSPkmxkxtRUEnAqhMRAUPLnhp1NQPFcv5ID4Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kalrayinc.com; From: Julian Vetter To: Arnd Bergmann , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Andrew Morton , Geert Uytterhoeven , Richard Henderson , Niklas Schnelle , Takashi Iwai , Miquel Raynal , David Laight , Johannes Berg , Christoph Hellwig Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Yann Sionneau , Julian Vetter Subject: [PATCH v10 2/4] arm64: Use new fallback IO memcpy/memset Date: Mon, 21 Oct 2024 15:31:52 +0200 Message-ID: <20241021133154.516847-3-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241021133154.516847-1-jvetter@kalrayinc.com> References: <20241021133154.516847-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::20) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|MR1P264MB2339:EE_ X-MS-Office365-Filtering-Correlation-Id: fc60c16d-29d3-412a-034e-08dcf1d4e59c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: rjEBdPkcjo9OxI80XBkwvNTCZtI2Ptdbu5x9pib1LLPRJz+YhwzOgfzvcb4Jf+Yk57mGGGPRSkjczQb3VqHsuDhp1wvY9xe+K4y94KgeQXqsw3CML89qnXu2KjwlnLJVjzN6sQJCJ3lfAcJ7Al0dZjAR7FC81GjTAZ3iwsuvCbbJa/PHmX5agOsCjJAFKxVtF4eHa8qZgAVWRo+W3px4/2iUpEnwWjZZQDa1+davy/bpyXw96RbD7hzD965gQbPXWH6XPTC0WnYnr+HEkLnEUVRXVF0a16rM3vOkLIm1Mb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4cZ/GBK6b8CoCkO6kyqEZGMe X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kihkfdOx2VIAk8sd6cb64EACsa7B02KKJJI5DBhSQWcj5rDnOImgN0F/u7ZDariI+7AJa/xwgoME51qCJUDAuX/EsgV4qoHFnXwpSV9n3uh7GeNivH7jZk3lPbaU51rB96vr3owAlBj/M/G+Tba/5EHMIe8XO7Vvl39zFgvAHThEef7KhpdLGfom8TygzLiCx8/LfcFoDAY8Mzvp9GwvMjutSouVcqU7RckRthDlPsA9I3Ky2aF+wpNslnJbgS/6IbYp7HL84FvT2+3CpBZ/w/HJh0GucMedGWGakG7R0TcOzcsMsN7/7BuX4W9JxTKdWUuEMbOzfgmP1STANPdPsdhSl4A+MnSwcisUzhPFJM3mxvfTZJtcJ/c4t+o1GeND6pKOkKJc6nMcwtDJDQknqBQf/81dX6A5/LO+039QK6GHmANKln0Org51p/YTRrwJ16elK6bsAGGcMkQr28NdqFXBX43wzprQcbWA6EG5RfNeQR0Na5DGDcrGhMgWcSTKXuTbn/tas7piU48WOyHkBkXxnp1dj5Chj6BcMOWmjD8GeWV42rkc/CKR4UorT2HIfZGJZ4cS8eVizjk+6/aeeZqOE/3CUISFjqlHHt8OWPa6ZLstWut52jiqvW5Z/qa3eG95EbPZ4aCijHMB0WSr3riAFJht/xTFJJwop6IR2c1R0pj1Eu8esnBk0ydW01tlmEL0z0mdDk3G5MuKMeG2EML226XLPYlZEfimyhP+FaJhWtCFtHLPtrGOlpTHS7gSfZK5Fb0eX//trk4SejOoN8IsHlw24sTme6RVVRolrKbJCBmsDFpGjonQ+iC+frSKRc/vkNDF8fQLyJldqJ+HIO5ggifZaVL1oh1FfozqO/T61nmHb8EJNX+weU8/Saqbysnjyp4xzbyyuX59fG55WbsfS/room7fy7w+PnCnt/wAehMyrkY8Jhsg5Rsa6yTl lcJIqhh64KnRIcyweiuNTqMvwGbc3vaYresH62/yTC7cTPp3xiLuWT6t1MuY6l9judXeicfHtmDCKkGXQloZRUb+/peYTKy6oY6bFach1Np0CaMwhWQO5DsudAQdPeY0bunjrVRSI9w7ShVMZA27pjolLbf2HFPbOM8FbpPUAgcpo+oHMm3qqs6EW4+tN2gE+3JO4kKHS4nO7mO5goNSP/6g8W31m6Zei6t7VVav6LNWZknjD0i0+27b/y5HRp2Q8JgjNx+80f3ihKHpOE8S1Hx6fyX89vC8QyJL2piHJWx/8GfYLiJZtNuxZZoHNKsiLHntMsJD8XM7obZUrGmmq3Nki8qXrJt5qtB+rvT3DHEKGLZ2SGGv5tEYOZPdn0sJANdiaM8yVR3LIomlCaBcRjm16FzxnXIRWX/BaSsTGcaT+nqM/rgiwRUPLwB/3gWBfV+CNlp88dwu4I28OlIV5TJ8S5wcRGlAS90jmqOVRyTeKkOXSgxYPcr3Rgtfqlp0PZte2AZz9FIURxwUwuF6n95ZBqUzDWZ/4L4YBw7XE+cQPz21PpjZcgJ2HQUq6knq/BXOlnonZw0S51jVqIvrhciWsLqoGKl5uxyWTqI4XaBFOefzxkFKLYIvShtxQA4B X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc60c16d-29d3-412a-034e-08dcf1d4e59c X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 13:33:06.8276 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8931925d-7620-4a64-b7fe-20afd86363d3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PnaTTzpXO2SCGPJxy8dnp5t4ejw6OX2zAQyKgRia29BmnLMnMhtUkjDrMZY6XkKitmJmV5j2GQ7NYJSiNS2aow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB2339 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_143336_177056_04D491D2 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the new fallback memcpy_{from,to}io and memset_io functions from asm-generic/io.h on the arm64 processor architecture. Reviewed-by: Catalin Marinas Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v10: - Slightly updated commit message to clarify that on arm64 we now use the fallback from asm-generic/io.h --- arch/arm64/include/asm/io.h | 11 ----- arch/arm64/kernel/io.c | 87 ------------------------------------- 2 files changed, 98 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 1ada23a6ec19..463067bffdfd 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -128,17 +128,6 @@ static __always_inline u64 __raw_readq(const volatile void __iomem *addr) #define IO_SPACE_LIMIT (PCI_IO_SIZE - 1) #define PCI_IOBASE ((void __iomem *)PCI_IO_START) -/* - * String version of I/O memory access operations. - */ -extern void __memcpy_fromio(void *, const volatile void __iomem *, size_t); -extern void __memcpy_toio(volatile void __iomem *, const void *, size_t); -extern void __memset_io(volatile void __iomem *, int, size_t); - -#define memset_io(c,v,l) __memset_io((c),(v),(l)) -#define memcpy_fromio(a,c,l) __memcpy_fromio((a),(c),(l)) -#define memcpy_toio(c,a,l) __memcpy_toio((c),(a),(l)) - /* * The ARM64 iowrite implementation is intended to support drivers that want to * use write combining. For instance PCI drivers using write combining with a 64 diff --git a/arch/arm64/kernel/io.c b/arch/arm64/kernel/io.c index ef48089fbfe1..fe86ada23c7d 100644 --- a/arch/arm64/kernel/io.c +++ b/arch/arm64/kernel/io.c @@ -9,34 +9,6 @@ #include #include -/* - * Copy data from IO memory space to "real" memory space. - */ -void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) -{ - while (count && !IS_ALIGNED((unsigned long)from, 8)) { - *(u8 *)to = __raw_readb(from); - from++; - to++; - count--; - } - - while (count >= 8) { - *(u64 *)to = __raw_readq(from); - from += 8; - to += 8; - count -= 8; - } - - while (count) { - *(u8 *)to = __raw_readb(from); - from++; - to++; - count--; - } -} -EXPORT_SYMBOL(__memcpy_fromio); - /* * This generates a memcpy that works on a from/to address which is aligned to * bits. Count is in terms of the number of bits sized quantities to copy. It @@ -78,62 +50,3 @@ void __iowrite32_copy_full(void __iomem *to, const void *from, size_t count) dgh(); } EXPORT_SYMBOL(__iowrite32_copy_full); - -/* - * Copy data from "real" memory space to IO memory space. - */ -void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count) -{ - while (count && !IS_ALIGNED((unsigned long)to, 8)) { - __raw_writeb(*(u8 *)from, to); - from++; - to++; - count--; - } - - while (count >= 8) { - __raw_writeq(*(u64 *)from, to); - from += 8; - to += 8; - count -= 8; - } - - while (count) { - __raw_writeb(*(u8 *)from, to); - from++; - to++; - count--; - } -} -EXPORT_SYMBOL(__memcpy_toio); - -/* - * "memset" on IO memory space. - */ -void __memset_io(volatile void __iomem *dst, int c, size_t count) -{ - u64 qc = (u8)c; - - qc |= qc << 8; - qc |= qc << 16; - qc |= qc << 32; - - while (count && !IS_ALIGNED((unsigned long)dst, 8)) { - __raw_writeb(c, dst); - dst++; - count--; - } - - while (count >= 8) { - __raw_writeq(qc, dst); - dst += 8; - count -= 8; - } - - while (count) { - __raw_writeb(c, dst); - dst++; - count--; - } -} -EXPORT_SYMBOL(__memset_io); From patchwork Mon Oct 21 13:31:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13844200 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29E47D15D95 for ; Mon, 21 Oct 2024 13:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qyh6O614b/8IkSe3xXMOvUBqzvmThFjUZ7QxLC46PX0=; b=ucj17Q6eoNmbfpqCR9WmxdLc3m yxHID5f9lubJSCHyTm07ad/E4VduG+2e+U3oh0tGVLBKqiEOYcs9Qbsb9viYwb/+xHnTAyQ4u/vGq BhzXZTkyM83p5kuDkbbz4HYxhSnUofHRirZO8e+rN6NdtF/E7/T6q+JL8cBXLlw0uSzdFBxCLZ/7j r4IDxFRis9BSSzbjWfjKJrGHWuGGGaou8ItxCXk7opptWUn5ImFKuZSxGFbu3I5saYRPLkEGbdr5d I0KW/RErs/wIli87DQwd+7kpDyPX22orYewC0t2qT30uaMLR3YS9D0Ckzg0AQbxgIxdwvxEvJXFxC LEk8elYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2sqz-00000007VPQ-2tmH; Mon, 21 Oct 2024 13:53:49 +0000 Received: from smtpout35.security-mail.net ([85.31.212.35]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXB-00000007QfD-05YB for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 13:33:24 +0000 Received: from localhost (fx305.security-mail.net [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id 244E730ED27 for ; Mon, 21 Oct 2024 15:33:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1729517590; bh=rWJitnMus/PcMNtJrIku8s/XDC0T/AmzlDyeGJ3xs4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MFRSR8P0yKzPopQ8LsA64SbgGQ+Zdbc9sTwQgFNUDXk4BaWkWxISJbIhZzU4bH9mq 2Vugiak3MGLxxAv7cTv3jBohQZ4BChmjnJuva5I5Y3yiyLtsDMn/rgC0km//wC3o6N uCZopOzh8/m061soxppXadaaI/knD1E5GKEErhSs= Received: from fx305 (fx305.security-mail.net [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id AF31330ED42; Mon, 21 Oct 2024 15:33:09 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012050.outbound.protection.outlook.com [40.93.76.50]) by fx305.security-mail.net (Postfix) with ESMTPS id 0F14B30ED27; Mon, 21 Oct 2024 15:33:09 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by MR1P264MB2339.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:34::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Mon, 21 Oct 2024 13:33:08 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%3]) with mapi id 15.20.8069.027; Mon, 21 Oct 2024 13:33:08 +0000 X-Secumail-id: ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Tc9QX+31wE0T1TB3nHXVkzQqarNmD1ULc6H5Lnti47pAb0CgJWfhQqDBJ34LKleEZXGBlxJDCc/3ksq/va1qF2xsSaCNuplGgT72PHS+e7Cp+hCpfdxca969mkKBFbJGjyom7Gxh9Gko4KhkLSKflV56XsWm3+eej4avbAEWWF8qVNJUlcWeA3d4qel2h+yLSeA+FbhFqJtHpPCDq7o2KLu8t8HhV01+uaA+xxIRZbLGGyBVC9VyAb+L7e6pNdnX2+eI6SR9UM88s+MXHduDKqBhroFVoEJ4IfSKmwm93zW/4RxlfmT5qlD2BXrh5XniFopHy2mfPvi98egVDdq5gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qyh6O614b/8IkSe3xXMOvUBqzvmThFjUZ7QxLC46PX0=; b=HDIt7DI3IfOk8EuzLPFnuSPETtyO2O3tsN0uJArjQ4U24nBAjI39aKgf3nF/lOyFwW3wxWyOF0UqaobTPKNPJjQfAmo1ePBxUq8scACFeb1l99xyFLUG2oFdM4xF9nUstqH6zaUfZnSwuv6PCfIxCpC6HjEMD/63wnv1syxAcvBckNV4hizzAcrbcVS2toZgn/UN4Nywg9DL7vHXIy/t+8oKk2DHBU/XFK+s5+H2j5/BZzeJcbm3K/Hb2yBP0g7mGi48TnYx5odmzd/dmI2LY2OHxqe2r+5eh78HIMQMVT8HrgLouPaeHpkIhMocle1GHuc8zssgxT+Lyu9pvn6O0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kalrayinc.com; dmarc=pass action=none header.from=kalrayinc.com; dkim=pass header.d=kalrayinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qyh6O614b/8IkSe3xXMOvUBqzvmThFjUZ7QxLC46PX0=; b=rmGxICwszCUq4zWSwspsPAuwB6rPhweDe1iLbFZgn9ycdPZjTcAjZRP+1XXPlf9S/po0BsZGeVr7h2qR6qEcJ17tfoXl0nRYIy6o5HKLiY2RXWChdpbT1MgT5v682xplNlt6hqQlOuXdJ1/VxsvMYjb+2uhzZ1gduIbjS0uDS4VlDBlRi3XDOeEPtO8jLyHkMxNS81C9I29CdofP4QI1ZZ4GF2fLg4rHrF3cedC55dqD6nb1Hvbz0C+z99KwDdm2auWuY8mWQQiFGKS9MDCJ0+tSo4gce03IAz5Ge54/maynCPCJfY+9C5m8sMaPtgA7lJWoOofYWlXMWdnVHfwB6w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kalrayinc.com; From: Julian Vetter To: Arnd Bergmann , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Andrew Morton , Geert Uytterhoeven , Richard Henderson , Niklas Schnelle , Takashi Iwai , Miquel Raynal , David Laight , Johannes Berg , Christoph Hellwig Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Yann Sionneau , Julian Vetter Subject: [PATCH v10 3/4] csky: Use new fallback IO memcpy/memset Date: Mon, 21 Oct 2024 15:31:53 +0200 Message-ID: <20241021133154.516847-4-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241021133154.516847-1-jvetter@kalrayinc.com> References: <20241021133154.516847-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::20) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|MR1P264MB2339:EE_ X-MS-Office365-Filtering-Correlation-Id: e534fd21-48f0-4c24-3243-08dcf1d4e643 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: T2ZL6eMCe/CVAf5qmUjAJXLDo3vFwC+eSoYWgZSnkqD91akiGQL5cPLNjie49TJPYKYzK5vDn7SRXxG+6aAgrxYEj51XYgKDgPOYj573Yr0MpJ71xrjkXlg2FGLXksl2ysZTM/VRwa8gC8buWLofKXNBf+0qx5w7WzdGat3GGiuqBgwqF5dHvA6WdIVXrguqPrzWlxEuVarWfgnk/B2pu+Se0d/tvRMSqmfUqbF4KtTiSJ8OKgBi0LtNi1Z4AIKkj/oNzU3aZomOojhDqE+odbphUdmKQSfiZIXry2ley82plwVMEjXwKzIagcJfJOWF/2UlLB6JXDtIRCvu8zhaIm3eT+O3vsO8+RijS3ZB54WeDl/ydqv7TTQU9T3oJ/6WfCPesj2udmkYKvZUhe8+lC/sFzRh1wlq2i2qm/l2iDvag7aRmbSJl/dIUMFmVxUrV4rPmZ1DbEGI9CYB32/cgSCGtwR3nSyDfh5SQNneoJmC9i+AW7hSepPQwxfoqetQj9GOhY6UKwDAzOYftwVGXjKzAytZZ1rKhhkbrkdGfeK82rgq655TV9Ka4yB4lIrEXczYvS4Z+YR61R6sh7WoMYE/44mz8UiEt0U/O+fxOetUkAssU0GTRMVWdQ+ilM3uvL/AW+McirUFSRAGgEIk8Gaip3d7opuTa/q8gcXY2cPhbNFBFYR9v53FZtgkHyExGT2Q5daHhmnTrKlc5oyS7Amzpze+w+/+zzYXhGEGwIuG9AbcHbeB2UFO9beWFqBCIJbrVdsk393fs96klyKynyXIigvyAr2trKc7NxeHZFHnRKwFA+HbbxHgAV6aZVlqvBlazRlocCwx1ea1Wxtu6RkENPm9iDghxOIj3G/7VN2d57h0euNcJSKed2rXhUJo0tyAOyi8KmBCNyod2peNsfFmpHkBxw0GDVC0xFaAMTZAtCB9biGalTEpDsgXBz/0ryz p2cRYopPFmrODtxtMzUprhk2k1VbIUatlTJkTgwLLsZ3EwbIIkVaG5UCqLk7YI37lZQkMxNIeV+U2PjPR8PRvjPDqmjiIpyK6wyzJ5AX4si/Q4VzTOwkD6Pgxc52XAVQJGm0+Y1t1vbtKlFdZSyDa5n17ChSt2wUreUGWlhc65Ae1jErWhy+WqO9kZYgcl3xaJPlsBHjT5ZgdJliDvFqERw6JoBAuJaqIhTnK3FDKYlNeCw9uKMq9ylf0FUMrO5x2eylPdoRAh3Q+g5csWlRw1cf3cZsfwvQmF8AibnVgN/j9My33Qf1z8GRpPLz/qf618IPg63QH23blDH3C5a9DFko2D5Izb/9QZ2qASPeqC+ksKJ0Gq8xS8EY++JxJ+k9OA9Chh9omxyai90CLXki5VL8z1rHyjGXYmzdD//XNjZkzyi7USrTwe1RHB1lF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WMGD2dne5ziNP4UGyiS9Z0nwIH1njwtIRPauGN2C8DuJcgO6ajUap6rrEc1hKbVZovwQzBIuQ7EfIJ3We905hL1PTcBJ9C3t0uF/nAdJ352d2bL02fUD4+WOVAyIFh/PU596LmSVT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9bPHNxrK1vNRq5yFv+9i+5frtwhH3SZARk46/d/FSAM40O+h9mYj8c6heBK04Z8XV4++UEHxz7yeTUhc0SAFqeSlX6co0man3bshKo/Zvigzioz3kkdqOGNw3Z5PaGJNNCHJqLbCIqq/XryK2wBJWCWZfBC9qm/HJZ/5a1yN1vH1/gHUsgEQ8ZDQJO/LbLUdl6w+n+01HkSwRXvoipwzHt8eHBntSeX9fG7J0cft+gqcKcMrSJqdAQJzvOJLpvH1ycuRLIlCAM5CeQPeywe7vEOmqaPb7SDW4YeBq89NVccdWFmd+r0Ghd5cII29gySRUiBwnrD8VM+s0mi2Vz0Ta3lHxfM20IduS7Ecu0lHE903I88X52zxjt+yKKgB4uYnEJ5PHUbeVh X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e534fd21-48f0-4c24-3243-08dcf1d4e643 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 13:33:07.9985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8931925d-7620-4a64-b7fe-20afd86363d3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QH1PP+A6oSJI72aC/BhZiypWVMTDk2EYnt0Kpzh8W3e2hcmpngqMnfvwon7znGzACj9mOWPILQJoHHUbfyJ8AQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB2339 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_063321_238534_7D00117E X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the new fallback memcpy_{from,to}io and memset_io functions from asm-generic/io.h on the csky processor architecture. Acked-by: Guo Ren Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v10: - Slightly updated commit message to clarify that on csky we now use the fallback from asm-generic/io.h --- arch/csky/include/asm/io.h | 11 ----- arch/csky/kernel/Makefile | 2 +- arch/csky/kernel/io.c | 91 -------------------------------------- 3 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 arch/csky/kernel/io.c diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h index 4725bb977b0f..ed53f0b47388 100644 --- a/arch/csky/include/asm/io.h +++ b/arch/csky/include/asm/io.h @@ -31,17 +31,6 @@ #define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); }) #endif -/* - * String version of I/O memory access operations. - */ -extern void __memcpy_fromio(void *, const volatile void __iomem *, size_t); -extern void __memcpy_toio(volatile void __iomem *, const void *, size_t); -extern void __memset_io(volatile void __iomem *, int, size_t); - -#define memset_io(c,v,l) __memset_io((c),(v),(l)) -#define memcpy_fromio(a,c,l) __memcpy_fromio((a),(c),(l)) -#define memcpy_toio(c,a,l) __memcpy_toio((c),(a),(l)) - /* * I/O memory mapping functions. */ diff --git a/arch/csky/kernel/Makefile b/arch/csky/kernel/Makefile index 8a868316b912..de1c3472e8f0 100644 --- a/arch/csky/kernel/Makefile +++ b/arch/csky/kernel/Makefile @@ -2,7 +2,7 @@ extra-y := vmlinux.lds obj-y += head.o entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/ -obj-y += power.o syscall.o syscall_table.o setup.o io.o +obj-y += power.o syscall.o syscall_table.o setup.o obj-y += process.o cpu-probe.o ptrace.o stacktrace.o obj-y += probes/ diff --git a/arch/csky/kernel/io.c b/arch/csky/kernel/io.c deleted file mode 100644 index 5883f13fa2b1..000000000000 --- a/arch/csky/kernel/io.c +++ /dev/null @@ -1,91 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 - -#include -#include -#include - -/* - * Copy data from IO memory space to "real" memory space. - */ -void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) -{ - while (count && !IS_ALIGNED((unsigned long)from, 4)) { - *(u8 *)to = __raw_readb(from); - from++; - to++; - count--; - } - - while (count >= 4) { - *(u32 *)to = __raw_readl(from); - from += 4; - to += 4; - count -= 4; - } - - while (count) { - *(u8 *)to = __raw_readb(from); - from++; - to++; - count--; - } -} -EXPORT_SYMBOL(__memcpy_fromio); - -/* - * Copy data from "real" memory space to IO memory space. - */ -void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count) -{ - while (count && !IS_ALIGNED((unsigned long)to, 4)) { - __raw_writeb(*(u8 *)from, to); - from++; - to++; - count--; - } - - while (count >= 4) { - __raw_writel(*(u32 *)from, to); - from += 4; - to += 4; - count -= 4; - } - - while (count) { - __raw_writeb(*(u8 *)from, to); - from++; - to++; - count--; - } -} -EXPORT_SYMBOL(__memcpy_toio); - -/* - * "memset" on IO memory space. - */ -void __memset_io(volatile void __iomem *dst, int c, size_t count) -{ - u32 qc = (u8)c; - - qc |= qc << 8; - qc |= qc << 16; - - while (count && !IS_ALIGNED((unsigned long)dst, 4)) { - __raw_writeb(c, dst); - dst++; - count--; - } - - while (count >= 4) { - __raw_writel(qc, dst); - dst += 4; - count -= 4; - } - - while (count) { - __raw_writeb(c, dst); - dst++; - count--; - } -} -EXPORT_SYMBOL(__memset_io); From patchwork Mon Oct 21 13:31:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13844237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47C39D15D96 for ; Mon, 21 Oct 2024 13:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=l7Njht9EXOov+4QFI7riJf17Y/k/EfOjTSncmbNefbI=; b=dq1HnAGr/w0vNLWydGlJ1JFCa+ j1P6/iW5VlVmdqHLIHg6xsQQyiNy33KHmrgKqGobN65x+o+J/Yq0gJ8LZ20PL87ibAUm5wdSOxPEF BzqXGjkL1UqA6nV88XZj8fLDdVWh/fRroSBnhsO8prN5nTrRi+8vo4zn6B1I1NOV29j1tSWqxbT4L nvj9lZIvmxXpfDDOUwZ1+fjiZCqdCjdn/TDwPwWl/LARSiiGa7WnuDQwXsYHwusNSMtB4OfAIpFiw JM92GPBfPy7tLH5SlNyBqHJAUDmoEbCsFVFGaZAu6fI+iDWQ8ezsEmCofFl8xRJfduFlckezwzLiT 4PBsd9pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2svO-00000007WIc-2i80; Mon, 21 Oct 2024 13:58:23 +0000 Received: from smtpout35.security-mail.net ([85.31.212.35]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2sXR-00000007QjB-30f9 for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 13:33:39 +0000 Received: from localhost (fx305.security-mail.net [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id 61AD230F0DB for ; Mon, 21 Oct 2024 15:33:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1729517591; bh=9MrRi+HIu1RpyTjzo4eMu1vZlTPkh23XxFp3JMnYzCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hvoGeB6Hc+iKZlAiL9tZQ7LI2rn1tHT4yeqWS48dvmMQrP6R1NErXZ8t18wDl5qQW 279WcO4kLFmi416cF+0FnzTaRNnjmNZ5DuonXLw4w+j+h9G74xkOSVLx6ecBWw789y R9M0eJYW4X2Iwcn1F9F2LITyDKLd32MFITCn4X2g= Received: from fx305 (fx305.security-mail.net [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id EEE4230F08A; Mon, 21 Oct 2024 15:33:10 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012054.outbound.protection.outlook.com [40.93.76.54]) by fx305.security-mail.net (Postfix) with ESMTPS id 03C3530EDE2; Mon, 21 Oct 2024 15:33:10 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by MR1P264MB2339.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:34::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Mon, 21 Oct 2024 13:33:09 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%3]) with mapi id 15.20.8069.027; Mon, 21 Oct 2024 13:33:08 +0000 X-Secumail-id: ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OLdEx5zBIhxlI+ciim1NNGxybSUKLysqvQjYipcO+OmTK/11aMnsy6uLn6Y8CDoN7W7P+E2/1WXLqMjqZ8MmC5VI2AH4qVgnnITK8/OhwUVRsKqr2l3ThUVrCJmER3spIejU+9UtNZAwde1WIKn+Qc9EsJPMqr1eqOxYb2niMHZ8M7F+5G1/S+jhkwhC4SI2flVfmkTJH5iWAnrfPtQc87qvfPoyHjBGEyygfV5eoLh8vgn8pTODGQplQgToT1G/pcXmSUXft1ogXJa4v6AZKZ69WFTaqWikqkgsPzFlfZA5yONqTKm4W+ltMKPr2sN+6FtFdGIZwP7mjcDi7NePJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l7Njht9EXOov+4QFI7riJf17Y/k/EfOjTSncmbNefbI=; b=VMwz6aa/o2MWdEbFajwCZm2E1eK37MdV+VXagon2jr6vZV8v0osyUjyqj1iIt5jYEgBwrt/VpemGlnNuZWNlMS7CYTwQ5NqabMz9KYdLAg+crafEEPB9lhj3zU+av/qL0gjAV0+RjwPZBp2B/VHT3GC+RphT0VGPBDJzNafBf+JLddfGRQ++dDQJFbSFztBKOzQm+u9U2PN4vDE1AUL8BaNoxTvsao03J0/cXJQOPajepYFnGUY0pFArC611naNlZ8W5BwmtlX+Y0N+ESBvTAJe3i5XO2aVdiDgTo3ftdQHIeYkiW+oT+3iEnLvXIR2j4m/TEDL54iIJ0J3A8xYHwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kalrayinc.com; dmarc=pass action=none header.from=kalrayinc.com; dkim=pass header.d=kalrayinc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalrayinc.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l7Njht9EXOov+4QFI7riJf17Y/k/EfOjTSncmbNefbI=; b=KOkrBftHFJwHxQC0cQ8cUg4/L+QnxCF2uK0nmNmMojq/UzWJA2X8+BpG7P7k/cp5V4btjgDgV3hKctnyUGrJYoLO6n1iECVHFDMxfmlCvLGg+X2G1MIYBe7/NyqCd+6am+lnXwMc2TQAp6YtbNC3hEnyJmbT8mo31ONBJCelEiB9ump9qAkCf//CXh603LMuwA0xV+jXxTtbNCfh+8wK76XJnwpD/rGZpVLz8+mBBJxas6rSDQz0a7vlH4l96NdAhna26dKBrtPQpSBAm17i2X8OVdLCI//R4Zk5je2PDTKPCucEp1QHBWaYRY2tbVeB37idXjJii/CfiDQbtYtJig== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kalrayinc.com; From: Julian Vetter To: Arnd Bergmann , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Andrew Morton , Geert Uytterhoeven , Richard Henderson , Niklas Schnelle , Takashi Iwai , Miquel Raynal , David Laight , Johannes Berg , Christoph Hellwig Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-arch@vger.kernel.org, Yann Sionneau , Julian Vetter Subject: [PATCH v10 4/4] loongarch: Use new fallback IO memcpy/memset Date: Mon, 21 Oct 2024 15:31:54 +0200 Message-ID: <20241021133154.516847-5-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241021133154.516847-1-jvetter@kalrayinc.com> References: <20241021133154.516847-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P192CA0012.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:5da::20) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|MR1P264MB2339:EE_ X-MS-Office365-Filtering-Correlation-Id: ca301b52-955c-426c-e4aa-08dcf1d4e6d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|7416014|376014|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: JWJ4gjrindRvyprbjFVJokFDqjHe6mWgnjeWGpq/7TVdzZk/oVE82SnZTtDU36mT4Csi96eA4cih2HvQV6q8qPp+3a1H6hSTgkGb7rMLVr2mWJH1TT2Dx41bWccClK3ZzBPLkcBBRKoczuPaNd4rsiwjnmZGWySBbG7EoRd1Xc6Cn8wPjqIFsTZuSkTfykqv37UWyZzUZthXDeZvw2qOEfKOMo+x+SoNi8Alm1uStrjPi3x6hP3T69Ph8EmuITsabxdnsRi6l7AAKKDfcqtNKNUzECZ4NalZXfEpn60bfyt54UXhO1OeyJAhr4K8W2yk2o+ZM/IG4uHfGF3xA+tK1TH1kX+B62wZYxRw0TaL5f0LPyXpnLYauEtasfH6WitkGrhLm3TJbMVJZTmEVHLm9zt+VuQgdArHA/n+S8uk2HJOUUFkP+BfBvrZ9hbuq4GUA68ZLa7a2cNoH0NeAWr92Fjpj3V4iG6gOpCOIiA3kBfD6FDLvfSaKc7WqP+HygCMvV1RXdVHPV1n//iHyEilEEAfaSF9rHxFu8mVEtDHMcpFU7WnzgS98JCZmAgr8hMqIg6dQdk6P+92gxgzoRqnsWRUs/H2cU6UzWR6dSD3rAVdKjUlcHxCZ9VyUTkjTrfVbFdGDQe0Cw9hrX8f6XkOZtwsu10N7kxMRwMRGn4+yw8SKYtp0vz8pB9us8LYWr1q3GUIyeNEwVqne9XIuxk5A/pS2TYLRv7ODcAF7xlgp1SntfNwqFyHL0ANwm8IBA3H0xM31tf5c7s6E5knHXTS+NgYbuigZ5GTVtIbEbumVlynQsfhKygeWP7BdAKE3rSpBSa8ig7EM6i3OIDBdGtBOs0CPEKoxlmojcoOT30iMNfMWmI004zjEPT5zvKxV3nLRclaqb5XatMjQ32uNkknFpDan9aQxf5uM45/YfJuh/8OUntEu4HjQhleSTlJnX8k3h2 lsu2QJLBK08FEkWnWh/EvKX6quIW/PcCbZmffz922RYiM9WeBoG7UHhGOSFZzbrFyIOIT0l2e5iJpAK1RHgEwRCxf0EF+9MOy65buY6C5+Vxh+ZcPz7VRQxjEDf0jX3xS0rp0HZj8KOUnAqirkPftYtv8tkZeojWXaY2Gb/tJTbuLmjGGiaQUhDyXYgGYLRhLh3h6Zl7X87w/bewdolagW/E2kCY8W/lFSJMzxPivQvSBy92uHTEbsMBvqRs+a/R88ntnj8u2CGenue73iSVrkTlhU698Y8OAa1I7IlRgb01CLHkYT+YEoQq9Vpr93CQLn8twsabBDWOLXhz05T5omQHLQd/E0VAsgGQ5x8BPgYvLQnOmJOTljt9ChkH575pCOlGea2dzVKxO/D+BKnomURIaEvGkEvRlDTEmnqRvTxRKuRwqmm4bc2oqCWa0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(7416014)(376014)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q7pAdVamevcwDP24bVE0E5CcpsZi9WrlU866JQwuRhfQxVc33Ta0eZWVmjCKPmVrgIoqke1sOF/ZByybLquG3xNaDc1APaV7Dg4o4+BU3EyWJ5TvdMAZfgkVNPdCXB0T1qvSkwpJP0tSDcv+C9DcyWbdja2gZRlAVLF49etqeYj3zfGSWJXnS2r+sEyKeQ8aumuOaPA3+qvL+g5off1UpxzAjWaSo56Z/L7/eZw1c4eAUTYob14/YBNai7vHo0HHVyT6a2vShBAjpDkHCMlPrfl6UfbSGvuG4lyRT0fQyt67vLV6TD7xUYGfBgf4x9jIf2JtIzeQTRhDBziNSHjM4bQgf+sUThjtgTHZcPhfFQkE691UppcB0OEqek1nZ4vNx0kiO5kutpgEDZK37e0g9HdQ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zk15JWf7bjKHcg33PfygEO5aINBUu+WBZaYK7c3Pm4cVfh0qgQc4XYzAbwgEsI8AmHk9oTQwYoPjeIA3xgn0XR2HCwWOcv X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca301b52-955c-426c-e4aa-08dcf1d4e6d6 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 13:33:08.8848 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8931925d-7620-4a64-b7fe-20afd86363d3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EFeQpEgGJTN1Wm29wkZeK2LrbBrwHTqjxfA+Amsltq1itEq2kvT1tHf6MAe+STmIChc0kCrgLbHTVYbwj2UNug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MR1P264MB2339 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_063337_952194_2321BD18 X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use the new fallback memcpy_{from,to}io and memset_io functions from asm-generic/io.h on the loongarch processor architecture. Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v10: - Slightly updated commit message to clarify that on loongarch we now use the fallback from asm-generic/io.h --- arch/loongarch/include/asm/io.h | 10 ---- arch/loongarch/kernel/Makefile | 2 +- arch/loongarch/kernel/io.c | 94 --------------------------------- 3 files changed, 1 insertion(+), 105 deletions(-) delete mode 100644 arch/loongarch/kernel/io.c diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h index 5e95a60df180..e77a56eaf906 100644 --- a/arch/loongarch/include/asm/io.h +++ b/arch/loongarch/include/asm/io.h @@ -62,16 +62,6 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, #define mmiowb() wmb() -/* - * String version of I/O memory access operations. - */ -extern void __memset_io(volatile void __iomem *dst, int c, size_t count); -extern void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count); -extern void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count); -#define memset_io(c, v, l) __memset_io((c), (v), (l)) -#define memcpy_fromio(a, c, l) __memcpy_fromio((a), (c), (l)) -#define memcpy_toio(c, a, l) __memcpy_toio((c), (a), (l)) - #define __io_aw() mmiowb() #ifdef CONFIG_KFENCE diff --git a/arch/loongarch/kernel/Makefile b/arch/loongarch/kernel/Makefile index c9bfeda89e40..9497968ee158 100644 --- a/arch/loongarch/kernel/Makefile +++ b/arch/loongarch/kernel/Makefile @@ -8,7 +8,7 @@ OBJECT_FILES_NON_STANDARD_head.o := y extra-y := vmlinux.lds obj-y += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \ - traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \ + traps.o irq.o idle.o process.o dma.o mem.o reset.o switch.o \ elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o \ alternative.o unwind.o diff --git a/arch/loongarch/kernel/io.c b/arch/loongarch/kernel/io.c deleted file mode 100644 index cb85bda5a6ad..000000000000 --- a/arch/loongarch/kernel/io.c +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (C) 2020-2022 Loongson Technology Corporation Limited - */ -#include -#include -#include - -/* - * Copy data from IO memory space to "real" memory space. - */ -void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) -{ - while (count && !IS_ALIGNED((unsigned long)from, 8)) { - *(u8 *)to = __raw_readb(from); - from++; - to++; - count--; - } - - while (count >= 8) { - *(u64 *)to = __raw_readq(from); - from += 8; - to += 8; - count -= 8; - } - - while (count) { - *(u8 *)to = __raw_readb(from); - from++; - to++; - count--; - } -} -EXPORT_SYMBOL(__memcpy_fromio); - -/* - * Copy data from "real" memory space to IO memory space. - */ -void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count) -{ - while (count && !IS_ALIGNED((unsigned long)to, 8)) { - __raw_writeb(*(u8 *)from, to); - from++; - to++; - count--; - } - - while (count >= 8) { - __raw_writeq(*(u64 *)from, to); - from += 8; - to += 8; - count -= 8; - } - - while (count) { - __raw_writeb(*(u8 *)from, to); - from++; - to++; - count--; - } -} -EXPORT_SYMBOL(__memcpy_toio); - -/* - * "memset" on IO memory space. - */ -void __memset_io(volatile void __iomem *dst, int c, size_t count) -{ - u64 qc = (u8)c; - - qc |= qc << 8; - qc |= qc << 16; - qc |= qc << 32; - - while (count && !IS_ALIGNED((unsigned long)dst, 8)) { - __raw_writeb(c, dst); - dst++; - count--; - } - - while (count >= 8) { - __raw_writeq(qc, dst); - dst += 8; - count -= 8; - } - - while (count) { - __raw_writeb(c, dst); - dst++; - count--; - } -} -EXPORT_SYMBOL(__memset_io);