From patchwork Thu Dec 28 01:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13505573 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 81CAFC4706F for ; Thu, 28 Dec 2023 03:45:51 +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:References:In-Reply-To: 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: List-Owner; bh=6OQ8BgfdYXmK1nCAvYCyqj761dFocz3z/+7lYdHenQk=; b=mY33Is1wjH8LoC 51efS7Ioj+1bD5AdF3yYSroQk8Yb4bRC5nLkxJxDRKSpOMV4QUMj6d8kPTbJtv09oBlYy9BIs9x2z 5cRkXf3gJFLs6pfFxeZ8KjZgZ+kK36pDiaW2Cm+q0YmH2U+HER/29OYthllhy25c8r3EdIZGTIbRh 0yCVJfg2T2+i11S13/boGsXOks1zW0ERaxfczzw/dSHdJ8zPkwSlHN5CubfS37RUoGJ+IVIYQwr+4 16jeJOSy+mhxyQ1b82LuE6hF6xiGLag3xlJgEZEcBr5sVluzMgKnRswBqE6wHqRRV0arZjuRRWBTj EJgGForqy/I5DzIeNaqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIhL7-00G3Op-2p; Thu, 28 Dec 2023 03:45:45 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIfQ2-00FryO-2w for linux-arm-kernel@bombadil.infradead.org; Thu, 28 Dec 2023 01:42:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5FK4PuyaVW5o+fowKBsFSathMMiGJoXogQryv4/PrHo=; b=pyXm3w+IYlj/aTCy+BYqxqp1FD vJ0ioXob8li/wLuafXH/UlNGMWU//TsEXXFMHtrGUiBwXXX514ssarhgsqCHSu0VXovVb5NeTWHY6 swXOrDs5yQnxehp2TIYNImlzsXryAraxpI/K6NEBueG3of9OtLmosr8qLSJoT7OeZgTGIp8WMOJVY Pnm+fqjpXCrW2y389P6UMLeRmcGPu83jGXdiuOz3v5xSYgXcNDGMe3zpX8niXDIYfeUpIUxcO8B5K 8fA+zb24966WJT5TM/2QDyxLYkXN0xeZyFnOp+jpB3jLkqMT/iI13f7DkyGXu9SdwWi8DRyhBAF2r plK09VyA==; Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIfPx-000xJ2-0M for linux-arm-kernel@lists.infradead.org; Thu, 28 Dec 2023 01:42:40 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5cd68a0de49so4110569a12.2 for ; Wed, 27 Dec 2023 17:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727753; x=1704332553; darn=lists.infradead.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=5FK4PuyaVW5o+fowKBsFSathMMiGJoXogQryv4/PrHo=; b=KduikWc0CE9NqjD95M1pT9qhiEjiJUrTpHkzZp9ni4F8m93I1LTF5/uzJ4vvRm0tpb sGTl0aYfekiO4Eo/NpJLd7PPcCHIIgyMMuXQWhEUJNkhRs2VCs1J59njo8zcJnrZS18l AmYqzmrZh2uiFa6/Qd8BxD17AvrbiwpBH0ykUDiNXqRE1zlFiycwyt39V89A8CJFyCVx jsARILgpHp0FJQNSN8MiHfPj/SIHg59vX4ErXV/9Grm/ANPAk8nalk4QAWBiaZrcOOy6 c2l9NlcX8Ew0uZOeTLX9v276oA8AJpMqEq5y3xvLL3ZvDv9U81Ri8ZrH+N1N8uf1Rl3e Rtlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727753; x=1704332553; 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=5FK4PuyaVW5o+fowKBsFSathMMiGJoXogQryv4/PrHo=; b=gKYyt+2aLaDl0nLkImV1ZBsiD1Z2qhtCM/p996e8ablHbz0BvBG5eODJsZZMl3vKHT 9uJzisKsT11WqKnQubIcI913KoqXtC2QNgprYrFQgad144+TEiobYjQGeXqwro5dkEOE l0ncxfBUN9k7FgBsXUZJDquO8UlQM8A3pQ09pgS+pv7NFeGzgRqvke2hr1hjr3hvnXAo +cfbjQ4/2sMxNADO0xOlu+1M1w6kW65OZ86F+EPwiJvvECx4shmfqL5sxSXNlZPTvoDp DE8GtycjCQEGpg3MIjk9xA/OVF9/sM+oBUCPh19giLv9SlUHRr2GS/EElTwS/+ej6+jC utlw== X-Gm-Message-State: AOJu0Ywdzawv1RG+hXRrBOh1rXHrGaPzTNZ+gy5Ehm59FKhYrBdf3n5N ywQSTU9qnFymZT0eICrUUa0AWtZj3OwK5b0KhLfriSHrDmefV5EPoGLorLGwjEOKfdQaroHFwj3 HRuP/7h+ywzxmJoOfxiINF0GfAYDIopTrcSLJL1b/n4Zmh0am5DOTf1HF4AnDU2CvRy8aG3hE+q KsjvFX+2gC11vxmCbfgiWp71+57peGQAt9dQ== X-Google-Smtp-Source: AGHT+IGDcwpDNI+ACJS8JwK6slMdt2P3zgEqkBXVCA8XIoKmVvXUWVJm0n6YvZtcZMejj6VORWJ3pQ== X-Received: by 2002:a05:6a21:612:b0:194:f17b:f877 with SMTP id ll18-20020a056a21061200b00194f17bf877mr9226487pzb.61.1703727752746; Wed, 27 Dec 2023 17:42:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:32 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 08/14] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:58 -0800 Message-ID: <20231228014220.3562640-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231228_014238_109945_FCFA2DDD X-CRM114-Status: GOOD ( 14.34 ) 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 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. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) 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..91106970a8c1 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -142,6 +142,9 @@ CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD)) CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) +CC_FLAGS_FPU := $(call cc-option,-mhard-float) +CC_FLAGS_NO_FPU := $(call cc-option,-msoft-float) + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY @@ -163,7 +166,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr) KBUILD_AFLAGS += $(AFLAGS-y) -KBUILD_CFLAGS += $(call cc-option,-msoft-float) +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) KBUILD_CFLAGS += $(CFLAGS-y) CPP = $(CC) -E $(KBUILD_CFLAGS) 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 */