Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp827949rba; Wed, 27 Mar 2024 13:03:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUK3Mty2bqo+i8L19oFYToqJF40V2m+JgBZduME3AalmcaqAN4WEQWrFo7OD28KUP2mL6cKXiOnHL/nupWaMTY43lKBAO9xltBgO3Z51g== X-Google-Smtp-Source: AGHT+IG7uxVvRrz3QA5uV/OMCtHpBx5bpRQWbJ79bSW6rWT4jtU3CXWp6nSbOg1tGjKcoMpLaN3v X-Received: by 2002:a05:6214:12d4:b0:696:7fc8:b679 with SMTP id s20-20020a05621412d400b006967fc8b679mr607093qvv.5.1711569821834; Wed, 27 Mar 2024 13:03:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711569821; cv=pass; d=google.com; s=arc-20160816; b=hj6Zl7wIewgh/5KxoG7KK1wOpIUhXSx6ot0Po+DAukfVtZT3ns0iu+lvZ9UDjRd8Rh +Rk3CGhig1WXxvmdibhLzdfuuWs3PfSIZucl8raC8JvFU5HkbtTWSMCek4A8o6jnbWMM Wfo7sdeCiz5lNIakzsugz+mRe5Oz2B8rHqnKUPEsmfDH/FVjltEBjmL/jJ2d6qqt9ECa 4Bo6QL9vOuS7KGCcwYo0JNR6lk8ugpq4kaltD3AVqfO3UljKmNgBJwc2IT8maY5H359/ FPTXYQT26/fWfwZhsrrfM2uLus85W3Dh+WEButeUceNN+zZPEQ2/go3pbr4vxlvo9ydW I4rA== 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=m88RK+Z/il7UccpWfFZJ13Lz8O1oGIqhXeprohKD33g=; fh=2sRQR5wCh2D6APuQBJ3gh3iqF+xzIveimN7L5+SYre8=; b=tP5pWDb6byAZi3n+qGk0KwDND2EBZ9Rx+dII+PHItkjxpRj8dWyETJUEdO750xdprs M97KZzFVaU5a7QR3dDHO1Sjg6sxZ8qv2adrumqnFbbACiBgECJ8Y8wy3Fk7SPavcreK0 4BCR0aPGpUitbk4S97Ijon/M8PExCruf53Z6RJ6DruXuc+WwyZkHpsg30vVkv4/IHg6A Albpj6Fjnrm4jMS44flOVQZaLX3ccOeaqoTMV0Ac1C72m6IQakaKLzPL/BhvB/fUQV6M gWEKd2lAJHbjlnpeK5ovgieAAK8ES0+aegfaNiYtswW0jEE1GPpg5Uapp22s6QcCEUsT 8owA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=a+zvewvk; 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-121940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id px4-20020a056214050400b006972ec855besi538757qvb.96.2024.03.27.13.03.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:03:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=a+zvewvk; 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-121940-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121940-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 83A1F1C32BCC for ; Wed, 27 Mar 2024 20:03:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69FF8153829; Wed, 27 Mar 2024 20:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="a+zvewvk" Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 F0DC5153812 for ; Wed, 27 Mar 2024 20:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569731; cv=none; b=iJzfulsHz7iXF81glAvSa2yshsT4xDXyvqkCDnWni4crlx8ehUzfOxXWFj1qiMgB7/UZJDvHeYXcm3UB6s87abl2H9ea3PqpioXGIXR3D+1Iyaz6OLl0NprkNYKVgexqNOZkJEzU53MMr2X5nEtmLfkLOEMTvaPl0Oy2qGyKC1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569731; c=relaxed/simple; bh=Fw4bnCEbYOWgBUe7aXSYgGws+NbNxp0fhExNVQAWEbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BeIb0vXhfK6uHUZjo7hGKYGZtXN1wGYccvclcsr+uSMNSJMqo70xfhtbCy17TUanl+r57c3/3DaFZzWEJ4RVuwhwY/eqLmzJPQyJ1A4SSGWQJpk+cW3Z+y2P8x28p0UnK3nWqj6WrJH/HT4pLDxrASrwsq5xz0icZHk4yxvtM20= 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=a+zvewvk; arc=none smtp.client-ip=209.85.214.179 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-pl1-f179.google.com with SMTP id d9443c01a7336-1e0025ef1efso1870405ad.1 for ; Wed, 27 Mar 2024 13:02:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569729; x=1712174529; 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=m88RK+Z/il7UccpWfFZJ13Lz8O1oGIqhXeprohKD33g=; b=a+zvewvkRZ16W9B3hQMjxRA6roFHMtTuXOcbAAl2UVHLzt9L8pWb/IvZXs6YwyCo/w mdAmk2Ropp8ueAoi8mF+bSWKvEtZe3JP/TnX0IdN9NyxIy5hRK+tjJKv9IT0Gyfd8usH 2UXmotfupvOzqv0d59ufki8HMgGJ0hRMObEhDqmne6Ckv2seYZlN5fRH1I8mwbLB4bHn iZKJVFUyrWcTfclDkuROstWeL2DlW5u0OHzExwA3gHijHV0USvnH5O0IURbWKoEFX8/Z LD1j/Z3sYQZvmugZrKIlbDFYN0sWXs7biaITyMPirfRhvlkM0ZR3rpiDTjekaEcXxbMu dCFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569729; x=1712174529; 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=m88RK+Z/il7UccpWfFZJ13Lz8O1oGIqhXeprohKD33g=; b=uWxAQzr7vYmvg7pqmqccQZJKdfUDy9ovO+yPJ0PsxGMBo/rBHQEAmuNLLATWatcUv4 nymQ3NdmsndPk3/Bw680K9McZGqbA7n4VijJ5kByfUIXPI3PmQ+fgl0MDUvjt6YhUKOo 6likhOO/tIprAomvNCK6h0CUrVB3Nwi+qu2USi/XQ2F4oJWvIMAPBY10qtXsOD5SaD2N /KHiwMi2/i0dLe3owqE4uCrCHAsUrij3beZtS8SYLLWoNf+UCz0kRwxYTGj4o8g6vpl5 lYZFHBk83L/LKNvDp4jIeFBESYJ7oxpYcEBk4cxmPqAGI2bdx1PzH/gNf0N1yJx2Aeap Hwbg== X-Gm-Message-State: AOJu0Yz4n7vMrzewHBh2KC4PQp1f+CT96P1cYG/6y4XkzwGDEKTTIrbs 1N4R3pHRt+uY+lh3yAOy2d257rFIFoSxY0VyuZ/8m+oQTq4pjsQofx+OF1kqNmI= X-Received: by 2002:a17:903:245:b0:1e0:e70:4264 with SMTP id j5-20020a170903024500b001e00e704264mr785470plh.33.1711569729552; Wed, 27 Mar 2024 13:02:09 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001dd0d0d26a4sm9446459plf.147.2024.03.27.13.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:09 -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 v3 08/14] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:39 -0700 Message-ID: <20240327200157.1097089-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240327200157.1097089-1-samuel.holland@sifive.com> References: <20240327200157.1097089-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.43.1