Message ID | 20231228014220.3562640-1-samuel.holland@sifive.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-12367-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758223dyb; Wed, 27 Dec 2023 17:42:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjy1veZSKtxAe4A3gsyN/jlMFOt6LkciXgidNVSUNwsbWBKdWiP0Bd8xT6VjZAxPmoHiwD X-Received: by 2002:a17:906:10c9:b0:a26:c595:62c0 with SMTP id v9-20020a17090610c900b00a26c59562c0mr2240291ejv.47.1703727778433; Wed, 27 Dec 2023 17:42:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727778; cv=none; d=google.com; s=arc-20160816; b=O4i8Kd6Nl575weJyw/Qw3pVbA9AC98zZe4M8gFkjKXUgXMDhhLuwIT6RHlQMxtHZYs bRTjAizWKWGfDO198p4JYQJCUb01Rq3+GVY4DKvN4XK9STHqAzQkz0wnIsbI+OnJ1b3K W3SkIfHbG3rvwDW/2qX+P9V3f1fPzcLF35S0jv9CP74eNT0PT4tgHvW7zBGcJfXJEo0X C+ymI/UZCNLvH3tmZyjjHofbo2ll9/EzeOep3hQbYkD+l/qZeJ02cd7YYv04RKFWzl2J JKnc8N/8nKA9Hz3Gh6H8DV+5z7crWollUmDiVGh/KujshkjnasGJJBzdF3L9eK75ye8g Cfnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=LKYKCC0iAyjtmcl9i3gxZmi/p+HZhZfirGb7twXi050=; fh=94uOV5sWmRw3BrY72TFM31lKigqzeHCm+E+w2ZFcL9E=; b=M/KD2PSPIMCq0MfYA2A7B9hqgE03pH7EMk73CRRUDZrTJEY2TCVEL0OtyrxrhNrPqz 8EgPsX3OgAbi6OKVqUOcgbZicboQ3yRcA581gIQaHz6WPmhHi6xcbieY53xWKH0aVcta csI2DlFAVtRQsZemr2G35NV2CMKxKOL+VPYUSVuEARTbsYPJ5o2AAAALo4ei4NPcyW49 GVK3XJV2C/Cn2NF80Nz4Vnyf7uqn9zIRwQD7h+0dJ26zGoZOisK8vWrNk6dIdNTEGNWb SaIDSQQYlcuzTsAsmvrrBdRKaYBB4QSSMoR4atpV4m0RdFB1yQychm7GLt/82ZpB8JRs mzGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=TyU0wwBE; spf=pass (google.com: domain of linux-kernel+bounces-12367-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12367-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lw17-20020a170906bcd100b00a26f1d9f138si3019125ejb.34.2023.12.27.17.42.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12367-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=TyU0wwBE; spf=pass (google.com: domain of linux-kernel+bounces-12367-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12367-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D18791F211B0 for <ouuuleilei@gmail.com>; Thu, 28 Dec 2023 01:42:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19E442909; Thu, 28 Dec 2023 01:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="TyU0wwBE" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B2B610EF for <linux-kernel@vger.kernel.org>; Thu, 28 Dec 2023 01:42:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6d9f94b9186so1002829b3a.0 for <linux-kernel@vger.kernel.org>; Wed, 27 Dec 2023 17:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727742; x=1704332542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LKYKCC0iAyjtmcl9i3gxZmi/p+HZhZfirGb7twXi050=; b=TyU0wwBEJk10kuzvLRKAnyS/3SvkcZORHlzRCbc5fwcKB6QmEeNMdNQn3j8lsh5aBH 6xunCqHitRqAJP/UPZI5ZmG1fEjxmRVygq9Ur76fdQugnUXlSPfqPfLdb9aZUExVWV3J 3kSAwrJK9AU8zVAns6HcJymsFI+rYEtOYWtMWgB2RMzQqcV+10tuc5AVWtpmMjwoPuBd shB22BF2X6Ti0z5MdjifyZZsKlqtE8Ld/JxrKUXun94Auq4Pm/2zBoxDeeDOxN1SZ1aU 1uLS+Mv73RsrB44zYWH9BcrgPiet4v+ewXvJZCw3HY+ktHY2A3DO6MfNXKMld3vAJZ90 0AIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727742; x=1704332542; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LKYKCC0iAyjtmcl9i3gxZmi/p+HZhZfirGb7twXi050=; b=SbeaH+alpIHd99XIj5elsQuauY6TBwY+sqktkesInhBBmxbcNRBMRI4KKmvRNC3dhK o7g7Mq9Wz0CUO0HZvG86Wy0y3NQxyk5Oih2l7U/GCxorFsy7pITqlV08FAaHrKS2Fj1Y Sr1qIO1m+OQGblpgQ3Z86J2/toCWNvliLdC04xNvjBte/xGZYBXtNFHEa9SA/qGTM+iE 834Q9Le5A84Dbzv4cdYZDX7Li+fSiv+jtps3Cn8JVIJwNa3+9dFmXa3Q/EnSSuUrAGPn 5Bd4cwiUiMvrcRklaEnlpn7yOp/7fzerQ5WcU+WHbmw5MDKjKrM0YWKpaUTJDpWVGdiR rE4Q== X-Gm-Message-State: AOJu0Yy/+aA2RIgDP+vy/xtSfq3Rj3b81k6R4ryQqDscPVlWLGSGrJyA /RDUikdTbpA94Kn4RZRxaesIy0/Ox1Tw9Q== X-Received: by 2002:a05:6a00:1d05:b0:6d9:bfb8:e37c with SMTP id a5-20020a056a001d0500b006d9bfb8e37cmr6112797pfx.41.1703727742547; Wed, 27 Dec 2023 17:42:22 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:22 -0800 (PST) From: Samuel Holland <samuel.holland@sifive.com> To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig <hch@lst.de> Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland <samuel.holland@sifive.com>, Jonathan Corbet <corbet@lwn.net>, linux-doc@vger.kernel.org Subject: [PATCH v2 00/14] Unified cross-architecture kernel-mode FPU API Date: Wed, 27 Dec 2023 17:41:50 -0800 Message-ID: <20231228014220.3562640-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488059241910496 X-GMAIL-MSGID: 1786488059241910496 |
Series |
Unified cross-architecture kernel-mode FPU API
|
|
Message
Samuel Holland
Dec. 28, 2023, 1:41 a.m. UTC
This series unifies the kernel-mode FPU API across several architectures by wrapping the existing functions (where needed) in consistently-named functions placed in a consistent header location, with mostly the same semantics: they can be called from preemptible or non-preemptible task context, and are not assumed to be reentrant. Architectures are also expected to provide CFLAGS adjustments for compiling FPU-dependent code. For the moment, SIMD/vector units are out of scope for this common API. This allows us to remove the ifdeffery and duplicated Makefile logic at each FPU user. It then implements the common API on RISC-V, and converts a couple of users to the new API: the AMDGPU DRM driver, and the FPU self test. The underlying goal of this series is to allow using newer AMD GPUs (e.g. Navi) on RISC-V boards such as SiFive's HiFive Unmatched. Those GPUs need CONFIG_DRM_AMD_DC_FP to initialize, which requires kernel-mode FPU support. Previous versions: v1: https://lore.kernel.org/linux-kernel/20231208055501.2916202-1-samuel.holland@sifive.com/ v0: https://lore.kernel.org/linux-kernel/20231122030621.3759313-1-samuel.holland@sifive.com/ Changes in v2: - Add documentation explaining the built-time and runtime APIs - Add a linux/fpu.h header for generic isolation enforcement - Remove file name from header comment - Clean up arch/arm64/lib/Makefile, like for arch/arm - Remove RISC-V architecture-specific preprocessor check - Split altivec removal to a separate patch - Use linux/fpu.h instead of asm/fpu.h in consumers - Declare test_fpu() in a header Michael Ellerman (1): drm/amd/display: Only use hard-float, not altivec on powerpc Samuel Holland (13): arch: Add ARCH_HAS_KERNEL_FPU_SUPPORT ARM: Implement ARCH_HAS_KERNEL_FPU_SUPPORT ARM: crypto: Use CC_FLAGS_FPU for NEON CFLAGS arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT arm64: crypto: Use CC_FLAGS_FPU for NEON CFLAGS lib/raid6: Use CC_FLAGS_FPU for NEON CFLAGS LoongArch: Implement ARCH_HAS_KERNEL_FPU_SUPPORT powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT x86: Implement ARCH_HAS_KERNEL_FPU_SUPPORT riscv: Add support for kernel-mode FPU drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT selftests/fpu: Move FP code to a separate translation unit selftests/fpu: Allow building on other architectures Documentation/core-api/floating-point.rst | 78 +++++++++++++++++++ Documentation/core-api/index.rst | 1 + Makefile | 5 ++ arch/Kconfig | 6 ++ arch/arm/Kconfig | 1 + arch/arm/Makefile | 7 ++ arch/arm/include/asm/fpu.h | 15 ++++ arch/arm/lib/Makefile | 3 +- arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++- arch/arm64/include/asm/fpu.h | 15 ++++ arch/arm64/lib/Makefile | 6 +- arch/loongarch/Kconfig | 1 + arch/loongarch/Makefile | 5 +- arch/loongarch/include/asm/fpu.h | 1 + arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 5 +- arch/powerpc/include/asm/fpu.h | 28 +++++++ arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 3 + arch/riscv/include/asm/fpu.h | 16 ++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/kernel_mode_fpu.c | 28 +++++++ arch/x86/Kconfig | 1 + arch/x86/Makefile | 20 +++++ arch/x86/include/asm/fpu.h | 13 ++++ drivers/gpu/drm/amd/display/Kconfig | 2 +- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 35 +-------- drivers/gpu/drm/amd/display/dc/dml/Makefile | 36 +-------- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 36 +-------- include/linux/fpu.h | 12 +++ lib/Kconfig.debug | 2 +- lib/Makefile | 26 +------ lib/raid6/Makefile | 31 ++------ lib/test_fpu.h | 8 ++ lib/{test_fpu.c => test_fpu_glue.c} | 37 ++------- lib/test_fpu_impl.c | 37 +++++++++ 37 files changed, 343 insertions(+), 190 deletions(-) create mode 100644 Documentation/core-api/floating-point.rst create mode 100644 arch/arm/include/asm/fpu.h create mode 100644 arch/arm64/include/asm/fpu.h create mode 100644 arch/powerpc/include/asm/fpu.h create mode 100644 arch/riscv/include/asm/fpu.h create mode 100644 arch/riscv/kernel/kernel_mode_fpu.c create mode 100644 arch/x86/include/asm/fpu.h create mode 100644 include/linux/fpu.h create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c