From patchwork Wed Feb 21 01:17:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13564833 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 E82FDC48BC3 for ; Wed, 21 Feb 2024 01:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=kpjTJxb1e4Vt7B5bzeWcEPkf4MuQKk029WSqxJd7z84=; b=3kKyg1MUa4mWXA YYfG0jOkor1HMVrw3jseCsTttZSO8SPCHU0KoR0yVtypqSQl64nuSet9CW8t74/QsxAv8fI8cV9Bv 53Btp9i7BEIPKsXx8n9yb20kw+UBx6u5zBwbpOtBweIShLEl/QOxfpp/SslXqkRGBqZCSPoeJxRFM 2iPvzr+x2PvAk8VcEVXueieGxcEP6n1ezJlj+tmL2hPWXLasgdIIzZQD+Ry5Tizh3f6i8/cxVg2Vd dMbikO+TQTwMLzNJfcsGsjhnRQSgkgZeh0RY2kx6+k0GLtwdhX4X5EftsHMhH6pRXidxjXIJuayx8 qwQuAS5299XwYLMPfvsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcbF4-0000000GiqZ-3EGK; Wed, 21 Feb 2024 01:17:46 +0000 Received: from mail-mw2nam10on20601.outbound.protection.outlook.com ([2a01:111:f403:2412::601] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcbEn-0000000GidV-1VkN for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2024 01:17:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Au17HivPtKgwTUwsIsVe4w8acB/YnaJca9l6bdKojKgPnF0o5wZ4l2LNTLQKkcw7WOdnLtlRV6VZ9IfraVzuLtp3NlxN44kZVCgwJHZt0Ze0HmygRF0O9UI4QP7EjiZHKKTnJbZcN3ZFL6r2rhjmT6BdSyc8bEsG7JfNElL9MsIs3D6SdSLWx9Bo5WrWsW2DxNPEjqk+t+QsHo0Dt1s0sSyLAV7LkLpqnYW3bMjjj7bssffUQfJWaPAuEw8Lt5IeP2zbz25Zdr4PJFRMecntAhpUUzX7kF5ymyUbE7Fdo9+4I35i02tmaGwk3vd/yTkoSwZ9zm14y8Cx6IdVZ4k7UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mW7ie0e+X6dYg50MFn//UM2JmFfloVFyb957RHrxNqs=; b=UlS0uZydyrkl7NrkdT2M+kG0FODgi8Sup073BddrRw00eMMSynlPplpzMeW3vDQiIaaPpV9z27Ki4yubxYbpgPa8wZioYh4OTbNELyV2AtOffB5fug90xrZzir4wAUUDGA0CwsO8yx51E4EOyMwYb+BCmGeHh1mTPFPsBZmTOYD5+qfg+8mhrhhmYSTAFr33co28VNnaofRvlwhyAtzQrasq9atpo4otRP/ZssRsTbgh71pE6Msrm2HX9iK+Fuuw8tsZ1ZODbxkeheA3x9PKCoJfisxkiUc9X6WFsKX6bjQ+O7x4JHpUgRFL4cu36+xw9MpIM9qDeP/RLuAFuP/33g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mW7ie0e+X6dYg50MFn//UM2JmFfloVFyb957RHrxNqs=; b=jmS9LIEfF1yLbZ2MGkg5tNLrblHgHHUbR9Xs/1wUITnOWgN9OiKW1ZAhC409weS4TGkB+Wfj0yCejuLi6L0ZQuvNCo3nm43msTr3xVuHYOFnSd3zs+rVdEYwQl3sC8JNDfsQtrmL2q5UnAgeuR8q5jLiGutW62RaroHM2votXhbwoAKvGnhkcCXjK/Xo1nbM96MpwinwJDwNlDxOORwZkfD5aBCsXdhGNHHdBycW09xVwZtx6F2K3zPie0hfpOPT3JXcprWImb4pfLGQ7w86Jr4/aziWoNZ0GT2LFavNh5Ut7RH8Exgwp7ZcEBEwqC2J/tgli2rUB2TMfAfC3z6CEw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by MN0PR12MB5714.namprd12.prod.outlook.com (2603:10b6:208:371::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.19; Wed, 21 Feb 2024 01:17:14 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::96dd:1160:6472:9873%6]) with mapi id 15.20.7316.018; Wed, 21 Feb 2024 01:17:14 +0000 From: Jason Gunthorpe To: Alexander Gordeev , Andrew Morton , Christian Borntraeger , Borislav Petkov , Dave Hansen , "David S. Miller" , Eric Dumazet , Gerald Schaefer , Vasily Gorbik , Heiko Carstens , "H. Peter Anvin" , Justin Stitt , Jakub Kicinski , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, llvm@lists.linux.dev, Ingo Molnar , Bill Wendling , Nathan Chancellor , Nick Desaulniers , netdev@vger.kernel.org, Paolo Abeni , Salil Mehta , Jijie Shao , Sven Schnelle , Thomas Gleixner , x86@kernel.org, Yisen Zhuang Cc: Arnd Bergmann , Catalin Marinas , Leon Romanovsky , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mark Rutland , Michael Guralnik , patches@lists.linux.dev, Niklas Schnelle , Will Deacon Subject: [PATCH 0/6] Fix mlx5 write combining support on new ARM64 cores Date: Tue, 20 Feb 2024 21:17:04 -0400 Message-ID: <0-v1-38290193eace+5-mlx5_arm_wc_jgg@nvidia.com> X-ClientProxiedBy: BL1P223CA0006.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::11) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN0PR12MB5714:EE_ X-MS-Office365-Filtering-Correlation-Id: bc1cb82c-6cf2-45eb-b721-08dc327ad4f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mjzQ4IR33Aude1JpvBAEco7oIX0GN+ux2Sb3IvDNnJ5ttnC95n0+XpbQ+nso4xAtMhwVuwF5Mmp+yvgi5s19PmGG1eyNf3GsFzVURHyWuE0jiDpBGgvEpHD8fV2ySJvnjKv1ovtlOCF/Z76R0I3F0Qrso+36UdxPnlKo0f9KrNXq24ZTMZFMSco98piUOoUPlNtgx0hTOCcEDhPZX0/mf8wbG+PxyK+/jiDHWgtIOyWlCu1+Kyzpwh/lhSvgJQAuQ6sRBh0iEBBQT8XZRI5kVQCBBDUeos39R/lZFLXtv5zWe8mtL2acdO+4bLSINa0vHngaOlTKUcJBk1BlAr4yBSMR0PzwWI1iVY0yUkY1kRPTog5pX560523TisnBVjbyAB+YwSS1m0bl23Xm0v4u6U1e6URYQkgQjbftyzRkMi/2eAPl2E+j7kV3TQMYpxu5is0jG5RafIMyxWHeeY1YfBM3qCLXjDbRutjS/TloBG9N88FtnxyRijIjtrLsaaoBH743Ko0ttwhNJRzPxgMnWDvHC6BlR3l091b6L9B0DYe+Kww4bO636lgQ3Pi601ADMBxblA5EfL7VRhRuNFn73I2FnONg2AlFSJJ3GxE9HgURlvituQF9rYn2KhNguzB2jPh3erhgdijac3f+iEARhw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mySvtt5aiSypU+XvFca+es8y6V5upmdpaiDMpHgApiTVpldIPRG45s4a9/uGWlF6ExFkNEg75xPJlzG3nauYIiGGP5it1y4V7SaaCqmK6wgMJnnGhCo+MtnitQAJjxRw7NLwkeY1iuicL3EYTYcmmfQVFjalYx3z/QCn9XBB7UBosjNJ1+vVHH4gGx4+LsaHtPB+MD3P4I8/h9rPNF0Jr9jvtb1GamOVGdeYobaDXDqZB9iwQOdMOqd3z08jepAg6zs/HJoqXg7nReBXPfdrAoNkOW7E+Mom4nflEwGqTOhJNlB8J7zryzs2N5cXN1BsPLOy0bAs/kjNey1T6C8HDsIppzlMwr+J/CGjTrpx8vX4hxcH8vE3Io5YPBWmqNwl70pq1ZqT8/BoUuNJS3Aexmrc0vRpz+JeEdOOD28VJ1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u7Xx9YIf0c1WDAAo4g6yVVOWiP6MHSw7shhtulg1Nww7/nUH8OlhowgESgyrUmnMfvMJjSlbakoclB/fAgi3ueb84p X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc1cb82c-6cf2-45eb-b721-08dc327ad4f7 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2024 01:17:12.1349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lZm+1tAjwY54wFxKXYiS6iZn4stQtGF7V8WW8nnqoo6vipvYFAiQ/b1Gb72blQZP X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5714 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_171729_482571_AED3BD52 X-CRM114-Status: GOOD ( 16.53 ) 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 mlx5 has a built in self-test at driver startup to evaluate if the platform supports write combining to generate a 64 byte PCIe TLP or not. This has proven necessary because a lot of common scenarios end up with broken write combining (especially inside virtual machines) and there is no other way to learn this information. This self test has been consistently failing on new ARM64 CPU designs (specifically with NVIDIA Grace's implementation of Neoverse V2). The C loop around writeq() generates some pretty terrible ARM64 assembly, but historically this has worked on alot of existing ARM64 CPUs till now. We see it succeed about 1 time in 10,000 on the worst affected systems. The CPU architects speculate that the load instructions interspersed with the stores make the test unreliable. Arrange things so that the ARM64 uses a predictable inline assembly block of 8 STR instructions. Catalin suggested implementing this in terms of the obscure __iowrite64_copy() interface which was long ago added to optimize write combining stores on Pathscale RDMA HW for x86. These copy routines have the advantage of requiring the caller to supply alignment which allows an optimal assembly implementation. This is a good suggestion because it turns out that S390 has much the same problem and already uses the __iowrite64_copy() to try to make its WC operations work. The first several patches modernize and improve the performance of __iowriteXX_copy() so that an ARM64 implementation can be provided which relies on __builtin_constant_p to generate fast inlined assembly code in a few common cases. It should come after the S390 fix: https://lore.kernel.org/r/0-v1-9b1ea6869554+110c60-iommufd_ck_data_type_jgg@nvidia.com With acks, I'd like to take this through the RDMA tree. v2: - Rework everything to use __iowrite64_copy(). - Don't use STP since that is not reliably supported in ARM VMs - New patches to tidy up __iowriteXX_copy() on x86 and s390 v1: https://lore.kernel.org/r/cover.1700766072.git.leon@kernel.org Jason Gunthorpe (6): x86: Stop using weak symbols for __iowrite32_copy() s390: Implement __iowrite32_copy() s390: Stop using weak symbols for __iowrite64_copy() arm64/io: Provide a WC friendly __iowriteXX_copy() net: hns3: Remove io_stop_wc() calls after __iowrite64_copy() IB/mlx5: Use __iowrite64_copy() for write combining stores arch/arm64/include/asm/io.h | 132 ++++++++++++++++++ arch/arm64/kernel/io.c | 42 ++++++ arch/s390/include/asm/io.h | 15 ++ arch/s390/pci/pci.c | 6 - arch/x86/include/asm/io.h | 17 +++ arch/x86/lib/Makefile | 1 - arch/x86/lib/iomap_copy_64.S | 15 -- drivers/infiniband/hw/mlx5/mem.c | 8 +- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 4 - include/linux/io.h | 8 +- lib/iomap_copy.c | 13 +- 11 files changed, 222 insertions(+), 39 deletions(-) delete mode 100644 arch/x86/lib/iomap_copy_64.S base-commit: 3856559a378586366dc602f93febe1c57cdc366c