From patchwork Fri Dec 8 05:54:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484857 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 00C63C4167B for ; Fri, 8 Dec 2023 05:55:38 +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=BfvTvRAm2MUc3DYjA9CvTb1kK4RcIdBPmCKOjbreSpI=; b=J6Gysv5i8wqBS6 kBIeuvfBS85/gZvwJ0GPsLOnqEv9W83YVliSJjlv35YVsu0KPdIZM3LHQ16oWmvMKcVbvWRPBfngY vSPhxerD6DAs8N0qr5wN4Mad5ErCeyCt03NpxY34AU/v1xj9yCqj2R8WVrUzY0B/8C6wsIZp12FoY 7qUzyyL92/ovPN6PbTpjx+XtjVoBbjAHxQ3zZ6sFbiLvO3TvOw4R13AwHW1YAvkvaYHeCrnuJQG+f BPtpK3gKBoBoKG1Om0XmbjDvCTH7xAOeDoFWbQu5WXvOhEzkkH22pR2mKSei7psb6DAwh7PGT9zZE 8iKDz/STrVNyxbTLmtpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpP-00EnU7-24; Fri, 08 Dec 2023 05:55:11 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpJ-00EnNH-0E for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:08 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1cfabcbda7bso21575445ad.0 for ; Thu, 07 Dec 2023 21:55:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014903; x=1702619703; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jIC4glHzB+IOAGM7YCu4gQFdGXeLpWj/I7OZVSGOh7k=; b=dctx+L6xOCYkO4f4zF2odE+2TYqRp+19eu/qQLjXXdCchQVEimIcOwA1NR8bmXZWNb 9Jy2pwR/RJIv5zgayJHFBTnhy/RNzyU40aV31eiVFVEq936D+kGn1VqKUIGUKAQpPbhr t5f75zFC8RDKkbFq+jLEhAUUprSa/uCS4fHaJqHZWRqjvUidma2QEwQ3Mu4MpQndWogP ViOaGFfA8PZ4k6kgNJ2CANJcu3YjwuzytltFmCPTgZGbyVkUJzirmGIMg737Jj6h8FfJ LkqtGi6Or7jQrndvAd8RcFoRq58WfQDIO9P/yo916egcLFmOQWgS8WaGN4Ls19tKpLaK oS4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014903; x=1702619703; 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=jIC4glHzB+IOAGM7YCu4gQFdGXeLpWj/I7OZVSGOh7k=; b=fpuOlPuEhEHZM+vtR15m633misLLFR2qRsuIZKQBpkV7xvdFKM0cH2xu9NE94IHZGw wT4kJv1O4qj+60k/zCvrEwSawQCRxfhcxKPK+YHL7Jh1W9FKN9RwN4wynQiikmUq0lcH uwKX7NZKpIwPWAWumSLC/OY+TspbM5sWZWX4lcsobym8XRWTl8GdZMp6xIEvZimq6PB4 gZTFZVhmuXVwI+HlTH3wIU/HjB8bDwqW3g0DaugIEsHRdzzdXZag3IaIU+mCjb5WhdvU rhYoyHonh47xQXN039XACqFqKlchWD+TpOyIv+AyGUw/i1VH3W4jViStuIdQYL7ZxrVS 0rZw== X-Gm-Message-State: AOJu0Yzxh0Kf7CGnKxcrObZFlpdRuxs8pFMAdwvLnNe9TGdAhMP2B8I1 5jXqIfjDqxsm081Z30cCto6q2GQ7e7+OOyZOuAj6nbtZErEuFHkeHkyEjcpAClgL1efeBwdV67F IcfzbsrxuVKSJ3PP4V1jY8YxBXt82kVzc4ezqfADqkF9QAApyE/0aXCv0NPzYqU7JuePEd/qA66 s2wrMlT38LZGwo01pXmAi0RgyHPw== X-Google-Smtp-Source: AGHT+IHobgnIbAqUwh0qy5g87XS9Ops6tA3mZ0Tbbi2vny+WXvVENlMrplaMBh4oGzh2rC3HGh0NRQ== X-Received: by 2002:a17:902:c20c:b0:1d0:6ffd:610c with SMTP id 12-20020a170902c20c00b001d06ffd610cmr481032pll.46.1702014902890; Thu, 07 Dec 2023 21:55:02 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id s22-20020a170902989600b001ce5b859a59sm786250plp.305.2023.12.07.21.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:02 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [RFC PATCH 00/12] Unified cross-architecture kernel-mode FPU API Date: Thu, 7 Dec 2023 21:54:30 -0800 Message-ID: <20231208055501.2916202-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_215505_105855_E0758E71 X-CRM114-Status: GOOD ( 13.09 ) 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 This series supersedes my earier RISC-V specific series[1]. 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. [1]: https://lore.kernel.org/linux-riscv/20231122030621.3759313-1-samuel.holland@sifive.com/ Samuel Holland (12): 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 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 Makefile | 4 ++ arch/Kconfig | 9 +++++ arch/arm/Kconfig | 1 + arch/arm/Makefile | 7 ++++ arch/arm/include/asm/fpu.h | 17 +++++++++ arch/arm/lib/Makefile | 3 +- arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++- arch/arm64/include/asm/fpu.h | 17 +++++++++ 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 | 26 +++++++++++++ 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 | 33 +---------------- drivers/gpu/drm/amd/display/dc/dml/Makefile | 36 +----------------- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 36 +----------------- lib/Kconfig.debug | 2 +- lib/Makefile | 26 ++----------- lib/raid6/Makefile | 31 ++++------------ lib/{test_fpu.c => test_fpu_glue.c} | 37 +++---------------- lib/test_fpu_impl.c | 35 ++++++++++++++++++ 32 files changed, 255 insertions(+), 185 deletions(-) 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 rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c