From patchwork Fri Mar 29 07:18:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610239 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 C8DD6CD1288 for ; Fri, 29 Mar 2024 07:26:44 +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=/oRjgy0IRe4EZlSogiWNYlYM8gv/+s8CQsRvY6gnsgg=; b=03yDtl8rvccbJ/ dsal4nSGsObbTNneovt+4SUtID2aP7Cw7THQ1JNOZZRVb4s/meBPOLpRsCeYpjfRa0bJ7U+822gxi LL713bzwlNH83hB/H/2vPd+VBJnpGp4d9ZYmsLl9qNjcucEeRg9+BS8ZYepinUGvJcaVsEXe9a03C 74EJ+12uvyzGZ9XDXkiW7YdtQvpQKrrmu4btzOqG7tDAHYfzKWQ8CKFg8LCPtpsCQMYEVSR47dWm9 7lY3hv7oczfSUigA0JBYFUPtI+t9rS0la3hSrS6p9F46rnMguvyjL1mpT6C16KmcEDr5DwYOyQpFA EfP8guh7fcKIUV0BxdqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dG-0000000H9g8-0CWE; Fri, 29 Mar 2024 07:26:34 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bp-0000000H8hw-23Dw for linux-arm-kernel@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:05 +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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=JEm/7Ho5jwi1OcMMs+Wlg9jHaI Fo1qUkC/RG3Hh303Ng0Q81qkOyG+HAOyRbjGsxdY68kMndm64R7sWgEs8NdSRGnFyvelAPXu9FsU0 s7I2i9GshRf86s/H+G0HBhXmVgh10241vLRMEvyaZyIYhhGzkvAlgJpa1zH96PNi8WB611J9+gWkH 4XZ7htv4yksiEn9dr2Ygsmv4lhPC1eLFxG11Ktjbi7rmnkXFHH7cDgBtWz0o8v1RD8mIZzwfcqUF/ q9sdhSdiKvyggg2+56bLhLJjGP3MeVIWNdY0Ait13TFL9x0IOB7ghetviOn1rFY3LkCSLTzKSW+J6 M7sPMX7Q==; Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bm-00000001QtW-1clh for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:04 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso1212250a12.2 for ; Fri, 29 Mar 2024 00:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697099; x=1712301899; 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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=IrWdzBqppExxW0jsN5DO1Lye8ORzfalZpVvRu4CDwDwDhl951IAkiCgUWDQpgCTadx Je1N1Jn24WMdxr4WOQOFWDvYKN8EWNK3Pj5DYG6ofJMuRWtsNcDrGhs+wUARMFLDtj5S y+t6HidMaOK/WQmCk8FXCIArZzmlYIwmhpc0Pd6wnxRQm7H/BdzpUi9JavjubNK4ui2N nLOIm4rUhL8/3Bbaq9bjNSc67izK1J19h+b48Tj8AY98/Mu4Csbcu6skK0oiz4jpQSh1 CjWUuIy3EXpOmqFkNSYjUop9tzjc9duw8Xu2AjhvUq2GG3kbNwMdDfAIycYxRnoycdkF Jnmw== 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=Z4KVqUhc7ArnI9MBtAthIzhFPz+6ymIBL7qvqtI+gumwkCr/T7U7DQ1qN5iJtZnN0R ilmUs6QZHXhaQ5Q7/OXDjWyI3gzWy7bocacpW/j43/CMHJQuGP1yeRF0Y7r9JftgPcov igF4x+jWf+Qf1NN5eTG7ymAj/k+Whd6e/xDrrWPgrd5lBqM8Uc9VYiQYcxZJpXPl4k6G bCCvZXhU4Nn2wzMdl7p3LaCdM+efZssIZuPOxVyOlEbi2Psio16WtswHt19eDtVp/Jvp tkjVSzl6JUpkG2L3939Yrso3KUmzKYDGJQhMmrZZDV5SiEm1OFx1wLsYczXIr66+dguf 2ccw== X-Forwarded-Encrypted: i=1; AJvYcCVgrur0E/MIjPfgqSW1CHvcI5+oWAFOyDKby5c1Zytz9N2iBz3EG/RVS5iqxrf8BeB7KmDE85QZKL0SN3FBo8IfoXFZ9EDhxSvTW2R4m+s7ODAUe0o= X-Gm-Message-State: AOJu0YzYLJSeHqueATDEgDQz0wBWF2RFQEbbKWkXAeSIXpKQVI5W7ykE sk135k5ARzupt98X/l0AuHJLWy9mLFXOg75/5xvROgTrzLC15244VBaHKg02+e0= X-Google-Smtp-Source: AGHT+IHGvAdAnX/0WDZVeXS0a7ZQ/motGWeac64eqKBau0xYaG382zqiN+0tE34St5zugVtRmJL1tg== 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072502_558500_9CB0397F X-CRM114-Status: GOOD ( 15.41 ) 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. 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 */