From patchwork Tue Sep 10 13:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13798553 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 B2BA4ECE564 for ; Tue, 10 Sep 2024 13:47:18 +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=+su7xVP/nBK4AP2/9awTMq43uDqoTskCRbgvJzWwbmM=; b=xo6akpis2YwhnqKajP31HM/xzN GFjZ6nO1iE743qKIlGxfrcj4QYceglaFMdJmkniRlnxWfEAUns9ZKKvDF0IxWg0C+4+/+G5Xki/ES jk52AgNy4aq5CvLf6umg+xyJxGn0UvUFMs+04Vt7EzrKGiMVDy3C95+6vgavXxHIwGvb3PkxvXvYp 2tiJVy1Bjouj7YgQRH/fFQQ7KbCZQdG1JFtti6CZhI8RkFiZiJUtdBaPqkdV8CvlHGNboe9ak8T9C Vrg0M2ROPxAG8b6rLjAvtzFiZcUTmQ2zPRKVjwSTrLYozQUXuUCSc9/MRIhJ8UgC88GDN4yKnnSru mwDnwQvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so1D3-00000005ldS-37UB; Tue, 10 Sep 2024 13:47:09 +0000 Received: from smtpout35.security-mail.net ([85.31.212.35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so19z-00000005ky5-3bcE for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 13:44:03 +0000 Received: from localhost (fx305.security-mail.net [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id B933930EE14 for ; Tue, 10 Sep 2024 15:43:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1725975836; bh=JDefL0JG3b+NbPQBChl61mRz8IW4sP4EYSbbUOq6XKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Fpt9Y4epiTzaVWv5oF4POVwyp+NjImk4reLkMCdnLeQM4X2jDDrJTaJJ90bAN0gVA jtU4JdvXH5twtNGyGrlRV2F5n+Xr9z5eV8MI23uqJmVgceYQrsH/iWhJbTEgUyIsU/ Bh15rWqQkYUxf5KYgvPONvhtzc42BNndhFEsVc6A= Received: from fx305 (fx305.security-mail.net [127.0.0.1]) by fx305.security-mail.net (Postfix) with ESMTP id 62C9230ED81; Tue, 10 Sep 2024 15:43:56 +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 64DBD30EC35; Tue, 10 Sep 2024 15:43:55 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PATP264MB5061.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3fe::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Tue, 10 Sep 2024 13:43:54 +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.7939.022; Tue, 10 Sep 2024 13:43:54 +0000 X-Secumail-id: <935f.66e04d1b.6375c.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LJrJZ6H3lLNR5TBI+gXRmwoTZnvG36OMP1o7weIh8gUXT5CroKagraiVAYZUDlEJmjecn2mcS+dND8sB+tY8hM3SA8b8NOmWoqp52K+iYQTrMyJPdl77gY7m4ei07SDAy6426tO4PLHJ266huKY9SFbVcbv9lNmkN3rl9V8DUpZHDBGKU5avxgCaskIz97HdwFX0vmSVDk5DMtv2rB5Huidv+ErZxrNhw9gUzvCijxTyCMv/ila4fJ5x2jW+3ENEDLdaFY55/d3fv7LSEUa5vXIYw4AkFW8eQty6xTe9KkbWev7do4GT4jZW32hDs/tFBNPilC8sm4Tsq5s6uCHV9A== 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=+su7xVP/nBK4AP2/9awTMq43uDqoTskCRbgvJzWwbmM=; b=oPaWqMVlz215fcRsSlrRuT9fSHzf5uL/iyTgcBv4YdX4sTrloh3ukNKD3wS559lTSUE39/GWW9LvA10z8JeFevhIx7APe/KYvfbICXrMSoUgQWpcDbx/qj4OzFw94SSWwXagO91VDC6TZk3IclrZZzci0ICfJlJa3Xh7XGg9stN6xGUdhmeri1kFyFCn5zDbrifV5+knix4sTwlNx9eXPzDZl6FxJq3yYJtYIMv4GVEvrgDkYFc5hcUiINLc3GQPApfILb3usPLyk7eGd2TZsQqi58mZWsy5Qr7SM3NhPnNKNXoHh8S3USa4GeCMl6guJ6MAfRKOU2eldH7QyrPwJg== 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=+su7xVP/nBK4AP2/9awTMq43uDqoTskCRbgvJzWwbmM=; b=cgEF83kuDVLwS86gNX+/kMewtz/OMWAfi2/jPqblyKy14QX5qoKwxTRWcR6yWmrUXy5TQoMWy5ou8liWt/sJG278FWy0xdq0RpVfaxqGbTEOyIiGxzov/qD7UtYGZmMR1/JPo4mutOiniOjpcj1hDUH4jDporV9xQlCwJLx8WbXchT6hOF24tuPv6o21ZpsRrJJsN39wdd55IdfLYAC9cn0DVPTwDt8lPCexkfBBZp+lF0XM92/CgyQU28+dUpKmfHuGmD8JqNJWiQWcdI7AQy/8m18sK/kXiUjV5Slt/rxFHDN5umqtZJBOMwX+QLIQcAOZurV40XOVI8HLHiXC3w== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, Yann Sionneau , Julian Vetter Subject: [PATCH v3 1/4] Consolidate __memcpy_{to,from}io and __memset_io into a single lib Date: Tue, 10 Sep 2024 15:43:38 +0200 Message-ID: <20240910134341.2537407-2-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910134341.2537407-1-jvetter@kalrayinc.com> References: <20240910134341.2537407-1-jvetter@kalrayinc.com> X-ClientProxiedBy: PA7P264CA0210.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:36d::16) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PATP264MB5061:EE_ X-MS-Office365-Filtering-Correlation-Id: d53c8735-bae2-418f-5769-08dcd19e9cbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 5FFfgJajGl5O9H9xm2XQpR5aE8KM0VWhkNdY1zhU8UPkI6c+K0Y3WPjhlrJh388ntkagYHFG6SiJYx+FQcW5/BVEeanTI7KAs/pdrK/ElbTGkxQTL5uq9caCQ7IyjtDBgPBbu095Pc2uVIhvIzFnzp5nu1tkk2xEt9wnoQU492llVsiXSGI4FD7HYBIn53ZsWA+I2sP5DBREMsxV/VAWfhFaaksceaXffGd5OgWgHNwF3riGHBGLndO2XH9RetJxvkMRmsndMclxSbkqlflxTOyYic5HDJDmjmRjAypYW8iJk3tPvGwFwdd1Dv+JfjqCFHZtjILxwf16fRAAJvmXSE0tvjQBdfwjEq3y3wiaU3EQPOg9DqilMbENtz3Q8jnjPhTphwWnretipDNB6QNKDdDcH/RoRHU/qZOYmTULDfH8mEAFuUgn5puMgAY9yPFFSo6KsxP0fzREf9hFqBkRjiOOAh2mqRDdUXumT6/naT9Zgq8MMvoOQ2gHBMIZXQJrGGPEAy0LzzkHoyRvglaAVsPpWkF57btCNNWp5NxxM30wr5fTLy7AJ62fAmjvhtiNm/caBh1qZJWMhfi5zslsAUUaWUlu7Hnrsa/pZHFZyP/rSYv3Xsi4+gCwZMdoo1hr66IH/CL71VNu7DaAy1Y8OLHWRITNP4rUhcK5SX1iXCEi2nPw2YrAg47WymaDW4SnXswgFJYATrOUmgjza9gtmfgU7TsrezbrpUA69eLNCF3G7n4wSIHRkTOQFzz4xcSi9yUmed96tMFLZCsg51+SU4Rhh+qGHn7oOSlFLo6E/S5aYpjvHJnncKMWptKwQ3fuAClAEKUJjFawuKIZzXBt2Q9ZlSVVukHYtSHUiNT5va9fF8Bmild/N6tYCuok6lGww6JelNbUNY4ijfvPRxCctmKlyP01PVFibQqUb8doju5009SZoAJmtLyHyin8t65r6D/ h1Zj7RCBOGx2PJbiaDrTBhs8u9RyqyJB8kNLSyfqSbjNDMbHvUOiGzh7p8gjjGnJfNWzFzq3t9y4tP/+nVq1W8gR/t57bAPvcGiKfudPRuGIU/YEjvezmpKKagn356BbOSeUUeXWuX/gbxDZ0LAeSOtcqZkofjhdn11yodbgWje1bA3Kjt8DmJfSnZJ3Crfz2GgAStWlgeuJ4HMX57HQg2emCnJFzomfu4AKQntn1YaVxrBw1bhCqHSY25h5Ud4nsoNosUQTcm8TWaAtwjIGAP56xnPMf7g3oGqw/PZkHnvOyTG2Xk3s9aoBf5DVcgBOTKr1mtm0rNT2E1EQ74OidhICMficZxd4DTA7jf0oV03z3Pv6las5ECXxp7IjoTKZUw/GxqpFXGSj1nmkJ9TjYKCAFrF+2sZ4ZHR4+S2SSRL1/4DndF+rVyybUA0PVqjqg2g5nKsNURTDxwNRUAg== 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)(376014)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +BwfniH8s6borJ9J/wkpH1ldr7q+uYD1NpzM22THyeVJC48Qy5LEBpiPiNUKDz0q9M8LvEta1PspkSW976uv+RX8zK9suwgTcPeWJ1LqBIC1U4HIGtWve+2yWpWVZrZcmCreWxfcFcTjAwmCoBTOWjavRBZ+ZqeqV7QUPOfnuLR7mlzT2LZj24JAIreStFkTRBYFCilOMEUmi/shkPjY3XQqEaqqNU+Cd3CZ2D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2d2M8rqCHkZ5sgw6EBdWcIEw33FyRINu1s7V7rx4IaWvc+2xR3HAHFMibzuon6SSCkrpk29wsqO5qpf2c/9hFa1dFhFk3LtZ+E8ZgTQvrAn9tc+WzuhQq3/W97q52tU1z3bggn/ydOAN0SZEgAKIfQiSHeFopJZzgnJwdI4j2eMXZy0+W6ojebT5x4GsSLIzyaNWlXH2/o6bBwVIm5vhGB5+wzHSlS3LVSq5rIaIEQ4bmwv26P5OZLW2c0SskzUW+2ujqpf5uunr4Uif+JqbXiMev1bnu9eTJY/mhopW4qyg== X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: d53c8735-bae2-418f-5769-08dcd19e9cbb X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 13:43:54.5218 (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: xrk1lKVNMbb60J0TUXDnwfpvoWP/E80t3dkvf/DqkcECOhIADHIEkVuVZG6SxvlOUr8qMQJwvpKlfAJ3D9WF8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PATP264MB5061 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_064400_193603_FA7BC4BC X-CRM114-Status: GOOD ( 16.18 ) 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 and introduce a CONFIG_GENERIC_IO_COPY flag to build the given lib/io_copy.c. Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter Reviewed-by: Catalin Marinas --- lib/Kconfig | 3 ++ lib/Makefile | 1 + lib/io_copy.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 lib/io_copy.c diff --git a/lib/Kconfig b/lib/Kconfig index b38849af6f13..741550bc3856 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -70,6 +70,9 @@ source "lib/math/Kconfig" config NO_GENERIC_PCI_IOPORT_MAP bool +config GENERIC_IO_COPY + bool + config GENERIC_IOMAP bool select GENERIC_PCI_IOMAP diff --git a/lib/Makefile b/lib/Makefile index 322bb127b4dc..4f56ad5f9ed6 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -130,6 +130,7 @@ CFLAGS_debug_info.o += $(call cc-option, -femit-struct-debug-detailed=any) obj-y += math/ crypto/ +obj-$(CONFIG_GENERIC_IO_COPY) += io_copy.o obj-$(CONFIG_GENERIC_IOMAP) += iomap.o obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o diff --git a/lib/io_copy.c b/lib/io_copy.c new file mode 100644 index 000000000000..f44583166325 --- /dev/null +++ b/lib/io_copy.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * derived from arch/arm/kernel/io.c + * + * Copyright (C) 2024 Kalray Inc. + * Author(s): Julian Vetter + */ + +#include + +#include +#include +#include + +#define NATIVE_STORE_SIZE (BITS_PER_LONG/8) + +void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) +{ + while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) { + *(u8 *)to = __raw_readb(from); + from++; + to++; + count--; + } + + while (count >= NATIVE_STORE_SIZE) { +#ifdef CONFIG_64BIT + put_unaligned(__raw_readq(from), (uintptr_t *)to); +#else + put_unaligned(__raw_readl(from), (uintptr_t *)to); +#endif + + from += NATIVE_STORE_SIZE; + to += NATIVE_STORE_SIZE; + count -= NATIVE_STORE_SIZE; + } + + while (count) { + *(u8 *)to = __raw_readb(from); + from++; + to++; + count--; + } +} +EXPORT_SYMBOL(__memcpy_fromio); + +void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count) +{ + while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } + + while (count >= NATIVE_STORE_SIZE) { +#ifdef CONFIG_64BIT + __raw_writeq(get_unaligned((uintptr_t *)from), to); +#else + __raw_writel(get_unaligned((uintptr_t *)from), to); +#endif + + from += NATIVE_STORE_SIZE; + to += NATIVE_STORE_SIZE; + count -= NATIVE_STORE_SIZE; + } + + while (count) { + __raw_writeb(*(u8 *)from, to); + from++; + to++; + count--; + } +} +EXPORT_SYMBOL(__memcpy_toio); + +void __memset_io(volatile void __iomem *dst, int c, size_t count) +{ + uintptr_t qc = (u8)c; + + qc |= qc << 8; + qc |= qc << 16; + + if (IS_ENABLED(CONFIG_64BIT)) + qc |= qc << 32; + + while (count && !IS_ALIGNED((unsigned long)dst, NATIVE_STORE_SIZE)) { + __raw_writeb(c, dst); + dst++; + count--; + } + + while (count >= NATIVE_STORE_SIZE) { +#ifdef CONFIG_64BIT + __raw_writeq(qc, dst); +#else + __raw_writel(qc, dst); +#endif + + dst += NATIVE_STORE_SIZE; + count -= NATIVE_STORE_SIZE; + } + + while (count) { + __raw_writeb(c, dst); + dst++; + count--; + } +} +EXPORT_SYMBOL(__memset_io); From patchwork Tue Sep 10 13:43:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13798545 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 711EEEB64DE for ; Tue, 10 Sep 2024 13:45:15 +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=SVUX+6s45Z0ge65VzI3FZt7ZlDdHSX5oJ+Km/4ciA+s=; b=OgGj6F6ySWLg6ysrYDFiahnmB5 4ImaagaMtNxBM3lwbimSCe5TCSg03b5i3GXdFrzxdpAfcNJRhVQ+1XxBGIhd8Rh5Uxk8l9j9erTov /xsQgR/szYtlbPWuxWkBAa/pHQp/B3arcEbIljUcAe645JseFfn48ReNa3m9dTj/DgZz+kXBsVQqr 6tyEJ3Gtbg6Uk748XwF6DOEyL32CU8Du7NTb7dBINOIgoRTUf8TZmhvwWdiqbybjs1nrfdFzcvdiZ /LSrFbNmd2y9Apo0duqEzGZ465Z0h8RiZ23aW0zYPRoEhJMsV6pMlcJJlb2C+00InBLcHgROH3+O8 OvksLvfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so1B3-00000005lEp-0qEx; Tue, 10 Sep 2024 13:45:05 +0000 Received: from smtpout147.security-mail.net ([85.31.212.147]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so19z-00000005ky4-1jIk for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 13:44:02 +0000 Received: from localhost (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id BB787349BB9 for ; Tue, 10 Sep 2024 15:43:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1725975836; bh=fm74sZv+wQupqd1aA35tAP0V73LJDMRwcbwSpgpGSEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cjGi3+w+HlaHKxH9aF7yNmE9QBjyldeCW5BOc7a5uKvboDWwj0BAJrTmyP4WH1QK9 59YZvznORUD/hkcrC8Kx88kXAP5nMCx0cO5mrMd5lAXVvHe/lhNQK0AcN0pmk3aOsR dhzeFTaB1y2WN2rycD4iAN2zuS5AJQXjBbIfDqLg= Received: from fx409 (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id 7D038349BAD; Tue, 10 Sep 2024 15:43:56 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012050.outbound.protection.outlook.com [40.93.76.50]) by fx409.security-mail.net (Postfix) with ESMTPS id CA5EC349B96; Tue, 10 Sep 2024 15:43:55 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PATP264MB5061.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3fe::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Tue, 10 Sep 2024 13:43:55 +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.7939.022; Tue, 10 Sep 2024 13:43:55 +0000 X-Secumail-id: ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dUQ88BgDpG2+xQKfyk4YH9e9xoTSBgWecL55/QF+vYrX+yXco5AjoQa72hFNULzWSBmFwVNyjFaCHKZEyiWjc8W6ZoYK/LMGpH1V4MC77WC19HTCC83XcnpgyibjrCTR2qrtVjlTWMIrYxvuRRO3nFpZPyG5lqLOucqtHIWt+fPY3UXFzEYdAhAlEOh0B6JdLbzINGEtUaaYIQCmMHadqxrLLlOeFOlGpdBKBah0ULbidIDjVEOmOlhf7o2uUiV6Cy9ROOpKs8tqH2NbWsrHzgjUTqRvr34BhlFxv0zFVgFSqh8l848mu79qG3JAUew6SxwJknIR4Lhcbgd6tZppvQ== 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=SVUX+6s45Z0ge65VzI3FZt7ZlDdHSX5oJ+Km/4ciA+s=; b=Y3zn4ueocN7zuJv3UEqUXPb3zTt1fIPlkuKLVktdlEuq8B60ZOGrsXTXhuBnI+yqbBVBZILBXoRpNLIylYcRAn9QpY2PqndpxdkSXRJf8Aj+lxNWE3QGFApB4q+CxvwR4/j0MFtCXflQNEVfoOE9J6OuO4kePOWMHUrlAmzOg1rQKBZi+ZKpONLHdgSyWXScRdl1PN3DcFqF8H79oVln4UsZZODhypwYWijS6K/52rjcd6y3ZYfJjWPT3COS6AX/gyjJcgCwgL8hl1NjRmjBNBN795qCDHBOpGNJGv7wYiVngeaL5hmc/VNKJ0DKR849GUqeU1aMUKM/e5NLRYkzCA== 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=SVUX+6s45Z0ge65VzI3FZt7ZlDdHSX5oJ+Km/4ciA+s=; b=Zw1o5HhpSys4v5vGeASRreJY6Pn8or2gPIGz3iRhx1tJx2by9Jz9/4ZIylWf45ZkgTSJVXaV7clvudqRItPaH6b+055eWvRPLdo6kZ1NbB7PnfiBI1GBT/dXJ0dWlclE93o72pueDYesmaQqSxDushdXgT4fDEAxkak0O2knIHSsZXdwdj7IVt5Qh6J7pgZlzPlvQBQLM7qP6S6qleuti8gKu3ihhqBnuZGt5CSlrNJgUL5AYOSn9JPOHeWkb7G6DAy6CZr4HcpOvSXBWHTCPYpjpVd4IgDbITLZZhs9Tjyj9LtgRW4+U56zlSPT0bXrrAKGxP3nepryPnJEi2tc5Q== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, Yann Sionneau , Julian Vetter Subject: [PATCH v3 2/4] Use generic io memcpy functions on the arm64 architecture Date: Tue, 10 Sep 2024 15:43:39 +0200 Message-ID: <20240910134341.2537407-3-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910134341.2537407-1-jvetter@kalrayinc.com> References: <20240910134341.2537407-1-jvetter@kalrayinc.com> X-ClientProxiedBy: PA7P264CA0210.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:36d::16) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PATP264MB5061:EE_ X-MS-Office365-Filtering-Correlation-Id: b998ad41-e969-4308-0ab3-08dcd19e9cf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 31UafPGHuOZCxg1bE+0ndFxvDPbeoffnwLHMxpdBthre/FPBakmM5DCW8nEA7qQ6bQZmNPr67rq6xjRbOI4LxjQsGlYT61rl6Mstc6Gz5OmQfSgr/4U+MooZ91gJmFbeWg/aePs7bV+7qck828xOuFs1KFbZKh52l/pJn/Z9N9M2gFQX/7Gb4fq/DbS98pS2uT2qn6KYFZPOYfxUpAO59SYoAqifZkUzFuRpvuCQdin4dY7OEVmwjqUb/TvECvL+9+6Y/7EK8ukfANsQ3BRY/2iYtmcf2Tz77ujHo7Tys2pEtawvgySCMeVaQULdlrudNYQ3JwwJhhFSLt0RIKLN6UgkV1+k8n9DjNlXwPkD3xHZsCZryG/475y3wOjdA4KoLUqDm6IwAlva2ew/rzMA7eXkzf8BgX8flOJFZyGxOoEUIi2s5pxEf19Ot8yy7Ywr0zOAxAUDPe2AP21ULX6kBdQuyWRTntgHkm6PLvQWrjCJOtkYxQInMZxCgpDtVXPRkVBhAw/Q+0aMzgXygJ4XPOPZSX91o04lhMwQfGsYppKili8zfvG3C6xiHQTyQSUMS9axHpQxOFe2rjEIj7s3AaNKp3C7dVspvO27stIyKneiIF2fhqA1WM9r9jxA09GmvyV4vjKG6kwLg1Y+vQ2HuyC0vpRwxoqTnx+ZrXtvLG/wKlIBrtDGdXzXMRfnxg5DKNeZSN0/+e97BUdC6aVHOLx/rk1nf2YH95BlqIzj/6AW6IlUTNNMstOccPtQd7kfWBTy6ldNFVC7t0eyNKLyyugsdo605eKjBtiygKyLSm7rBrP/CZ7qhRwi5ZCMLBUUzSgkgYg/+XcQisBZTzdOy/o/223PQkG8WGRNk53ZdC7u9PEopKMxwqBI7/ALOfvnSl+4ryWpRoXEhOe0Z5BG+bIlJIzMVUISCLGlkX8T3sjjlTljUM8eGWU86L1rzGuGzf7 sKMKMg/G7lWwQD+Zv3LoMuwKlx5P8pNxQlQSmzQROhjDZSF7RqEnDdXTcvpLkaJFPPSANuiQLlozGthu9jOB5JHQOLo/w1W6TrJTeU37WhMcYg3bSRxQOxDXgGBi/Pqvh+pcrJROvbb9y4h0KiTmtN66FwZ/JYsrc9kd9ZUgJ2orpEfhndPmjfVtESarnj98YnCvqbZjQXlctk7l+FUCPpUHWhYE5ifITyR52Zbcs5fmAW5+i4N8rp/Xeu7RTD8/E7G3Dsw/krufokGnKDvMhoPA8ck3gduTzpuZLE1nSRWVCNXtLza1WT3FBZXWSyku/vRtI1QnpTNnTGCLqtEOIJS7XPd6GjGmLk3K1RdnF/G/xBAuSLrXTLzpsaatUaSoAXzgEXfJ+GWkz1xrZ88gkbKfTtxcu9YuVVZHTinCZHXdEGbzeLvUU7NdQjaYAwMqkBEkbwPsNq4ofyTgszg== 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)(376014)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tG+4y7dXq0CRyeeyf9e5DJCZV91kHohZaXW3Z9Ffw3rx/WOKuNd7tPLaD7qzf6iKqT+EC6+CWp9q6jDDUNpytDB2OJ8JBqybg+xoNE4LVIlfeRRxsPrfDmhhWbtObZxNtMQVPThLMXJTfWbuJfKGP1VkrFVXRRvFSglj3lKgwuz2DLdjok6ED9pMHixeDy3D2pqzIeiJCF6zprtV0FlHcBkZ9GuFKpzUA5qRgI6vBdklFq/naPXYItPn+y7sR+Zfp6CX11bQujQlPmSvO/iGkEF7wP+vk5/z2tLgT3x/R/LQ+xi+tdkpA36quyrHFj5THrPA+sK5tR4+eIQ/7eniIoeWcNZwOo+1DygjQR/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VXaHvD8u0Clw6RH5VaAhtFp/mxbE4i47Qej4R/ZI8wcKHKGIAKomWmDMl1f7XxHAA9Yeps236lIk62MO5Nb83IKS3E1Zb6mHffiTZLedD2bFBWsXRzNV8mzfp+2eanqJTlfJlbnZ1UQr/7AKOvjAgPpSPgGhFKbJYVx3SNzDGxuxeWw== X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b998ad41-e969-4308-0ab3-08dcd19e9cf6 X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 13:43:54.9523 (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: Pi+dE+Ex49HAFI+RljkGXDPfv4Emtu1nilNlIa88VshU/xnF9motSu4Kowtuyy0VfbOSvMAaDfXrIjccn3cv1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PATP264MB5061 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_064400_109982_42861B8A X-CRM114-Status: GOOD ( 13.92 ) 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: Yann Sionneau Signed-off-by: Julian Vetter Reviewed-by: Catalin Marinas --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/io.c | 87 ------------------------------------------ 2 files changed, 1 insertion(+), 87 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a2f8ff354ca6..cfb1c729c9a1 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -140,6 +140,7 @@ config ARM64 select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_IDLE_POLL_SETUP + select GENERIC_IO_COPY select GENERIC_IOREMAP select GENERIC_IRQ_IPI select GENERIC_IRQ_PROBE 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 Tue Sep 10 13:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13798554 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 CAFC0EB64DE for ; Tue, 10 Sep 2024 13:48:21 +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=DveJr7zsBccpWvAJKIk+kTDfNX03apt1gxEBBsrHIOA=; b=siBzetoHrfP6ZS0hgBk+5GMpuZ HyP7JMjPUgsc+ixRVswPnXGdl+NE+P0P1wvxAgtW9tHiP9sj12bnzs8x96OClp+L7gkELvZEH0qFU BotX8j3UHwS1MRoFxkLW/LldR+7TkBqAiXdnDLnw30tM5xcZJEWNKABqQoa6LFpUYf+SWVF+JNE++ KbqY/K4GB4xG7zRI4gd39ggnbJSMLzecAexH7/pLxwLUCnkBG+ngHISVPJpSgd7HIB6NAxGw51jUj RsnRhjj3i/WTxfVfYKvD0eaRaTro6iam8yHn7nT2DfjWML7oereocwy1NsSZII4Ftqt8V+n1zPHLi aynqPudg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so1E3-00000005lpQ-0Awe; Tue, 10 Sep 2024 13:48:11 +0000 Received: from smtpout147.security-mail.net ([85.31.212.147]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so1A0-00000005kyB-1ql2 for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 13:44:03 +0000 Received: from localhost (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id 88112349BE2 for ; Tue, 10 Sep 2024 15:43:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1725975837; bh=DlBtsP+yHL6mWeXFHedZo7xJcnsxHLkO3HTJki7kIVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fQcktVDUB1BUiO30SfUNITvUHDlXDUPraHjkqDB+gppdzgfS3gCnnmCUQWFNMjwtR 8WQprMt4t3Cu0nLhDiehR245fBAe4ot7cevaLtu8RfEUg5AXFWOf7oNyYlBFMDC8NL 9uwHhQGn6SisgRub/PifHsyltiQZIJLCEE/80/RM= Received: from fx409 (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id 3770A349B95; Tue, 10 Sep 2024 15:43:57 +0200 (CEST) Received: from PR0P264CU014.outbound.protection.outlook.com (mail-francecentralazlp17012051.outbound.protection.outlook.com [40.93.76.51]) by fx409.security-mail.net (Postfix) with ESMTPS id 5A5CA349BAA; Tue, 10 Sep 2024 15:43:56 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PATP264MB5061.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3fe::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Tue, 10 Sep 2024 13:43:55 +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.7939.022; Tue, 10 Sep 2024 13:43:55 +0000 X-Secumail-id: <3127.66e04d1c.595e8.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z0iW5ef8Qv9ht03x8kbt6pIXF09AQET2H6Rr4mXqWqrEElj/k9UKwcc3zDg9BQwYS8RfciIlrAnkGBH5XHWVeh2+1xIaEtv9K30Rim2TenysjsTFLkCBqwLV8qWn5SQEitnRA+7ZHSAHC0x7DT3nz3UOw1BqX0uP1QFwj2/Rt/rNVPYXOu9RbdIrn62QKHjBJDoLwInFJg1OPbX6KiGi6z78Ob88oZd7AI+D/f9yp4M8qnNcEXFLtHS6hFt//KimoxtPH+67wt62wB2x8RHlfQcW/hn4M+/ix+wZRLCO+W4VobkYqmhkIyGAZIu9RrZ+fNBgCDWFvCylX85vRfz5lw== 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=DveJr7zsBccpWvAJKIk+kTDfNX03apt1gxEBBsrHIOA=; b=BX4n0bl0P18O0njNRqfzzeSz5H/Xrp3aCJuM6SjLhsqo1ORnuzEwgDHrYROyPwTgNNXW/wqFl/qRf/UCIgctJqjGh3V+jkpDnu78JI/qoC3jLFqtV/ZUG/21etrNjLuHxcsHgKWREjSTOtmm5p6jkNEE3Nelw3ad0rnM1P8z8pAjD1Y/FWyGh/2uTuo19iAFGcoZIJ29PuHYrM038cOujtibFXkTVzHR5aqvzGFGwgyd357RF4LKEECuRjEvmiHeJJi0pEaSx5xDQ7+Jqo0gfK1E05Pbl31e3SzTMd0zL+GL3eRE17q/JxNAsZP5KdP6jpZc6YVZ9tTO9T7yLqUb4Q== 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=DveJr7zsBccpWvAJKIk+kTDfNX03apt1gxEBBsrHIOA=; b=VdBgqKsmy8rvfyMmlKCVk66K2VOjiqlMiZ9jYT5fz584MJiBVqNb3iV2NS9CR+ZFNNCkmEwaF/c4ak8qb7IEyKZ4Aa9Vv0IMCpn8SE0Xq2079ie45SgDyZWokdeBBHKOK+Ej/5lAjGj+Y8XVk0cQif6zbkwz3tTSYJ/3Nx4mMnDL/r86vM8HKUIVJVDhWZ4EP6egbCzq6RhKBb2rsu9RSivsZ7enCVMM8xrk4gA9U2QVKLGbJ+5V2UDM1O5wDZCaTDbj0QNMsmvRyctA1WJ1xnHWRUAomE2DarTKEZkb6dNvz8hvcRkZCL5WQclhIFQ/fgGY2JNyKnjpOst8z/LhtA== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, Yann Sionneau , Julian Vetter Subject: [PATCH v3 3/4] Use generic io memcpy functions on the csky architecture Date: Tue, 10 Sep 2024 15:43:40 +0200 Message-ID: <20240910134341.2537407-4-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910134341.2537407-1-jvetter@kalrayinc.com> References: <20240910134341.2537407-1-jvetter@kalrayinc.com> X-ClientProxiedBy: PA7P264CA0210.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:36d::16) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PATP264MB5061:EE_ X-MS-Office365-Filtering-Correlation-Id: e7141727-83c3-486f-3c53-08dcd19e9d4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 5pVqRklXPl9xv1mqn7umFca+wwcYCi6cGihK1z7Nc4e4FW3veCdVqxDM/mqVVYSB9Ug8isyLnnf3xXglgrFtRFpWeBbgyemRRjQ5Bf3lPuvXx51o8oV3QK1nP9tyuR2GxvIjYAgTFMcv816D+0P3KvST/LmlUKwtbaBsbczpzd4gpNK2xB+oOPJch2Y82vxAaFsQ6yuHNSsQrFLY0CfJBNO80yu5CGl4UsL9Y5Db6L4WG9wuAFOJzdbEPeanihGnC8RcnybqHU36zhnu7iNs9Gvsg3NF8hNqwCY4PySfPqCtYhSciyAZlCtplV7+qNFl+wipLeCEpRsmIW3FyFEW1flid6bIt9kRx4L7MhK/X7evz3zXNxBjTAPhHtWSYp6MdfrnkAk2Hpc5DPy6cjnH6vCwvbDuNj//BRIUVDS4kPAo8emlyIAXVMLCnrcBiyJg2A7B4ddMSj8O5ok+5Kv1MWMg9S44OFH3IjNyCYWKuayUuMgujP5c52qi016Mi383VUG4kOsKTlIltWODFrhd9CqMa6vdedALKgYTvJy3qzPwb8tEQUinKe5s+UcZ7S9uJSd3RhJTHMij4V3p95r6RWJKeKrWDxezF1knx0x9zDIXVTn1SnXC36du4KN6V9lMU36iiErBItZcZ6zNGrX24McivJY2bZdBE1/TsDd755Ly9Wu3dBaw46JDklBK/VTuDYDn7nBfMRGQn/ODmQFDsRgfUf++5gwx7WqTvZkqFtN+mb15zDH6m1Sj9XHJoVC68YKliUrgdMurZZxgq5Ip/Dwfg6bhY60FTGug7knRN+v27Aij385w8UU4uDeD1B9fw7SbwX/XmE1+4cQWl35v58MzOvbxyU6FwPPlBtDphyBU3F8HmYxtDeElhptieqTSd5gQAaIoA+lJeQm106aDGbofCSNWiONxZB25IcsJvk7MsBS9e6dfDIj9PrRMWrW7aeG ofWjWWdcoU4HyzH7u/7SlShxDXfvJYnHaO469wG6CxZ2CkEfz1Dot5N5C6f9t7WqLOBtXoXwH0fzOTukiAruWsjXIxLBU8qFzize1WAe9NJcJZZUQTthZV5i7N35AET1h+ZquZqTd66YoB6dOu9rufiT8+seC9aZQUdRR7xmqxSoQT1FVKVXEuKE+YWkAv0rJKB4ZTFhWhfKLpbk5X86OsZNjZYPUosTtI8QZcmIvryWxMsdtgxy2s/CmK+bA3AwNkLLXLz2L5it6GZSZnD9DmZ7v2Z5cTPuv4UAGvNl/KRvPfqRp/1iOu5KNIWy04aL53wA4diax6Ha4Kus53EluJrFmqsv7N9MsMGLdgHroSMpqvDn2dK37UmropTGbdJpNIwAfQ0pTbrP1XcIVIX8hItLfJvBv5PuymA+ey8cKZwIZ2WY79u3jDDImnEOzBiw3Qu8Xxkl4X4L435OmiA== 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)(376014)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSp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BXiR3U6/owBTWj00BAaWVRq3gacX4eiVsMt99zvd9loGFatV6Mlu7C+U3T0b6+Am2KsAQz9ZKnRIAJdwGL32fJ9+b428/oDiesmBXnN6zCVpn21NKIKgm1G+7ipEMzP6K09GgCIOnixRynes9t9cwTb+7fwIm/m0JGkcGhT9wKz+O8CbywHEPF4hgf8sLCTpB304nzo2ZsyodxYjUrnAK3OFD435qpMQY2v5MNqDxQ5uCRivKcIgVm6WhETfUnXh8RgF5Mcyox/4q7AHuQoYCkEAk22VxbFwKLbF1jVbNo8CmeyTHYPAI2a7ZugHe5zMQOwFTiMzKDFw2Ys1IcLPSCoayyKwPF0TNyOcSHnn339mS2P8B3x9zPZbI1gDwy6WU01aTdKogO42oj49cngAboI+9ToOtSvzY/In+YAUNdMPzVn6b2Htd/ln8Fl0ia8wsRgAZ8NrPGef0eN7yKT5EE2mGKt5xyE079HLg/2QZefKPgZS3py73qlRf7nQx4Ebkx7Xi6CwCZj+IvqHt0/wAlNCD7xiaf3e2xFQ== X-OriginatorOrg: kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7141727-83c3-486f-3c53-08dcd19e9d4b X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 13:43:55.5398 (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: ADHzW/q2cd9N64XRBp7Kvdi+f5FO3N4PDndLjTj+JRN88nq8mWnv+Vz/NiGfhiXKtTdb/ogp3V9gWdH1at+TTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PATP264MB5061 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_064400_759285_3F93284B X-CRM114-Status: GOOD ( 14.42 ) 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. Reviewed-by: Yann Sionneau Signed-off-by: Julian Vetter --- arch/csky/Kconfig | 1 + arch/csky/kernel/Makefile | 2 +- arch/csky/kernel/io.c | 91 --------------------------------------- 3 files changed, 2 insertions(+), 92 deletions(-) delete mode 100644 arch/csky/kernel/io.c diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index 5479707eb5d1..59d4051b2a83 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -48,6 +48,7 @@ config CSKY select DMA_DIRECT_REMAP select IRQ_DOMAIN select DW_APB_TIMER_OF + select GENERIC_IO_COPY select GENERIC_IOREMAP select GENERIC_LIB_ASHLDI3 select GENERIC_LIB_ASHRDI3 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 Tue Sep 10 13:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Vetter X-Patchwork-Id: 13798555 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 26237ECE564 for ; Tue, 10 Sep 2024 13:49:22 +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=ap33tf5qZZ62I8NJEWvBds9aSZQ+d7OzAL26H+fuCc8=; b=xKTBR/evDgCPrMMqwjxDRT/VLN w06g3c5o8LrsiiJH7pi6umv2Hq9hxG+K56Fc8xnZLmORMqY0XQAuge6ZIIikFCvnwu2YG1zuMZBHz Vm1yuI6+MBrC8dnbTUU/e6MoeCwemLwzGBEIP11IQwa/pWspT/CsDBIji9t8XPpJotb0EL2sHHjyE tQlkQy5gnsfyXsadzYGB+AoQmhhYawcCvZnZdhnmCmXNNWbeZEUcwY8BRU/tID01LK+DfAnGGWFb4 0E7P+1IPIfrdzjo7EctTe16zPygbRkocTFcCm/JkEnQ3mFBXHatDb0Cwpys4aw67Xk9zG7c5jHuv9 D+zbX5HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so1F2-00000005lxu-1wxU; Tue, 10 Sep 2024 13:49:12 +0000 Received: from smtpout147.security-mail.net ([85.31.212.147]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so19z-00000005kyF-3q15 for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 13:44:03 +0000 Received: from localhost (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id 01F1C349B96 for ; Tue, 10 Sep 2024 15:43:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kalrayinc.com; s=sec-sig-email; t=1725975838; bh=T5uSHgkmAwvTJQWgMDrPyQnAF/YeHQaaCcpuB+cWki0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mYipa70a2IG7vadNXIKOHlQFKDKLCRjlb2vCtqKvH95p4Lep6L+edmv+XB7cRdEur v1ZMI0mNvxi2IS0CBy0vLfEtDaxBfR2QihsWyRaMRg/3QcHrcWsI4kj/QUaoXDX7K1 TKnX2L+Zflrn+KzTQXGwQ2V/dZCpImmz+YwW11W8= Received: from fx409 (fx409.security-mail.net [127.0.0.1]) by fx409.security-mail.net (Postfix) with ESMTP id AE6C8349BEA; Tue, 10 Sep 2024 15:43:57 +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 9C119349BB0; Tue, 10 Sep 2024 15:43:56 +0200 (CEST) Received: from PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) by PATP264MB5061.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3fe::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Tue, 10 Sep 2024 13:43:55 +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.7939.022; Tue, 10 Sep 2024 13:43:55 +0000 X-Secumail-id: <5c5c.66e04d1c.99f26.0> ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iY/CnXQNA0kpVy5vT6749zsuyxBDqtoPfSmsTETbaoyqWTH6hrDq3aE6EVnbGpWinmQ+gJRPf01acCnBuiyCMj0s5NbidQ04a9urfa/sL0xsAtKjWSBr6F8LDthcp3gN66ivfSPPxFibQLKMPby1/bj3VM2n67E0Is4CfuP8FjLmuvht3m7dby5T7QEIL6vfTpYLLPAtB48hfWLGm1cSEfH2Qpb/MsQFEtlrNZX7dd14g3WuPA/zIkMhZuZVLDjIPlpF1u4OQaoGPEGYHT+g7LGwh0pKW7kzwd+i0Q2KcIWjdiWQEsxFm39tcEA35NR2MDhHsWEBFduOMjSA60abHQ== 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=ap33tf5qZZ62I8NJEWvBds9aSZQ+d7OzAL26H+fuCc8=; b=SQeBuWdrkC9DFvJ54lKTKVHi0x0h16MiPBOZLlyY9xmIuUKymoPjWgcON43tXyr6OczFIWXBoPEntSqqza8zbTly6OApRi6L+L4N6bZ3m5qUdc3jQhdyI8/BXRzeIINljlrRLWOYszbz8XSWqFzHqq5yAQunUkX0vtzAMqJPpEVIMilg9wdilVwxnYoQQH7c6YLcq4H5juUv4LC987E3RfKAMhT5krpb6oYJ7ZWjzKKugX6Ho/nfBlaXHPtPRF3rSrhSY6IjNfJT/7f/3b5lnyG5GhKEGU19hss9VoPyO/JKS4RMz/nR84ucn3QVXKQXr9Xlg9offQHezo5xeASJbQ== 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=ap33tf5qZZ62I8NJEWvBds9aSZQ+d7OzAL26H+fuCc8=; b=WhXoSmv2oINjv1nlmLY2xHkDhEJc4Bg3KE0QdGmwiHO4uu4nq6wwAJ8uOLOq+FmTsFpS7+HoMQjzK/LoUNWwdpwWz7LsHysmf1xP6v4dIkQDKdT29rx7rlabNDyuZkjDw/HuyIACqpCnXYIkKIFx6TxbWChzRPs8MahRSf/KpHj5Dqb9vjdjC0iagsp86x3hM6VwwIImVhdtxJx6IpJ5CPknjPKxfaX8qp3cv4Y0MEezCkFcn0/pFR3CZmG//S42teJHOAhs+Ab76JIxuNuAz04hus5op4hNw386QLh40FJQjNq8q85yCkYk5qPBXC/FvSFh5OuHeGYUQfmcPNixBg== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, Yann Sionneau , Julian Vetter Subject: [PATCH v3 4/4] Use generic io memcpy functions on the loongarch architecture Date: Tue, 10 Sep 2024 15:43:41 +0200 Message-ID: <20240910134341.2537407-5-jvetter@kalrayinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910134341.2537407-1-jvetter@kalrayinc.com> References: <20240910134341.2537407-1-jvetter@kalrayinc.com> X-ClientProxiedBy: PA7P264CA0210.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:36d::16) To PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:118::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAYP264MB3766:EE_|PATP264MB5061:EE_ X-MS-Office365-Filtering-Correlation-Id: 7155bc29-7126-4898-eb1d-08dcd19e9d8c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: hQwnpjhyaATbiDwk6byBbcRdFjG9Yvnhy38N1jyDF79hArHRJw8FsAVpLoxBZu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yuOQozy4ORSOvsFzRt2/LClR+qHObUrFRDppAVknRvBS7M6v5zPddVpzbCVtM1Cwg+AE214/THMA0BTsfge3LkTPkrJ9OdrAuHa4AYA1Kam3KSoTcee4Un1NHFtJSkQWSPF3yNajM+zX0Jjm2RdH3be7hU5HrxjhLbCjbaZbJNvNykSQ6/isgMDj3UYC1nBe4F7MPe4B6AKys2EoCHY+rAEdu1GLaE5k80cylF/AygCo9idtjNc7mtSG+t8935rqY6yIawPX7TEcNcFOsgkgMhNMoYffZHoWLeIMwyVQORxFA== 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)(376014)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0VmsLK8w71wwbwOnKlMddst1O7DVYK7CKLX5OUYNH5FVnXApmGzTeseWMdSV9JknylRQcZVh8TqOBjsEID8CtCBPZo93CxHPe8zQGe+S3xIx/namFoDZn1Rmd9rCRcRkwa5CMy3AJYY+M/hPuObYdj2vwF+L0Ns23y0815I84zUxOht4ouHIuX+wj1wWrzaexw84zLJ+R3WnlGS2i6s3bwuOFg+mtENVrJhE393FSlP4VKkva917mFZ5wAA3bKskowgycX6fphXNX6UM/C7HUSyySGJDjqRpLmF+KsbTBpP+JnSHDaqTc0F5t21UvBnD16BbxtQbtxkFjhvuP6yTS1VIvPHYuuA2M/UiBYs77LzY6eMT005qIjcb1vFOBNrZ9+o+VuSURF18dMhBK2SdgybroIGN1/rM3WlQcue67cNCL4/D4m6RhHim37HHeT+vVc7aBXGlZ9XlFNU6Oj61VWiOeCSrp+Ot2Zvx04qokHmnxe79Y/LyvegOf39yTtqfaJnRy8r+6MXsegqA7RI1i9rUOdFW6RvSBjmJ1Me85zEz2gQ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kalrayinc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7155bc29-7126-4898-eb1d-08dcd19e9d8c X-MS-Exchange-CrossTenant-AuthSource: PAYP264MB3766.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 13:43:55.8831 (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: AEIcIPomU1qQgrUzFKoBYbgKNPSvfgOM7X/Z7zq5gQ/dXR7ojOMr8wHRuq6K7s9Kn7HAjsNb4gTCrRsnV7j/Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PATP264MB5061 X-ALTERMIMEV2_out: done X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_064400_243606_B2F53AE8 X-CRM114-Status: GOOD ( 14.25 ) 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 --- arch/loongarch/Kconfig | 1 + arch/loongarch/kernel/Makefile | 2 +- arch/loongarch/kernel/io.c | 94 ---------------------------------- 3 files changed, 2 insertions(+), 95 deletions(-) delete mode 100644 arch/loongarch/kernel/io.c diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 70f169210b52..bc97b09efd16 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -84,6 +84,7 @@ config LOONGARCH select GENERIC_CPU_DEVICES select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY + select GENERIC_IO_COPY select GENERIC_IOREMAP if !ARCH_IOREMAP select GENERIC_IRQ_MULTI_HANDLER select GENERIC_IRQ_PROBE 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);