From patchwork Fri Mar 29 07:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610363 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 3647FC6FD1F for ; Fri, 29 Mar 2024 08:34:20 +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=0IVnpHQBQhy72h0vPCDPKgEL0w+TvLoSl8AXtPjKPpE=; b=ZNqgmTIuVU3vUK CxB0N+XjSzkHfLB7dTjbIm4LUvUs+UpuIoIGydfFU/A2Sr2GNG0XMXY3mACnEPR2p8BbFX452D6Pk ZcuFoG5lTx8trSn9t7Gkcz+EAgoHDKPISfPCwivEPSynDU4KgAoQZ9zrBQl/hg6hwzwlI0zufCI2l bAMWKlc2yIJ0Zblrq/QFEigUoTCd3QYp2ECrGgMG7K34mwD+2nMiXUJnm05O6NiwLk8zmY1URY910 /ZTTi3K6EX69G82jNV4TuQSeiOkw+pB0XOEUDkt7hEOynkmM9RKv/+dX8eVPVGr3202bnuYZ2TwRR nLGdbnNw4p+WWcLEL10Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gk-0000000HKgK-2xVq; Fri, 29 Mar 2024 08:34:14 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bs-0000000H8j7-2g1E for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:10 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2a21330d093so347560a91.2 for ; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697105; x=1712301905; 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=mTLgc+w86CIzWS7wXUfx6m7PM9/cP8vcHn3CMtfjbTw=; b=BJxRND2OZ/EzspShNtPye2avtBc3EoRg8QYY2WkYW1N4AYf8RsYajCGGIVr4uE79a6 /Axd8SRFU+OePj3+HEIyr1LyyXlA6HH2K/FkJzwEFjaCgwZnRYLN1XvGhHOfY9/uYi/A 6+MT/v4z5lUrByDAcbcCC16x2ZRGOXSR61MCAuSaSSdjyWUS/4VXHgpsw+2UFb+ITU+p azRir1Ox/ppSDXyvs5LHYnt1VGOhPpE5y8P0/yDog29ExNJL1duAkhUuA+LDB47A8PiA 4JpJ/bpPHulDjFxPuMm4y+ra1XMUUOrfmAROmL6QAkfnOKvovdl+kciSKtE0tpzfWzKK fjmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697105; x=1712301905; 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=mTLgc+w86CIzWS7wXUfx6m7PM9/cP8vcHn3CMtfjbTw=; b=A2vylQVPDDs3+7TuEdD6NKAlk2HdNlk/WGUuEbWBGI7p4oqYQVuYkch6dZPtrWPLU7 /TWs0nrXw8z7Dv8fwtMNl3ocCcA+MWkl2m8DO8w+mthwa/MmAt/IDWTsZvx4smRNIKAO rukM0JEHgL+fKIk41PeauGG4qccGbQHg6crVfGb7PdM2TDH4BEpxe17PNk5f4kYB90bl BPfqcQBUB2parFFQol2ufZUidDZJymgvbU0RCq3hyROO3wCBxIWJ/HYyqFuSL/Ocm8Su 1cfVKBvbpbPwalmQbe+fr0x8jptVdIyO1m3Vbnub7hhrP5aoi0Vr8K+S6xXgOOkokpaN Fy3Q== X-Forwarded-Encrypted: i=1; AJvYcCXsm3ZEm7hHq1G5vAdLMgNgmYxrlLJ2Bzoz7n5LqoIz4MQk7JHjXczkmGk6k0QBzBsaY0LnfCemPA2/yZPCKIH/GnZC4BGI94YtyLMsw74H X-Gm-Message-State: AOJu0Yw6NX/8VOrDG21An+gnprFbQi7gUlTzacoakp4LFFGTWyZPnOPJ u52CZss5MaRz7oCm3bhmUSU+AVeOjDgCAe2HXADBOk4hifcUAJhVN7W6HBu4VFA= X-Google-Smtp-Source: AGHT+IFao8s2x1qXqbSOjOiMcaW8BXkO3qbDPzR4wBp4ZGBo4Mov4EtcdN3TNOFfEQHizvd+vN9IZw== X-Received: by 2002:a17:90a:be04:b0:2a2:1415:723d with SMTP id a4-20020a17090abe0400b002a21415723dmr1167790pjs.42.1711697105239; Fri, 29 Mar 2024 00:25:05 -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.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:04 -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 , Alex Deucher Subject: [PATCH v4 13/15] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:28 -0700 Message-ID: <20240329072441.591471-14-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_002508_752249_3626FC84 X-CRM114-Status: GOOD ( 14.24 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Now that all previously-supported architectures select ARCH_HAS_KERNEL_FPU_SUPPORT, this code can depend on that symbol instead of the existing list of architectures. It can also take advantage of the common kernel-mode FPU API and method of adjusting CFLAGS. Acked-by: Alex Deucher Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland Acked-by: Harry Wentland --- (no changes since v2) Changes in v2: - Split altivec removal to a separate patch - Use linux/fpu.h instead of asm/fpu.h in consumers drivers/gpu/drm/amd/display/Kconfig | 2 +- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 27 ++------------ drivers/gpu/drm/amd/display/dc/dml/Makefile | 36 ++----------------- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 36 ++----------------- 4 files changed, 7 insertions(+), 94 deletions(-) diff --git a/drivers/gpu/drm/amd/display/Kconfig b/drivers/gpu/drm/amd/display/Kconfig index 901d1961b739..5fcd4f778dc3 100644 --- a/drivers/gpu/drm/amd/display/Kconfig +++ b/drivers/gpu/drm/amd/display/Kconfig @@ -8,7 +8,7 @@ config DRM_AMD_DC depends on BROKEN || !CC_IS_CLANG || ARM64 || RISCV || SPARC64 || X86_64 select SND_HDA_COMPONENT if SND_HDA_CORE # !CC_IS_CLANG: https://github.com/ClangBuiltLinux/linux/issues/1752 - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG)) + select DRM_AMD_DC_FP if ARCH_HAS_KERNEL_FPU_SUPPORT && (!ARM64 || !CC_IS_CLANG) help Choose this option if you want to use the new display engine support for AMDGPU. This adds required support for Vega and diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c index 0de16796466b..e46f8ce41d87 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c @@ -26,16 +26,7 @@ #include "dc_trace.h" -#if defined(CONFIG_X86) -#include -#elif defined(CONFIG_PPC64) -#include -#include -#elif defined(CONFIG_ARM64) -#include -#elif defined(CONFIG_LOONGARCH) -#include -#endif +#include /** * DOC: DC FPU manipulation overview @@ -87,16 +78,9 @@ void dc_fpu_begin(const char *function_name, const int line) WARN_ON_ONCE(!in_task()); preempt_disable(); depth = __this_cpu_inc_return(fpu_recursion_depth); - if (depth == 1) { -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) + BUG_ON(!kernel_fpu_available()); kernel_fpu_begin(); -#elif defined(CONFIG_PPC64) - if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) - enable_kernel_fp(); -#elif defined(CONFIG_ARM64) - kernel_neon_begin(); -#endif } TRACE_DCN_FPU(true, function_name, line, depth); @@ -118,14 +102,7 @@ void dc_fpu_end(const char *function_name, const int line) depth = __this_cpu_dec_return(fpu_recursion_depth); if (depth == 0) { -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) kernel_fpu_end(); -#elif defined(CONFIG_PPC64) - if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) - disable_kernel_fp(); -#elif defined(CONFIG_ARM64) - kernel_neon_end(); -#endif } else { WARN_ON_ONCE(depth < 0); } diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index 59d3972341d2..a94b6d546cd1 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -25,40 +25,8 @@ # It provides the general basic services required by other DAL # subcomponents. -ifdef CONFIG_X86 -dml_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float -dml_ccflags := $(dml_ccflags-y) -msse -endif - -ifdef CONFIG_PPC64 -dml_ccflags := -mhard-float -endif - -ifdef CONFIG_ARM64 -dml_rcflags := -mgeneral-regs-only -endif - -ifdef CONFIG_LOONGARCH -dml_ccflags := -mfpu=64 -dml_rcflags := -msoft-float -endif - -ifdef CONFIG_CC_IS_GCC -ifneq ($(call gcc-min-version, 70100),y) -IS_OLD_GCC = 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -dml_ccflags += -mpreferred-stack-boundary=4 -else -dml_ccflags += -msse2 -endif -endif +dml_ccflags := $(CC_FLAGS_FPU) +dml_rcflags := $(CC_FLAGS_NO_FPU) ifneq ($(CONFIG_FRAME_WARN),0) ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index 7b51364084b5..4f6c804a26ad 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile @@ -24,40 +24,8 @@ # # Makefile for dml2. -ifdef CONFIG_X86 -dml2_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float -dml2_ccflags := $(dml2_ccflags-y) -msse -endif - -ifdef CONFIG_PPC64 -dml2_ccflags := -mhard-float -endif - -ifdef CONFIG_ARM64 -dml2_rcflags := -mgeneral-regs-only -endif - -ifdef CONFIG_LOONGARCH -dml2_ccflags := -mfpu=64 -dml2_rcflags := -msoft-float -endif - -ifdef CONFIG_CC_IS_GCC -ifeq ($(call cc-ifversion, -lt, 0701, y), y) -IS_OLD_GCC = 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -dml2_ccflags += -mpreferred-stack-boundary=4 -else -dml2_ccflags += -msse2 -endif -endif +dml2_ccflags := $(CC_FLAGS_FPU) +dml2_rcflags := $(CC_FLAGS_NO_FPU) ifneq ($(CONFIG_FRAME_WARN),0) ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y)