Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2139396rdb; Thu, 7 Dec 2023 21:56:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBHT4zc5Ng75tx1ZtEVL+vTPnYxQ8hRa1D4xR0tpmbw32jDKaov4vTxwOQ3UDqiWgsYryy X-Received: by 2002:a05:6a00:4b4c:b0:6ce:2731:e872 with SMTP id kr12-20020a056a004b4c00b006ce2731e872mr956631pfb.57.1702015008315; Thu, 07 Dec 2023 21:56:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702015008; cv=none; d=google.com; s=arc-20160816; b=X5I2WawlV39seGvmqKo7GxECmQT4N1wiMl3BxCEX551HnYk4XJtD78SXFzJU5Oauc/ lKlH/LYvR9Mhf34ZR+4kYRHaKGJYwaLIg33Dh8b5p11jEmRJS9vbx6kcp/8Hlu2mpdRu fyKTBglt/jyNJejvVy3KsXibiUypA4E4Dw3iyHKfH95jh9kp752PwqkJIF4uVSK1/xSP ioPysyPIYiY6H+7HUYkgywGn8tRSbaztSWrbKV3W0eVDHX25ylLHFanNeSUmcHg7wMhA T+3J0712fU1qoAdQb+JPUrgGR6d09IMMelg3JgZtOjAEMdVkNoAvYwoc/Cm0xtQhIMJ8 xo2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+YzUuPYE3yay4aPXmYR/ZrTN/zes857jj0i/rwk/8vA=; fh=GWiN7/yH5ZaeB7dNf34H6takS9oI70VVB29etA3Fg9Y=; b=ggqwYK0Cciw6EwFC5P96XPOMMjuecOo5xlKC/OVfa1hpvt/LQMXyJgevxoPeIUpaZZ fPlEkuslInj7bEwN38jlUFPjv+enu3wTxUFP3Qm6Ww3xBUL/dT9iaP3Dy6kLmJOG0MRj brFdzyEEEJ4Ipqk2i5e62ln+Q8PYWhfgySMTCr603PW0wq5n2b8rLxILdSGyWtLmeqhE 596Jrh6vQw5xAYqPXLVCm3y9/1Vi1rLMS50kcUPqjSRLn6ihaIXsdHIzOLzl+rkk40eJ BJTRAq49f0IEZz7TilUAONh0d30HCCCk2YXqQ4fa9178W4lu2qnaBlJDnPXhzrsINUnu XjEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ClLCf4su; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id t33-20020a056a0013a100b006cd8cabde34si982916pfg.71.2023.12.07.21.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:56:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ClLCf4su; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B52E3807F49A; Thu, 7 Dec 2023 21:56:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573221AbjLHFza (ORCPT + 99 others); Fri, 8 Dec 2023 00:55:30 -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-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: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 07 Dec 2023 21:56:09 -0800 (PST) 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 --- 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) += $(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 */ -- 2.42.0