From patchwork Thu Oct 10 12:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13830061 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 A735DCF11DF for ; Thu, 10 Oct 2024 12:49:16 +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=Wxc+ptfJhfeW9nmniYCoOFng4kDVENPOF8QNimbyUxw=; b=YZhRwBa3Uv2jIQ/J/htCbmv65Z 1ZbYsV3EOIs2mrOGzgVtp/Brmj9hKLQVmLw40v913O063LxCaxYmrl/6DwoB1P6+eJF5Jp7WiFDrL FLrwSPCgdGAQjdnJKhkyfPetMDv4YNPoUwH8w3wp6CRlc30bVddNlj6nc1/0r3nLqO+vXWYp2Zc1r oRvv7liaBPlFwVc5mlC4OPJ7P0ZMxxvKnLDER3w26XKgR8/ZE7bYKAXzf5h5uFvsRDhgWwqPyBOxs f3pYQ9mw782P3J+L95qyJ21oOJwUBDKvcxEcl1hGgxcx4YRDD6NZvqyiASICNqgiNR9HYGLfIyjO2 sP6j/xig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sysbJ-0000000Cmo7-1CON; Thu, 10 Oct 2024 12:49:05 +0000 Received: from smtpout45.security-mail.net ([85.31.212.45]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sysPx-0000000CjcW-0PSX for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 12:37:23 +0000 Received: from localhost (localhost [127.0.0.1]) by fx301.security-mail.net (Postfix) with ESMTP id 22155511B15 for ; Thu, 10 Oct 2024 14:36:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1728563808; bh=AuP0TNfT+jqmdi51Lqy26dN3CMKXQ1HavhEmloVdNkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RaZF/M9KynJsx1dOC/G7i+scHB3gGE6sdAm4AtX8Cwaxk4KL7jLwFZ1kLuwgudvwY /G/0oGw+3gXwqvJzxeoQdBYokVfhI2VM8MwZqHERd/IQxs31Eh8uM96qJEDRlBJVxx PIu2V+kp+qetNNavhBACodxGg1HyMNNBCyesZLfM= Received: from fx301 (localhost [127.0.0.1]) by fx301.security-mail.net (Postfix) with ESMTP id D743151134D; Thu, 10 Oct 2024 14:36:47 +0200 (CEST) Received: from PAUP264CU001.outbound.protection.outlook.com (mail-francecentralazlp17011029.outbound.protection.outlook.com [40.93.76.29]) by fx301.security-mail.net (Postfix) with ESMTPS id 2DEA851179F; Thu, 10 Oct 2024 14:36:47 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PATP264MB4966.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3f9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 12:36:46 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%4]) with mapi id 15.20.8048.013; Thu, 10 Oct 2024 12:36:46 +0000 X-Secumail-id: ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NbQpDwx612gpwb9kMehjLO6MOHV0IivBnkVcJOW4qKWD2Zz6XkPSCb1QRWGy6gkjjUX5rFant5AYlxhgdyW7/7CYOafzOnGoWCi9I/1sPz1LQ7c+37gg71RXr4IFDvYwjY/g3E4ZtQj29x+3hRMsMi0qJR5ks5lFyS/3hyJhkYYI3mZBrDDbHUKrJ0bx3upM+SyVbUzP1VbhOd4ohcZLtK8VB+HqNFqzPfjU7gVa/XLgyfmELBPMGTOgPFMg6SQQwx/2r2IwdFigK7Nky1oV551n9LGYevPEcGGEJ/N4NJO6PJHVOKJS6/d8bH63IjBvkPFj26r5YdnwtU05+SG0nw== 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=Wxc+ptfJhfeW9nmniYCoOFng4kDVENPOF8QNimbyUxw=; b=xBF9QSQLD9t9xjCk+Q3vA+QQql9k08RBrixMLGP/+lxJJ9mzBH2hvy7Tp6EiIc2kjV5r9VuEfrDmevkwcJa36DSP2DpUMIbpbICrS+pRRI2H//YW5HggDDg7B0ZNBMPvJG71qxZPDo3o/mHbycVi5L/bRAox87N7bCWFhZjrhybZRIats1TKZNkiIbq/WUnWVNXyRpnM/1dOtID0mocMDsXmhWd4OIqjF23d5tCvWscHzVyvIbam0veVZKD3iZuY5xz1yhh0vPHrv5rZCw0FgerLzh+W1UOyY6HWthlazZKlUDQurE24Wjmk4NOXz4lcDglzuNCkeLC8YSExFdBsMw== 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=Wxc+ptfJhfeW9nmniYCoOFng4kDVENPOF8QNimbyUxw=; b=bz+lxIGwxPNQcnh3wItZU+GaElDzBfozbabRpAULxG2QTXc7SlgkbPj79F3J3fs1fT8l4l0E6kBKdKiGdBU/aCxPQm0lt39omdIYgrmrioSQmdUzMx67NoOg+hqJu3KosauAbmoLOfaw3PKACCIAyX6UHbgiBqJZVBfkwu5UEw5UYteiYY4KE6j42sOEcK3j5bMcgwmMpjCnluY7gSdqK/Ixk6C1a/JSj5rdKTJSvlL90JMdib7DBBzXZuzkhV4FmLGKKakJrnF+ceHVuj6u1mAvGDW1jqGC45PUKxUxKxAThcruyh7tY2V3zJTiUNvXVTYuiVYQu9OWdMdaWY2gVA== 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 v9 1/4] Consolidate IO memcpy/memset into iomem_copy.c Date: Thu, 10 Oct 2024 14:36:24 +0200 Message-ID: <20241010123627.695191-2-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010123627.695191-1-jvetter@kalrayinc.com> References: <20241010123627.695191-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P250CA0020.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::9) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PATP264MB4966:EE_ X-MS-Office365-Filtering-Correlation-Id: 098d4ad0-e5bd-4416-3a98-08dce92833a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|52116014|38350700014|921020; X-Microsoft-Antispam-Message-Info: tZeMErcidABGkuJj6X455BnS1ZXBGHC8fuYRsXjk68R2lCIF/iVdW/ieGXV1pNUBNOISa3v2KyAcNP0EFznh7Loqz2qm9OmtiKS09NwwvZkbvA4HV62Iq44RYPbUKd8+3vHaRpFHBDZy2jSE5K1BFGBD8Zcsbs63r2tW9EUfBWnQb/WsXs/AgmY9nxzPQSixWbSAjNFy38JWy24Kkng0kDZfgsJUXWdeXHsZdAoXIElVwRYvqp9Qity+kqjfa3twUnRP1XVHlGe27qW07y/ett+/2YawnVr0DFTrIr99CK5Z3/qVpmNf86HREYTNinDtupH1in6Wt3Wwsfdel1BWx7EG18p3W/YjAsxTTgRLrKRB4Vne+QMESewcSb4B0EuTvuMUmTBZ0rPDKngaO+U+eXuETAUSZ9NmL7DZHgFg5bRA2JwQrm5QbHd+eo7iL1eSLyq7NLjmSha9GPdyhQ13DmuJT8R1/bQbP3WEQGbCL5iLitZ8BmWXhlt2XqfGSQ4EOJoqgq3oZDNPs1pKBnKmWMpSI2onmyOEjLK8oCJ2np+Pwze4kh7brHgZpp0i8DR4EtVXYPejssSkoe6SpPwIK7wSnTIK9naDsYiHwiLRZnt4xvz3q/ldPSOFmSqsCfgYycVsY7P8yweYql/LAQdXef1NukEezGcRev+74eOdFtX0gtziTtMZum1HIBu+SDja6NDvSBSb3fknFFI12LL0wjOVXiL+76lo8+hHyMmqoid7Auc4kclTEzlYIxXijLjXvQg+IbADv/1S2Z/IytK3PxtYezhfT2cR7U++RJ9SXl+l+cA7+hjSxp5eEiHfR13yraupqvxolD5TqwQ+kUgVMCbWcT0vNIR6VgzRzQDRZeGAHfQBtMnYwyKlVzH2I5akeo0gUM4+rRFDl35VNJBpceGO92g5hrwheikq4hCMUs9wBhAO+A36si1dCU6wI4G6DWY XigLloGvVXz12qbQOePj6pz9ZEpoG6wZQaiq0Z5FJBzvo3jKP9kxRMxfq1qXClwykGBVsmBTLG6E32St4VWmfshIVSRUfTedBhB9qLBuYxkQVmYSzRbY4hCvC0eyNTP4MlMVgslJ4yW4zx33PwCm1bKJ+py7bNZ181+aGK+RHCySzVLGxF0fsvJelkNawgk6zNguX7RiWsCcaiiRV+ZjXS9VaFKOCgcmcvVjR9KSjZHhitEJxq7Ak21gOg3nxhGuglTPON4wpQq2KDNmoXLa+0cRo3mnthhmKj2cwmBexho/WH1cThOID94NBk06sIdsEmJ/zhpTHt2l+NEePneNQft89Kisr3HL09Ka7lSMQGaLEt5hMBi9G2ajBDRoDXGZMpEeveqGf8FYTYnT1zU5wbCOJq8XCqdfGaoxw+6U= 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)(1800799024)(7416014)(376014)(52116014)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NDncZTcC5l6gyzgBuQWZSmU0f2xf+Cbf5NMJoVppzbcR8gCK/dp4SkQFL7BpaY8aKW3JBChypwO2BDji1T+6g7EGCNccBIRbNNYTddamYDaUpwi7Yw/+x8jsDZOPev9QlMMyHbCP5IxWZyoc3B4B2XX8eW9zgZiIeYU0p8mxHO/W+7EZtJtyjLtaohZ7q2TjBlO6kLH9319QvWj36rLMB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gjxxbU8FC8qWyDaQ6pLwElxs3NZ2/NfCJLVPYknTugik0jwVjg+bO/paslJBkvh+tk21sj6XfMAEMsnMyjfUTnpRvDrhYnJfGMdjgUO7gLslfSt/oVL/y/zCxjG/GK18pb9sdIzHuUdXFsOIGyG4SceA9R6sIyUOoBMTiJnuwU+j5lcGPamUwJHhSuFAxvWNjmud5NZkRoVMpUELVKnQ4l/9T3B5xEdS4UqnmE8dMjN4pha9q7Hp8W88wit2E451XB0lmSF0PE+hPi2j7YDAXJTVPfKyXZKzNFD8vEpx/ZB+uiG33ZHkCsdZv X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 098d4ad0-e5bd-4416-3a98-08dce92833a7 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 12:36:46.2129 (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: EnTkvGgCRuVIGesU+iQ0ieLQw5uBWJFWFLMgDhTfoI3AxZ0jH8CHSCuYyZaFzEU5YJDkP9JCE7+AL8DaggnbEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PATP264MB4966 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_053721_653969_827621A6 X-CRM114-Status: GOOD ( 21.84 ) 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 Various architectures have almost the same implementations for memcpy_{to,from}io and memset_io functions. So, consolidate them into a common lib/iomem_copy.c. Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v9: - Moved all functions to iomem_copy.c - Build the new iomem_copy.c unconditionally - Guard prototypes in asm-generic/io.h with ifdefs --- include/asm-generic/io.h | 62 +++--------------- lib/Makefile | 2 +- lib/iomem_copy.c | 134 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 53 deletions(-) create mode 100644 lib/iomem_copy.c diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 80de699bf6af..4ab47ef7095f 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -102,6 +102,16 @@ static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __i #endif /* CONFIG_TRACE_MMIO_ACCESS */ +#ifndef memcpy_fromio +void memcpy_fromio(void *to, const volatile void __iomem *from, size_t count); +#endif +#ifndef memcpy_toio +void memcpy_toio(volatile void __iomem *to, const void *from, size_t count); +#endif +#ifndef memset_io +void memset_io(volatile void __iomem *dst, int c, size_t count); +#endif + /* * __raw_{read,write}{b,w,l,q}() access memory in native endianness. * @@ -1150,58 +1160,6 @@ static inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) } #endif -#ifndef memset_io -#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 - * @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) -{ - memset(__io_virt(addr), value, size); -} -#endif - -#ifndef memcpy_fromio -#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 - * @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); -} -#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 - * - * 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); -} -#endif - extern int devmem_is_allowed(unsigned long pfn); #endif /* __KERNEL__ */ diff --git a/lib/Makefile b/lib/Makefile index 773adf88af41..db4717538fad 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -35,7 +35,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ earlycpio.o seq_buf.o siphash.o dec_and_lock.o \ nmi_backtrace.o win_minmax.o memcat_p.o \ - buildid.o objpool.o union_find.o + buildid.o objpool.o union_find.o iomem_copy.o lib-$(CONFIG_PRINTK) += dump_stack.o lib-$(CONFIG_SMP) += cpumask.o diff --git a/lib/iomem_copy.c b/lib/iomem_copy.c new file mode 100644 index 000000000000..4de710c2a9f0 --- /dev/null +++ b/lib/iomem_copy.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2024 Kalray, Inc. All Rights Reserved. + */ + +#include +#include +#include +#include +#include + +#ifndef memcpy_fromio +/** + * memcpy_fromio Copy a block of data from I/O memory + * @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. + */ +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--; + } +} +EXPORT_SYMBOL(memcpy_fromio); +#endif + +#ifndef memcpy_toio +/** + * 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. + */ +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--; + } +} +EXPORT_SYMBOL(memcpy_toio); +#endif + +#ifndef memset_io +/** + * memset_io Set a range of I/O memory to a constant value + * @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. + */ +void memset_io(volatile void __iomem *dst, int c, size_t count) +{ + 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--; + } +} +EXPORT_SYMBOL(memset_io); +#endif From patchwork Thu Oct 10 12:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13830060 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 B1A29CF11DF for ; Thu, 10 Oct 2024 12:47:53 +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=Y8JUSEWpLlyNo7vsdafD4VUsr+z3yFf3OS1Tc7P2A+E=; b=wQT/V7ONVPuN2CY6NjS1PP8LEo hLMhhhFA3mD51NvpHgHIQkquPbrdXsq2DHoA0gYKkqZTIig3A3/vnCam7c6gvNtTd+9wGpBGwpHVA ytD09D9LBJS8+Mqi30onVYys2+UqfsN+x+FHimjoUv60ZgLUfVEUXkKPljqThCSQ6YPdk1YYCRSZs lqhCvUhOkHafUB69cHhJXq4Fimp1RwSeegYoxP/V4PG6STkV6KPrO7vL3LaNSRMOyhCDH/R7q1hXV 14c6Kdq3ZlJNIcmV/GcoIm3pBFTNiTdJtT8HQx9rEoN56jmF9vipT9VIUkbuI8+hW0tpsyXbPwK22 AVhTlmWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sysZy-0000000Cman-0kP0; Thu, 10 Oct 2024 12:47:42 +0000 Received: from smtpout147.security-mail.net ([85.31.212.147]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sysPh-0000000CjWg-1g16 for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 12:37:07 +0000 Received: from localhost (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id A038C349715 for ; Thu, 10 Oct 2024 14:36:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1728563810; bh=RlQzT0U7eOx8U5TfAfIuFQsaaIHteJk0XXQbWyLB7W8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Es4H6MqNxQc5UAs/5/2V80UKUPaziMge6iiYnlRI30pbdaIgmKxrcTkMMqDIznI4J pVgfzapIKYFK4yuk5RoiIlHhVVio7NVHqdC7gHN+YdpqMbfea1+Wj+VvYOYRryIiTy PN+hgMr2B/mSdzqfpttLzsbm9iPN7doekvDL3VTc= Received: from fx409 (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id 0F71334948B; Thu, 10 Oct 2024 14:36:50 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012048.outbound.protection.outlook.com [40.93.76.48]) by fx409.security-mail.net (Postfix) with ESMTPS id 24C1134934C; Thu, 10 Oct 2024 14:36:49 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PASP264MB4625.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:435::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 12:36:47 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%4]) with mapi id 15.20.8048.013; Thu, 10 Oct 2024 12:36:47 +0000 X-Secumail-id: <67e9.6707ca61.2144f.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UNNmWG69ESnumb+Vz2aQuVodEj8uoDPvklp85Nba1ooy7V38kMwA9f4pcyGCziPgx/VsMWdwrRrf3gGrGQudrl0j9yOZafHgENROOAiN2an8r0BwU70gkjopSCoVtxRO2/ZgIzUzuK00u8yaf/MsVKbEH8nCxxEIUTfdOkCpWese78MHPXOQmIJ8EAk1YHdzRPb//y8CnssgdA3TBA+xU9ekFW6fb/nQP+Ylu+vgRJqcsCvfNU/Gb3nL/tmG+yFvIRDKfaJEeLOSqQgaK+eioYApofk5v5KY48XPtCGiiGhFtI2OExuQGJgzz3nYkAC1rXItEdsHbvfMDUZ9nWvc7Q== 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=Y8JUSEWpLlyNo7vsdafD4VUsr+z3yFf3OS1Tc7P2A+E=; b=eyPPYfNakN3Vz+7nJkCNMl8+Kav87qUf+0trXex8A9qduV4KK0amwpE9Th0HHKwQbavAzVtC0tJdz0KvVb5EdS2YGBwpPVoaRGRwHp2lETwiDWT7dswMxC7mUN/pBfdmgIjIRGXku3wrh4/9hKPGahHfv9PsIM28h3HD+rsca6kxbLxKpijtkjx7HVcs2M8HkTv46xgPu/W9W6ZIhlrwVKcJToAWWWgv5kiTRllowLV/5Pe7uwvWsVWydZ5VWcR3XVQBMDGVljLpo8PUoh8+6iohrnmUu1jYIBHKkWdK67U4tdDIfqKWJXCDXbYhdpkuNYbxQ3tLNLaqw0O0ns3sgQ== 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=Y8JUSEWpLlyNo7vsdafD4VUsr+z3yFf3OS1Tc7P2A+E=; b=Pq6Gr/CrE6hVbjkNRSlEefuu/G1iBUMBjiWEH+n4A68YgYqe/h0tkd/g30aCUVJr33k/4Un61NMqnVvz2VyrIkpeu4dAUAswyiDXcQbjNbIXGUSCtQCoTgfuF+CIQh18TMu3W6BkWz/L8BdjJr5bdojqFoXHiBHptkUz8gmwd0o0ivSVj4M6MVmrViuPDntFjy/B+cVe05XmLzC3LjDifjV8CDYIoH17nPTTC7HVkRhFny2dufaHMnfN19+6wf64TjdD8212BrOgtuJDOjd4LC7pBi2KpBXTleiQQi626dqL2/MBmR5YIrs/SuD7k647D03JWfj4dYYTK2zl5ute2A== 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 v9 2/4] arm64: Use generic IO memcpy/memset Date: Thu, 10 Oct 2024 14:36:25 +0200 Message-ID: <20241010123627.695191-3-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010123627.695191-1-jvetter@kalrayinc.com> References: <20241010123627.695191-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P250CA0020.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::9) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PASP264MB4625:EE_ X-MS-Office365-Filtering-Correlation-Id: c8572b2b-2852-493a-cdc4-08dce92834c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: Aa+wed1RaGX7XuYYpYFsx4Ws3z0UeLGlaBfA1862e+hmZupL9twxd/jJcW3JH6mAsFfGIAb9gjnP5rApu1TMaQ+NN+hL+lQkAcV527qvI4Uu9t1QpqLjS1FaG3jnXRY05hflhy2Kqi+poTYuCGOkn2t1QUiK77CATt6YkfQhoVjwQXaZGq2c4uuv1n+7BWYON1fEy0A/oETZnOX/Oh8PXH8+/Q6KYW5xX/2g4ducE1SsPJjc7lP6bf/Pe3uIOv6D/z6dKQ2EXHZ1MsDIp0QaP1a5n+4br3nfPUfEOisc5feJzP9mfF9SbRwQIxid3vTQcvWeXUHZ+vhVm9XmQHrPc8ihPTifU6VbHw7SshG1cNAA/y2GJsh238OTlloPV46Mjts0ibFHfW59sDug1a+YotJf4rVjYohY0n3slf4MAAQYiFpqnmM+kpZCUNbAiHrJLJjIsK9U4QFL08AWbHPj6KaxMAfOOQI84UQAAZCEo0B7lTpnZ/69wCautalWGY9w7yfND+RHCn5VahlyXRHHYeW7jT2Q+mxkN9olOlVqsuQLijZrg35OBZAo+GoHWGDk+AwJgRYkA1halIx/q/Kr/w7eyYFbVTfAufNcfi5f9wKyj8+6QIL994z2R0RyzU/Zf7onGzay3qx4Kw2W+qVz9Lrq2YrIrRp8uMkcf/lyJE7Lydglf+MAqYjORu9dabtej20tK0+3gsSiRvnDtNKLDBZvRNaC9KPl095FqVWEVhaRt+5X6WUFIAVy2XH6quCNx4mhEyR7AFpivZdQj3H5rXve3SRDv+bVlTny4KmZsh3XKer6iGYV64OeoRr8pIJyInWvQEbFkcO8MSOmMZzNGzuGmh65XlmK6T27z1JVRfXHJnSZx8T5LzOir3COS/URCRki4kaWkq790B/27cgJHVDkKtcE9sL9osQx+eZZ8BYF4SFWHilHjWDFDqGibe6gXf9 mnD4jysarutMTuP4tQubwXyLvNYBJgR+K2F43S9iJRXoC9bOf0CLDAauQLh8i1DfjUlinl3Am6xEgtT+iXhJl9DhH9zXlO2jWAvq/UnvrMCLXE1gtAGww7XlxG4BV6SVverMQvULUJjp4anng2JNhAy80J3tSwrU2lIO5ybey9sRLKp4w0/cJO5kmhvXwBjPD+PwSmATQ9dhhvcwBK4zX2rFQgT+RGhVBWdmEwDIqN1EkUtTICgAUR1aNTa1kzYSRCJhpX69B519Opx8ZVrJzl3cvmHuj8KokUojOZ9lXuC8aVQTIkPmLAAISTboeufIm9Gw+tBTJzB7N9gtWic64AaB/qhRPWIhQ8aAFEL14athxhB5PjNKW92ZwhNgorGPpykRwWMsbiRscqaeXcIhZ71AyDImtVM1/U1tlH2c= 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)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g1XQJ+Zx1LMlgdGppaYvO/Iz+YyWukYroG/8QUL3Cnibe8gTcuxiAQ7wC1iB+8IZkid+5YC3nzSJd3l82jeBbY3YTDv7sfzeqAn++cvMIt9cRc+VT6pMcQ7mogRosfnipIcHP2g/epqxTF8FIA7A83jBAkGa5S1jTr/cvDmMdDpW5UxMygUbvVttvsuWBWm5rRoiJDJE2at9GHUpZGgi0VMp54cLuMQWzH2P0IBkJ2PgVG8QZG6aLK/Df8e9htEimXFIaZmwIpHQv2+rB3wd2QccwGedtZNEEd/vwhOXqDwjzWQ9MHkS5NeGvJpIL2Qk7qa+OQjTLu8gngoppafMyKBeMdJRpn2uC4e1KtUyBtzbUAq4UNfE0YveZmXaazc1OtSRJeyU++/iqGm8FJYHXinF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naGJdH+NHAnBkg235k7oR6Jwd2s+cgxp0h97uvdTtgDkgsVD8kVCx9PuGIZq46pkpXrvk98NfpB6hFX43wTEj4otQN+zuGzj0ONrUPCGPSFjQ/uh1WIA0Tmahwx6bqF X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8572b2b-2852-493a-cdc4-08dce92834c1 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 12:36:47.8861 (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: HouI/ZIyNHV8LGYe/ikO1xTBn0v2oMm2l8D7FKJvMjVZwT3xs+vLA7/ZhHwOSgcDiwZIMdVc5tgMx2YyY8jHBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PASP264MB4625 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_053705_739126_CF7ED403 X-CRM114-Status: GOOD ( 14.31 ) 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 generic memcpy_{from,to}io and memset_io functions on the arm64 processor architecture. Reviewed-by: Catalin Marinas Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v9: - No changes --- 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 Thu Oct 10 12:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13830069 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 64571CF11E9 for ; Thu, 10 Oct 2024 12:50:38 +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=NyagxVLOGfirvc9f6tu4WyEJve+5URvX1q0tll4fckI=; b=owSpv+4tKXYlDosvbzrVVysh52 g13UuIcFla/FbkBuCn8Fmn6g/p5vOgArvYrhP1Jb/ssmphJ81d+BF2QAzK6upEwEIARZuRdiRoQBb LBcbikAlNJ++bXSna7o1ViCqIEtBx5zfV3fzDH1hKhO3vPcwDMi0+2g38b8x1jRNFsU5JkI6JeL8e 6edq+CruZkRTh8I5g8zGoJeIdhyXgUb3GEhaD5yuvYBKJaW93tuxylJG2yfcjdYJQyjxqpdiAL1Sc AcIDPJu5OPSOgpPd1z7Y9bsulu1whQQUjib5L46HkMgYsO2p+m+GK3dAJrYXt8uJTI5fK21XGhf+u H+GjqRvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syscd-0000000Cn4A-1llJ; Thu, 10 Oct 2024 12:50:27 +0000 Received: from smtpout147.security-mail.net ([85.31.212.147]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sysQD-0000000CjhW-2QW3 for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 12:37:39 +0000 Received: from localhost (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id B1E9D349A6E for ; Thu, 10 Oct 2024 14:36:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1728563811; bh=Wh24u107cI7PD08KmHzABZsw+yf/A0fEJI8uXE8dCmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gI5MTzmeaBSYdmrmgP94DIO/shHi4FF8YNKwbYb5QHeWgcUDnN30jZ3xjTEWs2QPF /MT5keuoN7CvucY9TIucK/2oxk7Mloj22434eMlYR14l4lvq9xOEcLzb502UVwjzu1 A9pO8qeTDyzg6Knqu8d5kvVkyWTOhBsaH1EuufRU= Received: from fx409 (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id 4EDF734990A; Thu, 10 Oct 2024 14:36:51 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012054.outbound.protection.outlook.com [40.93.76.54]) by fx409.security-mail.net (Postfix) with ESMTPS id 72DD53495B7; Thu, 10 Oct 2024 14:36:50 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PASP264MB4625.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:435::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 10 Oct 2024 12:36:49 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%4]) with mapi id 15.20.8048.013; Thu, 10 Oct 2024 12:36:49 +0000 X-Secumail-id: <510f.6707ca62.6cfd0.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MCZVfS/UwN0Cd+AJuu8a3nWWli/ZV6HRjK8l8eCQO8+vNw2p3W2vxt3GLbpapaPR4KYDr0UZyUm0CGm9134NnMhg5tUPPBg8l0eZmKGYsh009TS0H6RUu9xfGWUvScIlY5Pf83zqwtBcn4xKU9lahqTgGuTPrCL67r+L0aqS0x11coG8CghrzcuISv9Hfxg/PtolIVt97PCd1TJhCUOtEjfhgBBDLYJXAGvoKPS9selLfuZXb81lDus2j1bsuyiH8KL5UPcZc3jyyiM8v1VU9oy3pMAjfNlxooe/t7GiULU3ZqXmGthvNpBIJYiZR8KBW1lyJ3cmitBmD5z7V6PmVw== 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=NyagxVLOGfirvc9f6tu4WyEJve+5URvX1q0tll4fckI=; b=ZfbWtLj8b+enF0KT8Qw+Y5q6+VUqq+m/8Hf39UfQePkrHRPit7X8BfKKLTf2D0UEAmXh8Qt3K3UM6HjmNXC/frTlApNb1zcEwFGR9t/Zyns0++xrq0UYkbj1XnOC/fyqKgkhtk5is3yvLevQy6zVgQrKkQ6KJL/67fFk2BiNiECRUtcIMCTuetD70DYDajqbhA4uO+4zhYtZeJauPy/OKTvAbbvhl9fHBj9Nezxae0xpva+Fsyp8duajErsdqrRjv6/0ygl3HxXgbyDd5sf+HxPyoiqzWC28mTLvMs8ZFhH7tFV7OWiXRPCMoFb33foBfbuuTPAbpViFdrkqDxgqgA== 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=NyagxVLOGfirvc9f6tu4WyEJve+5URvX1q0tll4fckI=; b=B1pLhETmFkOqJtArgL7b6s1fji/fMncwG81LBVtM0RqOiXv5uXJM8w4IHir4eIepKhTeiqQxogSeh87DrMpiLe2B6dTL9kQwuPtsaQebT6jlyyIVC7V4TlL0sWHARzsPDgun1puVYqkKhCsWOOwUbYSbtNesXb/zmLnkiW6p13+4zv217O52oWcGVwsyVFP4GKIb1CF6aE5fwJs/2MMwfmgxRJ+4dB4MKuHq7iGjW4Zq6L8vTt50hRSUlhtJ8dVr6j1ZtBEsIPKAen96gP+6ZT6cBTB3zbs7r4a0Bw9wFpBtzyoz1AMD1LwccpjT3xpVyc7XbhbYeMJRqy8+KnQMsQ== 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 v9 3/4] csky: Use generic IO memcpy/memset Date: Thu, 10 Oct 2024 14:36:26 +0200 Message-ID: <20241010123627.695191-4-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010123627.695191-1-jvetter@kalrayinc.com> References: <20241010123627.695191-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P250CA0020.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::9) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PASP264MB4625:EE_ X-MS-Office365-Filtering-Correlation-Id: ef1ec6fa-3031-4968-7d08-08dce92835f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|366016|7416014|376014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: YLpcjJ5Y/Go3GiPoerWhgty4x6Y8G35Nt8bZsUtb3R/qJdztyV6zS15rrPGJzYsk/rJOmaIXOK/7cFxvTy9mHO1lciZXTwLwEnSxwvgJTkUcdhqy+we7wIw7gH28wzV58zWQGClyB6aQ4tqalMXBOUAMMeJJpI9mMGr8NpDPmP/4yoZujMdHrE4hmww6J24k4eLedWxguJTlAn62glN7v72rnKWXIQmM16L1ijQaEmwGJgjVxlgqrlK5CHb3hFa0x23HnvT9bA99XcogCdnWAJawEMNYuVUKWv2DPHl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cRu/Dk3Yq8qtibxEKNZEb6Z8YgXs= 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)(52116014)(366016)(7416014)(376014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S0kGIV68FcXXf92K8csP19zflWXcd5Lc/k9Z0OUQg+cO5Sy/NGVgma5LHNX0PPPtuTpOBhvoIF/EH1Rv5RxJ248nhFFPlXfBV6ldiTpRR3YRmyLT8PZ8LD0BKRTH8N83itQQQ8tt9xDxqZdMPKWXzzl6hy8srmN7IZyZwK6RiJfbczihMSOLcouQznr3NiQud93pFiYLsNsuNPzi43C3pNjfU7es/z9A4HdSCakEbMndrftDAwTHJrNUbINjjtZaaXN+fKOgp0b1hXwHMwB6yGmeio572XW1YeF1fmPq6aZFTBfqmBz9o2spYiJkJSWs5LcewdimqNVfnG0TwrqSy0/ChSk44QGYMOAjUPvhXNK5L+Qkq47oEqVeegON80QMm8FHTYtVku9j5o7rsnSgan2Md0dkzV+M0ad/98wZeF+BzQVrRDR+b2Ni6moBGGUdgsC1O3Tu4CWxAQEaja6uQK9hMGTR68jFbTIsqb5evMOw3dpCMlUFuCLpilS/1YG5Jw2pY1m/McHwl9SAN7Bk4Sg8yZrLk+qfGF4iZmEkU7XB1rJcrtFXvODNqGwZf9lbG8mk782rD+BTnkc+BCozkCxlFYspB8Au2bfItTvBqhoGDfmbAtzjqsDouuc6L84cKnzy1cJqIi6m0DqDucTHucnRGgNNiiFjRj3+qnde/8ge+cWr2uAP3ytnbrJad8Mck6fAo4hialgTQa0eZlwha9ILlCDRQIYmdeY2aX5XNmxoeZtAWHdO2JCwCYUo03lVtBIPK1XLgM67fq+rRmD++ZbL785K8ZgbXnFrkewLcmrNZkvlZRlHDYA4AJA+XosNS4aGvOz3YhNURw1SU3Sfi6qUf3N8m1/pqSbIM8GMMUkrN3d+/t46os7qjljc5o7nfr07cUIaKbZzLMsTSWCFnPEx58+tgXlkwrLaOPUDEcfz6STcrGsRAhX7bcp97Qtb 8120ckUG+tf6D747WNb/Xjk1a4lC8/b67YAt+vlq9bdkjngSbN+vynJMQJAlUQA+aF1GRU5NC0lWdNcpMgYDRJ33FN1rqHFXp9fzTZ9gVxiPOEa4boSoeZDZLdgYOrY+SaMHOSw+VPDAnx511eBZRdylE0pTfNM2Md86OF99jJ8k8hq3Cwq81M071WPeTsK9qQv5Dk8joQwrN8uEeOUtIViX5U3uz6XgGOMSR5s+9XEMswBqCwE0zhr/VfGhd6rrzObqvUVDJ9XeRciZbuv82FNrSvuM8I1KaVjqGZw54GN40aIjdRtWi+Uxl3JugJS8EP5OxHEWU6oH5bTaaXrGFVwQbS1IQFinsvcyCHtiUXf6FH7jd6e7745s/ZgCXTd67wUI8OXkbS5yzT96aFr+/niQ6C9WnJuyPl6qOfZTOICk3SktAxHUmm+kaQVgwuN/4a7trd5WDjnEUa8ysrIek+fhd2Gf5bopKArHFWWUPxjBxeb6Rhpyp1h8SdpVuTjHbZbPK30LDqyH69e5NraHnnnRtGiKoJJ7sRwEqXnyLXdxKy5B1plra1HL+lC26RZ6zU03Zy+3vWq/Aesr8Gtm/HWYi5BYtwWmOFfxScuyzXcPwjtlDIRcydT5waI57akH X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef1ec6fa-3031-4968-7d08-08dce92835f7 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 12:36:49.4229 (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: mO3vuqIxgWTqYXzmPMyg4ezlVvbGsmSzM85a2bDhn2ozCZbGMXWLm9TQiAg/xCdzKuAbkLpj8GLsLakXSV426g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PASP264MB4625 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_053737_793868_FB1A4245 X-CRM114-Status: GOOD ( 14.60 ) 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 generic memcpy_{from,to}io and memset_io functions on the csky processor architecture. Acked-by: Guo Ren Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v9: - No changes --- 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 Thu Oct 10 12:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13830059 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 A75D3CF11E2 for ; Thu, 10 Oct 2024 12:46:30 +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=L8aTlq7JIBqwkllqsnMQNf2DhLRDwt+iHfycOWuWHpw=; b=GmexbTnCG0yyNtnFY1/Tfgy452 buSIWjiSvlg6xuH1xd3uAE5PgYAKFpHO75Pt67DTOEX51vJvCex5Ax6dE79zAQh8YLeBq/Q7kDNc8 nU3HaD7Jw1cHhTloUzz7rXtkBPSTjXtpG8/zZtwoxBhopJc9YJn/GToPJTY7z/EPuHyqKkHiqa/7z 8GeFu2uFTZTX63YT2vsJtFTHLDjgrsxsu+RwRiDQFqu7/3iqNDKzMGQa/RTxn5UG7pqRrcDyPuH+Z sMU/GhSuTL/dz0mnETbhAAN/y+AH/zKu2tbuDZPg1p32uF6VtgVfo3rV7ka4Y52UvQniEECRGuUnP 5A8yTykg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sysYc-0000000CmId-2rUc; Thu, 10 Oct 2024 12:46:18 +0000 Received: from smtpout42.security-mail.net ([85.31.212.42]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sysPW-0000000CjSU-36KP for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 12:36:56 +0000 Received: from localhost (localhost [127.0.0.1]) by fx302.security-mail.net (Postfix) with ESMTP id C677B4906C3 for ; Thu, 10 Oct 2024 14:36:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1728563812; bh=6M6Ssw57cTrYNqTXF8pkA1XmN2bzEuoQgDGkQuiHZSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XhW9y0EmQbU3gTkJCzvaLsT6LE9cEk2VEgXkMZ1WvIrDXK86m83T+YgU+sXysCf6U Gabpnf31lYq3TK1Xb7x4gIzsum98LW5hICPLYhfCyJux9JgNDm5uwudF7cpOfxEuwU DRobW2uumft+Y60aFclMGURjoCeylCIwKm+NIS5c= Received: from fx302 (localhost [127.0.0.1]) by fx302.security-mail.net (Postfix) with ESMTP id 88B8149082A; Thu, 10 Oct 2024 14:36:52 +0200 (CEST) Received: from PAUP264CU001.outbound.protection.outlook.com (mail-francecentralazlp17011029.outbound.protection.outlook.com [40.93.76.29]) by fx302.security-mail.net (Postfix) with ESMTPS id E6EEF4902CB; Thu, 10 Oct 2024 14:36:51 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PATP264MB4966.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3f9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 12:36:50 +0000 Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626]) by PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM ([fe80::6fc2:2c8c:edc1:f626%4]) with mapi id 15.20.8048.013; Thu, 10 Oct 2024 12:36:50 +0000 X-Secumail-id: <4b67.6707ca63.e5c98.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RL7/vOA6jfIXhej3+kykWj5AoUBE5isKBz4tE1XZuQielpGRNA4KdyZWe0PysR19F2OwkJw+FwPVe27PSAPJo4XvCfG9ruOWDQkDSg3Y9L9QcIk3u2vX1oMuBbiPPw07qwTevx79ObZxY8m9eojpaWc0q4PyP0owpPm39RdEjh/PZibhNkFHT6QFS6G7sPt3qiBYorYza6mooI34hHiYlq9qrjl1lcY25P38Y3cNu8go2wIrffjq4ZOY2DOp2vcx+z7Dzv6Wbtb9kdAUznhEY8OorTTp9rVkZblFaZX0NxUXTkpMEUS1HLmGkXSxjgny3NaVZIK/rps4P5UtrMpu6Q== 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=L8aTlq7JIBqwkllqsnMQNf2DhLRDwt+iHfycOWuWHpw=; b=ByPXwvZzPDlYufzsJX8PRTnNjaXODHr+BQBJ6iqXA0ZEryBbzu9Swe0tYuR++yO7voxttetbNm3cImLQRz1N0J2u1Amg10Bd2vgd9Popa74MFwhpHrvIeA16FpzVCBNMfZZNx4ZjCft6jCv4/Iig+WrzpGJkQR+WZghNZvIxLmmzIJXW1+T71PzRY2hPkiMOAumrvmiQk/qzjkXBNibGz5bYhs9T3DWBDjy3VTsppIwNHldc06PiV+jkupm07OsKPu6zwjEyFCMbjDJckFdcfFr9ODT6iavTv5XhuDDykXaDoYGRn3GJdnv9O2ErwDHj1flk2KImHyt8Nw1Ms/qnAw== 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=L8aTlq7JIBqwkllqsnMQNf2DhLRDwt+iHfycOWuWHpw=; b=KnOZS2Oh6TnEf1igco4EQ2Gz7xVUjmS+xgIIsUwDCqwHAv1aXSq3s8bH3ryqI6XvLLjIZXtx421TKSUoy/WR9YAP+6zlHv2kIDF+KHwMsP9FpVLqd/FQK8WPTbEn4WZ6ry6Itav9YJiCWeOULCiMqOcMF2sLiPOllI8uDZT46NNUxlSKSg1DNNXPuRtI35BGytiYwCtVWpwAfIv9zVKqw1kebyS3AFXkHi2MHdTVIB4J0h9fMj9qWwvKAJv3r0PXFAbXEFoXm8D6GAVqefea6l1pJNIayqH/gmNO75wnCXLxdd6wCjZAGWvwsNV54oqwxtgcjyxQiFkUoEiAGUwBuw== 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 v9 4/4] loongarch: Use generic IO memcpy/memset Date: Thu, 10 Oct 2024 14:36:27 +0200 Message-ID: <20241010123627.695191-5-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010123627.695191-1-jvetter@kalrayinc.com> References: <20241010123627.695191-1-jvetter@kalrayinc.com> X-ClientProxiedBy: AS4P250CA0020.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::9) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PATP264MB4966:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b90d6c8-d7b7-4c87-9434-08dce92836b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|52116014|38350700014|921020; X-Microsoft-Antispam-Message-Info: msefDPJvc9IUBXwTsW4u9kSh/x99lfgz+/12/YreLsxPMvvOTwXyGPIh4nZw2t1ih6wiR8exIbOujeGGqTZ9WE5U3tdmGMZiDn7XJtW8x7bsy/wITIhtoLP3lB49qblwQRTLhTbBlQ8vqTwvOc3MTWTy8nd16/A1vO8BGpAtXuo/k1ohPbtSr8Ealr/YjB0fgFC3rmlNwWOtaXr7zUujsnV0t0CzbXzeD6Z1kpKUc049iVCfFw7uDSMKUWBMa9TfA0B1drN+Li5TAeZEulAY57UcuKTJjembqIU1hUo423t/XY3g30r4BksCV6ZRU4Lb39+p6naI/dTIFlcP+ONLwLjLidaQtsDZ+PFdj/pEExZGcFA3FW8BAW2XmfpHVMn61jiAyhaIGyQ8VBynbE000y3k+r1dLDcnbwlu0apWoyWeQPOYWhNtNzKYgdQUZ0RkWDk/MWKzX4hKwCGFq6bg1tGAcCHLxDByLj+T2WgLKaXD5OGys/0eSxF7khteTKqwJrnGkvImOcgOmQDJIZQyHQAoMzu5C0A6QGcrvoFbEIQ3Blzv6snV1+4DHjCYXGKgXMBQ1Oj+rDHI9HTKQcTLTWX0h1Xix44MFm6CjD5cDPI1QVRjN/7h2m5UjLQvjxH7qMJKKnI5ufxTXHukdFu4sZFHV4NAL8kvgmXUBatF6kJVFZA6pgixYSgwDnyNeOCqp3TrbUclzvVxGBWf6LiXh7SHVacPz+907DN9sPibFYG/KEMWh5S0igeiHyDEnWbKE8quKOi/pFohGFiGLfR3cjGWjbFX5GBIqATZ/oNHPcZ6MrwmCj+hCEr/rSoWeUjiHdG7WrNpd7WXJ8wE6/1AKHh2wl8bqVfSyhe9dLONTHrw6NKNtY7OU0hkRyT/NrUDu+ZQO9PKyInGyTczh4Th1YdQdw7S9kDDkImwCe88ws74rQEUrPBrVXkjIBLrWTMHwWi zn2r3My2oSKdLS7ABe3eyHGmWOd0J6WmWhhVQ1l3BWW0510mYLm9jVMKXG+6BNz8ONp4hPWB54qmQcckigC9zThzzAOO3i9fbTxfE5RzEaXmDDGinAOKXwkdVZi3QtLzIzh4RGpCPBi3RIHgjE12fNxUilYba+rfbeAT9nlaydEsoUBzZzx6MQkECqRdkxEATyoLFgziAGmSoeneV7pLsNZ3JhqqIaduxHpGgkDAr0hpj+kPrfhTX9aQl1eBcs57jb7M7eDYKx7zGWABFTNVG/Y2bqbCPhH1eTA/jaMY+6YO3fD9KmUWlxEDPdKU+NT+LFzh4KM/VnRryywKWqDvyHvHDOk57ngel/xO3UYEbq82wGsz2mOPcpiqR2EQNs8K62/KXIvpgy8Wnz/plsgX2muKf0QL4NY6cUn9WeQ4= 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)(1800799024)(7416014)(376014)(52116014)(38350700014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: paw9uiWNyiE7R8rbO39fnzHRJ/sG3Haw1W/oOEIo222V+HFy1Rv8dNWkqZvXVllsY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3iT/Bk7row7EyaDnMrCtaNCJ/THMhtxagtAuIlpWyojIKByEa4B1vTiKBBdEJxji7TsXwr9OvjPyYQU3FSTy3B8ZEJ1RUbv+6JKDaF2Qo0+M7kiHjbqN0DAvDoK035yj4lnVuT7EUbAED2NStUI9eZfGp2QRbDSUsPZSD5K/BWOllX6UXeDiHYT3ZyNFRJkN6BbdqpBqZ+N1UVKQg50BjMKp2XOXCEVFnBC1Z2Emc2ocNV1Q5VpMEzF8+x1jl+Qp7ZkE+ELnqRNeIq1c2qKH9KiQ6YufJYL+dOYmTaElj5X/5ZSfyBtSCTx/LXzYXQjl0k5sabUGKzce4eNB8NXJTnlIH+tqD6zfZYFdWQmZF7NMBOEdZqScIMpPxUdlHXH17sxJ0Jm/Fdar0pybeCGd1vVcfhHEGZBDU6oPXUczxT0XMzIcbuTXKgim56G60UQ0RzdBk9bN0r X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b90d6c8-d7b7-4c87-9434-08dce92836b0 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 12:36:50.8311 (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: jfnUV25QxTF7Z8VEjO/9NdeLoSsEtnJHm6Mq7dY8+cNS5e5GDj/aZrbfJQlbn7Tx9khGMyjyVbfPDH0oDP65vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PATP264MB4966 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_053654_941515_CCAD5849 X-CRM114-Status: GOOD ( 14.68 ) 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 generic memcpy_{from,to}io and memset_io functions on the loongarch processor architecture. Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- Changes for v9: - No changes --- 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);