Message ID | 20231228014220.3562640-8-samuel.holland@sifive.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758714dyb; Wed, 27 Dec 2023 17:44:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNmY+a1+P2X6SE8IuoMLVFFm+Ywr4lAdDcvb94yeQtncQNjpPPrj9f3LsrnoIKv97vxJAZ X-Received: by 2002:a17:902:780e:b0:1d3:e3a8:19fa with SMTP id p14-20020a170902780e00b001d3e3a819famr4016432pll.74.1703727879181; Wed, 27 Dec 2023 17:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727879; cv=none; d=google.com; s=arc-20160816; b=Oo6tarWXsr1IHSN7AKD2DGbCa7KRI8+lXuIZb+aSvMCoTtfCjo0jACPo192NI4ZsJp QDo0pGRqrXq5LlLqPX6Wb89WW3GhLZkzt1ewyPlTsFGm4JX5bObGP+ZAZlMu6Y1wKKas wZQR8XseLPwjcpZhcF8MXBCFN4qR1R9H1mfBA0FkSJ6isnHeHaXJ4oNAdpKjIFJ+8/t2 T8UYQ4Mv9ndTa3Yzzv3mp1+BgniotG2H/HPqikxly0zs414/YLaTCq160vVCyexpNUo6 K216cxnM6jA+9Q3yoNc1uzDnGyGSMsjV2DLcYPCTUD74e/8XYKndUnhWyCNHLn3SgWVa SSnQ== ARC-Message-Signature: i=1; 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=h+RheApEuJN9kaaLRvICyPNbTjOVIvY5kEzb7DbTZjA=; fh=KKHhbkk9BIzPR3bk7ePhX57mmPOUuMWk2RXQROtgr3E=; b=OxG2MWP6yAs73AFP8EWKQE3eAYJQ+gqVskJLOxuNytGZTLWndotRsam+zAUvmySKjc zocYQUlwSyPriCZrG/NFaxhal/nnlU0Aeq04Br9Kesn8/YlfavEynQ3oYh/7LSq491sK 1OMQXWbbwI9TebOgwzGQXwMdFO+fpBi8fuk/KjgP7Je8qphqp4JHcdj3Cv2wieU03ROS 74asWLvzAekK0ojzmxttrIQNNti+8N1+ZsFACmApv+o5/DyRZ8wmCBeOZRM7JXK9EVZ+ +UC19WdNICyLLsrAHRO99rzrz1CrpiOCHOROnE0loEDY0LXZAgTqcYlEgTwjs57TQpWG NEtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HRrYqQ1M; spf=pass (google.com: domain of linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u21-20020a170902a61500b001d3fe0117e3si8360905plq.293.2023.12.27.17.44.39 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:44:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12374-ouuuleilei=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=HRrYqQ1M; spf=pass (google.com: domain of linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12374-ouuuleilei=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 EAA96283F58 for <ouuuleilei@gmail.com>; Thu, 28 Dec 2023 01:44:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D15A847B; Thu, 28 Dec 2023 01:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="HRrYqQ1M" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 500A96FA1 for <linux-kernel@vger.kernel.org>; Thu, 28 Dec 2023 01:42:32 +0000 (UTC) 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-oi1-f176.google.com with SMTP id 5614622812f47-3bbc648bed4so789129b6e.3 for <linux-kernel@vger.kernel.org>; Wed, 27 Dec 2023 17:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727751; x=1704332551; 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=h+RheApEuJN9kaaLRvICyPNbTjOVIvY5kEzb7DbTZjA=; b=HRrYqQ1M7T0XagVlhzUysvM9h33SsHQx78QCtwD64qF9ARhh6CyP41vp/N/j33EgIU mNz6+to30yKSSb20LzoHL2cPnBQD8Hc2n2kxzurBvj0nDOYXzQqmMoq4or1RxJXI7jty lGlV3AMjF4i87DGQRnIciQRHVy3TlSz+aBC1sBA0cd6Dxq2kwU9cEqdhklsKaL7Sgw0C nTj8VqriRvejZYFmTOxTOpjNwfm2Sj5TNf0N6+7dGXPqcFamMPQyJnxsott79G3oAGdl FP4CNfENvZz6Ki9qM/3kZ4rEurusCICr72v/yheVsCFvxj5reqYatDQ8gDYbwMreoMn+ dOdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727751; x=1704332551; 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=h+RheApEuJN9kaaLRvICyPNbTjOVIvY5kEzb7DbTZjA=; b=BR8U5i6huZ1yvleX2OogpmSm2/2o/nEskffRezPqW1AkzDZCH7vLY62z/Mg0ZdP/Tv 0TyKT9+4IU8lL0HSxPd3xQ3PhO5dxaYKWVrPIiSuIFAcjMh4gz4LQrFzJ4PmAISpNjNU tPG5ilJPmMnmbBT8QcDmHXdqu72NpDu5Tqgs+IBAxmUJuOqmuOv+/+Gfj/E2XNBrgzmt 9wtX3M2Kndha7cBZZrPKgWMOpBPJ5SZqUAJ+Zni6bziiV2xPro7LYvACzwI67puQ36SQ +B2q17Rkr2PsloPrWOxFkfa/Lhrj0KmV6vl11hnLEk9tLgRcMkJ3CqjUPuEnryn1ybN1 8iVg== X-Gm-Message-State: AOJu0YzzD0AKZNSbltuz6W3GEPvc8zpu57LAElh74QCnpHrcTWHu6wHb ZoQJbR/eP5hiQ1L3A76FlqNGUbQODP42rA== X-Received: by 2002:a05:6808:6544:b0:3bb:b063:1afe with SMTP id fn4-20020a056808654400b003bbb0631afemr7698441oib.113.1703727751522; Wed, 27 Dec 2023 17:42:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:31 -0800 (PST) From: Samuel Holland <samuel.holland@sifive.com> To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig <hch@lst.de> Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland <samuel.holland@sifive.com>, WANG Xuerui <git@xen0n.name> Subject: [PATCH v2 07/14] LoongArch: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:57 -0800 Message-ID: <20231228014220.3562640-8-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488164199772924 X-GMAIL-MSGID: 1786488164199772924 |
Series |
Unified cross-architecture kernel-mode FPU API
|
|
Commit Message
Samuel Holland
Dec. 28, 2023, 1:41 a.m. UTC
LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in asm/fpu.h, so it only needs to add kernel_fpu_available() and export the CFLAGS adjustments. Acked-by: WANG Xuerui <git@xen0n.name> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> --- (no changes since v1) arch/loongarch/Kconfig | 1 + arch/loongarch/Makefile | 5 ++++- arch/loongarch/include/asm/fpu.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-)
Comments
Hi, Samuel, On Thu, Dec 28, 2023 at 9:42 AM Samuel Holland <samuel.holland@sifive.com> wrote: > > LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in > asm/fpu.h, so it only needs to add kernel_fpu_available() and export > the CFLAGS adjustments. > > Acked-by: WANG Xuerui <git@xen0n.name> > Reviewed-by: Christoph Hellwig <hch@lst.de> > Signed-off-by: Samuel Holland <samuel.holland@sifive.com> > --- > > (no changes since v1) > > arch/loongarch/Kconfig | 1 + > arch/loongarch/Makefile | 5 ++++- > arch/loongarch/include/asm/fpu.h | 1 + > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig > index ee123820a476..65d4475565b8 100644 > --- a/arch/loongarch/Kconfig > +++ b/arch/loongarch/Kconfig > @@ -15,6 +15,7 @@ config LOONGARCH > select ARCH_HAS_CPU_FINALIZE_INIT > select ARCH_HAS_FORTIFY_SOURCE > select ARCH_HAS_KCOV > + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU > select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS > select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > select ARCH_HAS_PTE_SPECIAL > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > index 4ba8d67ddb09..1afe28feaba5 100644 > --- a/arch/loongarch/Makefile > +++ b/arch/loongarch/Makefile > @@ -25,6 +25,9 @@ endif > 32bit-emul = elf32loongarch > 64bit-emul = elf64loongarch > > +CC_FLAGS_FPU := -mfpu=64 > +CC_FLAGS_NO_FPU := -msoft-float We will add LoongArch32 support later, maybe it should be -mfpu=32 in that case, and do other archs have the case that only support FP32? Huacai > + > ifdef CONFIG_DYNAMIC_FTRACE > KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY > CC_FLAGS_FTRACE := -fpatchable-function-entry=2 > @@ -46,7 +49,7 @@ ld-emul = $(64bit-emul) > cflags-y += -mabi=lp64s > endif > > -cflags-y += -pipe -msoft-float > +cflags-y += -pipe $(CC_FLAGS_NO_FPU) > LDFLAGS_vmlinux += -static -n -nostdlib > > # When the assembler supports explicit relocation hint, we must use it. > diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h > index c2d8962fda00..3177674228f8 100644 > --- a/arch/loongarch/include/asm/fpu.h > +++ b/arch/loongarch/include/asm/fpu.h > @@ -21,6 +21,7 @@ > > struct sigcontext; > > +#define kernel_fpu_available() cpu_has_fpu > extern void kernel_fpu_begin(void); > extern void kernel_fpu_end(void); > > -- > 2.42.0 > >
Hi Huacai, On 2024-01-04 3:55 AM, Huacai Chen wrote: > Hi, Samuel, > > On Thu, Dec 28, 2023 at 9:42 AM Samuel Holland > <samuel.holland@sifive.com> wrote: >> >> LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in >> asm/fpu.h, so it only needs to add kernel_fpu_available() and export >> the CFLAGS adjustments. >> >> Acked-by: WANG Xuerui <git@xen0n.name> >> Reviewed-by: Christoph Hellwig <hch@lst.de> >> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> >> --- >> >> (no changes since v1) >> >> arch/loongarch/Kconfig | 1 + >> arch/loongarch/Makefile | 5 ++++- >> arch/loongarch/include/asm/fpu.h | 1 + >> 3 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig >> index ee123820a476..65d4475565b8 100644 >> --- a/arch/loongarch/Kconfig >> +++ b/arch/loongarch/Kconfig >> @@ -15,6 +15,7 @@ config LOONGARCH >> select ARCH_HAS_CPU_FINALIZE_INIT >> select ARCH_HAS_FORTIFY_SOURCE >> select ARCH_HAS_KCOV >> + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU >> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS >> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE >> select ARCH_HAS_PTE_SPECIAL >> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile >> index 4ba8d67ddb09..1afe28feaba5 100644 >> --- a/arch/loongarch/Makefile >> +++ b/arch/loongarch/Makefile >> @@ -25,6 +25,9 @@ endif >> 32bit-emul = elf32loongarch >> 64bit-emul = elf64loongarch >> >> +CC_FLAGS_FPU := -mfpu=64 >> +CC_FLAGS_NO_FPU := -msoft-float > We will add LoongArch32 support later, maybe it should be -mfpu=32 in > that case, and do other archs have the case that only support FP32? Do you mean that LoongArch32 does not support double-precision FP in hardware? At least both of the consumers in this series use double-precision, so my first thought is that LoongArch32 could not select ARCH_HAS_KERNEL_FPU_SUPPORT. Regards, Samuel
On Thu, Jan 4, 2024 at 11:58 PM Samuel Holland <samuel.holland@sifive.com> wrote: > > Hi Huacai, > > On 2024-01-04 3:55 AM, Huacai Chen wrote: > > Hi, Samuel, > > > > On Thu, Dec 28, 2023 at 9:42 AM Samuel Holland > > <samuel.holland@sifive.com> wrote: > >> > >> LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in > >> asm/fpu.h, so it only needs to add kernel_fpu_available() and export > >> the CFLAGS adjustments. > >> > >> Acked-by: WANG Xuerui <git@xen0n.name> > >> Reviewed-by: Christoph Hellwig <hch@lst.de> > >> Signed-off-by: Samuel Holland <samuel.holland@sifive.com> > >> --- > >> > >> (no changes since v1) > >> > >> arch/loongarch/Kconfig | 1 + > >> arch/loongarch/Makefile | 5 ++++- > >> arch/loongarch/include/asm/fpu.h | 1 + > >> 3 files changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig > >> index ee123820a476..65d4475565b8 100644 > >> --- a/arch/loongarch/Kconfig > >> +++ b/arch/loongarch/Kconfig > >> @@ -15,6 +15,7 @@ config LOONGARCH > >> select ARCH_HAS_CPU_FINALIZE_INIT > >> select ARCH_HAS_FORTIFY_SOURCE > >> select ARCH_HAS_KCOV > >> + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU > >> select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS > >> select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > >> select ARCH_HAS_PTE_SPECIAL > >> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > >> index 4ba8d67ddb09..1afe28feaba5 100644 > >> --- a/arch/loongarch/Makefile > >> +++ b/arch/loongarch/Makefile > >> @@ -25,6 +25,9 @@ endif > >> 32bit-emul = elf32loongarch > >> 64bit-emul = elf64loongarch > >> > >> +CC_FLAGS_FPU := -mfpu=64 > >> +CC_FLAGS_NO_FPU := -msoft-float > > We will add LoongArch32 support later, maybe it should be -mfpu=32 in > > that case, and do other archs have the case that only support FP32? > > Do you mean that LoongArch32 does not support double-precision FP in hardware? > At least both of the consumers in this series use double-precision, so my first > thought is that LoongArch32 could not select ARCH_HAS_KERNEL_FPU_SUPPORT. Then is it possible to introduce CC_FLAGS_SP_FPU and CC_FLAGS_DP_FPU? I think there may be some place where SP FP is enough. Huacai > > Regards, > Samuel >
On Sun, Jan 07, 2024 at 10:39:07AM +0800, Huacai Chen wrote: > > Do you mean that LoongArch32 does not support double-precision FP in hardware? > > At least both of the consumers in this series use double-precision, so my first > > thought is that LoongArch32 could not select ARCH_HAS_KERNEL_FPU_SUPPORT. > Then is it possible to introduce CC_FLAGS_SP_FPU and CC_FLAGS_DP_FPU? > I think there may be some place where SP FP is enough. Let's defer that until it is actually neeed.
diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index ee123820a476..65d4475565b8 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -15,6 +15,7 @@ config LOONGARCH select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 4ba8d67ddb09..1afe28feaba5 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -25,6 +25,9 @@ endif 32bit-emul = elf32loongarch 64bit-emul = elf64loongarch +CC_FLAGS_FPU := -mfpu=64 +CC_FLAGS_NO_FPU := -msoft-float + ifdef CONFIG_DYNAMIC_FTRACE KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY CC_FLAGS_FTRACE := -fpatchable-function-entry=2 @@ -46,7 +49,7 @@ ld-emul = $(64bit-emul) cflags-y += -mabi=lp64s endif -cflags-y += -pipe -msoft-float +cflags-y += -pipe $(CC_FLAGS_NO_FPU) LDFLAGS_vmlinux += -static -n -nostdlib # When the assembler supports explicit relocation hint, we must use it. diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h index c2d8962fda00..3177674228f8 100644 --- a/arch/loongarch/include/asm/fpu.h +++ b/arch/loongarch/include/asm/fpu.h @@ -21,6 +21,7 @@ struct sigcontext; +#define kernel_fpu_available() cpu_has_fpu extern void kernel_fpu_begin(void); extern void kernel_fpu_end(void);