Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp914922lqh; Fri, 29 Mar 2024 00:26:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAPdFCTx4bUi8afvrFDHE5aunrv+BUnCqa3KLmxTWgx/DVixPYxLoO5IuGULRNgYgy9urvgfuGBOw+ZQRySXavtIlnGBxgPm2e4yPAbw== X-Google-Smtp-Source: AGHT+IFXutOxTypkfML7GBXpNZ8CwGJL9uOTJRrycS5kZ/hWbZvpV8yI9dadk/MAfVDTNXMyuT3c X-Received: by 2002:a05:6a20:2587:b0:1a3:dcdf:13cf with SMTP id k7-20020a056a20258700b001a3dcdf13cfmr1429801pzd.56.1711697207292; Fri, 29 Mar 2024 00:26:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711697207; cv=pass; d=google.com; s=arc-20160816; b=boU9w3C9sHJVX9GMHgnjVy/sCiM1AmnVFnDOeYC6q58p5BJuvSslwBMdhQ+VnqQ3ng 1ZSDgeLdOSRBp6qGDDfBlNiRxu2foarUHqH10Iy+C7Yc9Ba5065lm+KweC8Nsw7KFkhn biEjv/8lgSj+Q4YQggsv6KLt1VcmpXeJ1Yfm+vjNF5Wgo3wWST97lhZfpK/l3izpiezw /RGx83e+wfUuoBG08prfT0m1/lnKPyom8Kjf+vMa1VHJCRaFuqdmL3/aVUgi92uzUBuy EzsMAQ55jQPWxo9Tq0r+FjFO6oflphMkAH3avqMtzOnMiRCFYLQQZhjpQOEMJwF3LaPc Lv0Q== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; fh=2sRQR5wCh2D6APuQBJ3gh3iqF+xzIveimN7L5+SYre8=; b=tXtNjJeFiTF1PVJhGVvWGuxYjPqenSFBCx2wkCPa9d3PIfBLTqupIDxCuUC6E56zzz td6k3OTlRRdY1fBzB8eGXuDUWPS67kozHprafYQpK1YyucXn798gZ/662Bn7wzxGqKJr qGBKFm+jtSfHHiZs6jlYGJCU2nS8ap65rvOL/n/oZK5/AawuzLx56ZMLV3pndzWmmpl4 140cOxgTCj6Tw0SNLVgYFEyMavoFdsW50pxBh6nQ/6CTfzuqOSAfaCuaegGW0tpjorVH sYgwttlReXw2bQ+CInA851j5yktK8hoF64Gq9PHKCKov05KJq0w1tI2lDFA/y2P1jeZK 6lQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=W9Nr8Et4; 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-124235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124235-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 w6-20020a170902e88600b001dcfaf5bfefsi3246688plg.573.2024.03.29.00.26.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:26:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124235-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=W9Nr8Et4; 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-124235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124235-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 EAAB0285EDF for ; Fri, 29 Mar 2024 07:26:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C90A9524C0; Fri, 29 Mar 2024 07:25:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="W9Nr8Et4" Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 672684086D for ; Fri, 29 Mar 2024 07:24:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697100; cv=none; b=ByNrCw24gEn/wc18Fn0jta99c64oi0wAT0N+EyErMT9oGsaTFIBoXifZjPdy2WRjmBgdhmmaVDZYUNJa3IBiGpXg8kTh3bShxaiqJCXt4IxgZSpWKefJZ6ABaZBByqOurYSXnumICc17q29Pj4djMhk0DaSuwA37lQcs/bkfxkk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697100; c=relaxed/simple; bh=b0p3yNyhI4gS1UO6/7FtNHSLtx6SD/wV4pT5We/leTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aUF2mW2lv+mKW6f9ylBM3PMYsJfHF8F/j3VmAE2wHDuImZ0Y51LAAcMqWlE0NdnU1OzvbF55wvdHFtA6XW31hX/fxMjXdaM/8FyP4To/h3vwRJgH4gzMf5G4wh6veETLXEVKS2ewOVjlm1fXyisHjPhqc2gTYyUZeNjvmGJF56I= 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=W9Nr8Et4; arc=none smtp.client-ip=209.85.210.169 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-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e6c0098328so1476686b3a.3 for ; Fri, 29 Mar 2024 00:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697099; x=1712301899; 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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=W9Nr8Et4E7CYYgCXsjROXWY+7psvqjEG+P6oATRtBEuCOvOUDiUXpO1oYQKwPh725t FFMzcQYn9hF3EdD2PIEh+Lpv6WzWeoZH7rejTzk9Hm97+xwK5DmfeOJ026lYqV3gwxAV CVkjLMj1RqPjZWsURZfw6K8yNPYMuQqvoTggVfh7YU8wyDkR809xfF/fzZzOW8uWXyrL XEuHlW9dy1xV99rvlZIjjhvAjE+AoxrB3TYYh8INRk8G9CsPU1CnqwGSpayz+d27YYzP u/T5+0tsjqz8Yt0hEsFtpqOdR0epwwhKAshtmgbFVXo2rhO5I1Ldknnj4pVQnP/H/rAe blkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697099; x=1712301899; 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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=UWj6kOIfExkXj65KpLu7ELjzqXA9qaVtxdOUcDRA+8cqzPIv/Mgz/rkF9NWSzlDLHf i3SQ5yUMwowWr9jFXGe9lGr1VJkh98xkayl/qJLyEtEMGYmpf5WDMGJnEy1IwolcY33R JBVO3OMEcbxw4Egmxxk7dslpgfvDgPxpteychoWM1ahEr5x8O5YGT1Oz3KBtEPLpriSz abAEqqcP3cbgmlj/bBocfxjfA7qqLYhKx4UU0pdy/i6zuwIbcHgA0lVlSgkCTXv2ipNX Hfw3ep5HVifpQlPfHJBk0oII4D95P/vwMfo/S6vd6PGrPRI8QhWP2dHo/AHpUzEPsf+b ftHA== X-Gm-Message-State: AOJu0Yy0gE3LRgvInbjYD0TsWEoX3URmWx5zFtNoKu18/lUjD6VRhKFA k44CaD7472R0Hu9D6O2dffMhmro1zuq5g+MBxvpT1EW1iqKhVuck2+z5ErlzZtM= X-Received: by 2002:a05:6a20:549c:b0:1a3:baad:d566 with SMTP id i28-20020a056a20549c00b001a3baadd566mr1487303pzk.40.1711697098883; Fri, 29 Mar 2024 00:24:58 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:53 -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 , Michael Ellerman Subject: [PATCH v4 08/15] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:23 -0700 Message-ID: <20240329072441.591471-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Acked-by: Michael Ellerman (powerpc) 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 1c4be3373686..c42a57b6839d 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 65261cbe5bfd..93d89f055b70 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -153,6 +153,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 @@ -174,7 +177,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(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.44.0