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+HFy1Rv8dNWkqZvXVllsYmewgLxtyDXdTlL8bwPgZf1f5piUn4iEdzPuTQPdIzuZRN2iLZiWvHaTK/pLwyppqkJ/bYr61ZrjruiADsb8yBj9lYRwBn1IlbtjM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DaF2Qo0+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);