From nobody Wed Dec 17 00:17:05 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24EFCC4167B for ; Fri, 8 Dec 2023 05:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235691AbjLHFzc (ORCPT ); Fri, 8 Dec 2023 00:55:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573214AbjLHFzH (ORCPT ); Fri, 8 Dec 2023 00:55:07 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A1F6172B for ; Thu, 7 Dec 2023 21:55:12 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d1e1edb10bso15914445ad.1 for ; Thu, 07 Dec 2023 21:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014911; x=1702619711; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+YzUuPYE3yay4aPXmYR/ZrTN/zes857jj0i/rwk/8vA=; b=ClLCf4su0PKdb4xo2DCgzN7OPZ/jCdFfYL2JYL4cczmN8iiVIYfqukunn/jWFHgJVj 8ZssbDJU3zeoPJwKYRF6VMXGPytdIKHHDWyoZ0onOc1RPR1P7ZndXabIrj/18dY2wgg3 6zMEnS0EYWqHB7ZMxkzcMCezCHSqlrggcfJYvI3kTeOYPCXhIG9QlKJ7NN93eHAarjVA nNiNPfR7Pq2AYwVwz3hv7gCX5ULjeUYMMCBxCnISB9rzrHG7eJdiSae8QjgcdUy/TdYw QnEXbii0pc09s6T1nsnpZw+j9kRqRdfO8tbFAM0JPAGLi/LIwPDZQ0qdCtvNGHStLmB7 K2+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014911; x=1702619711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+YzUuPYE3yay4aPXmYR/ZrTN/zes857jj0i/rwk/8vA=; b=bVhzMBIDlCwmjSdGmzYjMe8HlEkxzy09vi+byHrEDh1waglBmq+4lDz95IXuez+18V nfZv6RGuM2C6M7m9e34LjiSN+paGoxfSZhWyXzTI/gBvI8ajQKiKHHSsdKItwfMi61SN 9h3Cx9A9hZ8ba3ymnm8FfVm+gE2n45Sc4Wi3zK3tHT4d5DBMSR+IbsRTxRVnDwuHGRKk creeYuqo/Rftd8CdeEWgVgCuo7hTJEmzbrSGM8J+bDg0Vlp9Ysx1v8Kz8XpqY9SXCBQ3 /STr66+FqfkdBOkmyDt1yl21piRwoqoXfuES9u7gBhYrVFolsLy9WAzuHOFUKXgnRczN Wpcw== X-Gm-Message-State: AOJu0YzM3fKM9ueEgh2T8/36CHpujuc1tPuwgk032446jXTY/MxeOlHH rQgIzdf8HJTmRfy/9psCg3xr+Q== X-Google-Smtp-Source: AGHT+IGkpKPNTZyORkUclzuJiqEGnd764SXTk1kHONQX0GukAsvi/MYXEyo8qWiBUacvBaveWOlV4w== X-Received: by 2002:a17:902:7e82:b0:1d0:b9f4:800f with SMTP id z2-20020a1709027e8200b001d0b9f4800fmr3698333pla.109.1702014911528; Thu, 07 Dec 2023 21:55:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:11 -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 07/12] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:37 -0800 Message-ID: <20231208055501.2916202-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208055501.2916202-1-samuel.holland@sifive.com> References: <20231208055501.2916202-1-samuel.holland@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" PowerPC provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. The PowerPC API also requires a non-preemptible context. Add a wrapper header, and export the CFLAGS adjustments. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 5 ++++- arch/powerpc/include/asm/fpu.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/fpu.h diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 6f105ee4f3cf..e96cb5b7c571 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -137,6 +137,7 @@ config PPC select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_HUGEPD if HUGETLB_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index f19dbaa1d541..2d5f21baf6ff 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -142,6 +142,9 @@ CFLAGS-$(CONFIG_PPC32) +=3D $(call cc-option, $(MULTIPL= EWORD)) =20 CFLAGS-$(CONFIG_PPC32) +=3D $(call cc-option,-mno-readonly-in-sdata) =20 +CC_FLAGS_FPU :=3D $(call cc-option,-mhard-float) +CC_FLAGS_NO_FPU +=3D $(call cc-option,-msoft-float) + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY KBUILD_CPPFLAGS +=3D -DCC_USING_PATCHABLE_FUNCTION_ENTRY @@ -163,7 +166,7 @@ asinstr :=3D $(call as-instr,lis 9$(comma)foo@high,-DHA= VE_AS_ATHIGH=3D1) =20 KBUILD_CPPFLAGS +=3D -I $(srctree)/arch/$(ARCH) $(asinstr) KBUILD_AFLAGS +=3D $(AFLAGS-y) -KBUILD_CFLAGS +=3D $(call cc-option,-msoft-float) +KBUILD_CFLAGS +=3D $(CC_FLAGS_NO_FPU) KBUILD_CFLAGS +=3D $(CFLAGS-y) CPP =3D $(CC) -E $(KBUILD_CFLAGS) =20 diff --git a/arch/powerpc/include/asm/fpu.h b/arch/powerpc/include/asm/fpu.h new file mode 100644 index 000000000000..ca584e4bc40f --- /dev/null +++ b/arch/powerpc/include/asm/fpu.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_POWERPC_FPU_H +#define _ASM_POWERPC_FPU_H + +#include + +#include +#include + +#define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) + +static inline void kernel_fpu_begin(void) +{ + preempt_disable(); + enable_kernel_fp(); +} + +static inline void kernel_fpu_end(void) +{ + disable_kernel_fp(); + preempt_enable(); +} + +#endif /* ! _ASM_POWERPC_FPU_H */ --=20 2.42.0