Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp826941rba; Wed, 27 Mar 2024 13:02:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJHxxX0o0D7Zsvf42gcDJfcIS9ezyCW7UenKff5sD43cBQzlq/yHqhPAfdP8q3h0IH9ErBf+vjrii5dKaDLJ9+BX7gNzsBO517r0LepQ== X-Google-Smtp-Source: AGHT+IGNJ74dYZbjS06AM+50iLF808CQ5PsefWFlfb95uDl/V0DkGgGzx1GHV7BFPuU4Qh908kNK X-Received: by 2002:a05:6a00:929d:b0:6e7:48e3:7895 with SMTP id jw29-20020a056a00929d00b006e748e37895mr385236pfb.2.1711569730663; Wed, 27 Mar 2024 13:02:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711569730; cv=pass; d=google.com; s=arc-20160816; b=KPGnk7u/gVgCtHzV8P4w9qZbRzDr/v0qSZpM+2AvfDZbskb8PrNlcAI7qMwG1cF6dn PKU9nzwMWpDJlFPYs/krS2RVa0i2YpAL5J4yxf7HrU4Iwayehpoq2woJFsz95fa6mNZV tZqsPlRnYCqZxqcWsSgvocypr4ps5R6kJOrEFJWUaxiX5iuPUQEVQEEtS0EG7SIu4iY3 1nbmIORmEjdx8Grk1y3gPDwiqDRKXMXTe+E9Zs1kjDHNKFfa2hHwK483Mzg9eAc6JjnV RMatl0IEZZJkIn8E/xNRz3GW7+2LSgKAltBWeKFdkvW7G11sqr9am4xbnaasOE37qVQX JDTg== ARC-Message-Signature: i=2; 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=IfyGhgpaDuL/FUm+Bqequ3n7X/gQ/Scu0/x5tn5zB10=; fh=hZLm+Y2X+kBS33GoOXsFSdLabaTFAQEECIXS8sYI58E=; b=M6tDnUHNrvSsMAuGOwgUL3cVT7myT+xOOoeo+gyYfRMeNk0MietzgRUB0mcETg7A8B JsGLHgm7pAMl3t01YFauuyaz4NAoIj9SNnChm3cIXdVlJfGGufL4DP/AfVZwEJeNVOvR KgdrnM0Ds7MB+369r99wjc8y6uWaj6VvqZL/YThvk2qNA/9bhXXci/drIk2/n7wRoxau QEB2M2aMqn5x+w/k9LZWYPdwyowlWjaaPpKz/h/3X8WxqsQlYGGRxJPb51h+gmS+10Jl 0hzy06Brf8zoNw0aojqF9XMUE+PKc/q8j/g/zd5rrfTfkRiRaHLHQ2s22fkCq5kURsvu 1NAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=WizOzDa9; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fe24-20020a056a002f1800b006e5725cd47esi9809301pfb.266.2024.03.27.13.02.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=WizOzDa9; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121933-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 57DD02A35CA for ; Wed, 27 Mar 2024 20:02:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBFAE14F9E6; Wed, 27 Mar 2024 20:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="WizOzDa9" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 C2001152519 for ; Wed, 27 Mar 2024 20:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569721; cv=none; b=peIwABQaF773z/TmFh/7Gyn6CPb4QewA/GyqKcxW+XnmRk9JHSCw7M0SI6kS/ERxIfEMmRUPcwDH9PX/DjP7fVN8xaG4jbrjAtc8ABp+corOZ55evXxQ+3jmUqjSYqkqb+6tnPj8sBaAh7uKxaeHzMRA7Esu2TTWD0zcIKk4Ygc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569721; c=relaxed/simple; bh=MzwBpy2FuowxhCGi0F1on+TpS6xpOXjA8uce1NQoqH8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QAQp64TbX64kduI/dvyDYJaNGFlUGruou1uTo/VdVjcqs09z9AE7YFbW/x/gE9/I/HxncIMNgLe2zZEzjFzJTTglJUN+P0dwXQoEBAkepJ0cJj8yUOVgy+yEd/6+lNB5lO18TdJKCozSHsVUtF4KDPkvJYA5lclMZikxv2xO1UA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=WizOzDa9; arc=none smtp.client-ip=209.85.214.173 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-pl1-f173.google.com with SMTP id d9443c01a7336-1dddbe47ac1so8985975ad.1 for ; Wed, 27 Mar 2024 13:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569719; x=1712174519; 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=IfyGhgpaDuL/FUm+Bqequ3n7X/gQ/Scu0/x5tn5zB10=; b=WizOzDa9JjhTEYikaMo4F8SCFZQ9c2Wmz8LDwWF8Z7VEfyLONs5YYi0/W9/JQQRUi9 7hoiP5RIhsTLS8xv/yQxHbnZ6InbCAa8RRFjvJnryxwByU9seqoNxKECv/MMndvZHrrg 0KfafrjHArMGjG6ySWDA7H80dfOY7VycCyZoBFeNjPTSvvkiGnFkJxu1sdKq/D0ETiM5 yp+HmHj7RjiIATWazr9YGiEpRVdxsEgXAyU8JnBWbpws9+ydUFkcP+Am7gIZJ9w7HvBy qg856e7fk99N2e5CtTIjl/hHL9Q/Pa7ciSc6yEwh3ZCKAcKt8ECCVlODeMCY65IEYp61 tVtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569719; x=1712174519; 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=IfyGhgpaDuL/FUm+Bqequ3n7X/gQ/Scu0/x5tn5zB10=; b=Dcdlvjjeiln8GxOwayg/egX18xHF79TJFpFj+Y4FURX1Q8hZ/6pakbe3+z0F6Q7Flu jL/wCQ80w1EkIij9okqLNlmqOTTYWjNDS/4ggCF1yBVhDJDmDpyWW6yupdgPMcfgYBO3 2WhVjPnZUF1CejK6M58/A9A9iD5ZWiMcKz9OKL9k40ezT0rM+j86hMZxpgHd/JRaxdMq hsgMwwJkELFNXyHEE0acJpRtr1hAHUSymzegfiXRbLtCuZcv6gXhuIryDC4j0mJo36eP dkWOVrlqFb1hjKNRr0nGyM4jRpeTKrzrmMIqax0arLH9rsxWodmDBsHo7Sz7L+eFgYBL UiPg== X-Gm-Message-State: AOJu0YzcFcjcmcc5AO6dC0nE+I/g7FeDQCu1Jdlv7y3FYweRfMyCKZvY KREyVZ8UmdRtSSR0iveGyGZ4Jrq6t+HCWn8dJg3qWOwb7ktQ4LTX/ejIpHGO8fM= X-Received: by 2002:a17:902:d2cc:b0:1e0:e011:e3cb with SMTP id n12-20020a170902d2cc00b001e0e011e3cbmr442983plc.15.1711569718923; Wed, 27 Mar 2024 13:01:58 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001dd0d0d26a4sm9446459plf.147.2024.03.27.13.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:01:58 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland , Borislav Petkov , Catalin Marinas , Dave Hansen , Huacai Chen , Ingo Molnar , Jonathan Corbet , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Russell King , Thomas Gleixner , Will Deacon , linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH v3 00/14] Unified cross-architecture kernel-mode FPU API Date: Wed, 27 Mar 2024 13:00:31 -0700 Message-ID: <20240327200157.1097089-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: v2: https://lore.kernel.org/linux-kernel/20231228014220.3562640-1-samuel.holland@sifive.com/ 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 v3: - Rebase on v6.9-rc1 - Limit ARCH_HAS_KERNEL_FPU_SUPPORT to 64BIT 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 -- 2.43.1