Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2139243rdb; Thu, 7 Dec 2023 21:56:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNe2A9GNEfBre55gDXcKw1DOI7LS2XWb74CeU9cRy8oDWcFT0YrcYnBUWAsKrAE5VCCMlO X-Received: by 2002:a05:6808:23c1:b0:3b9:e69f:c0a7 with SMTP id bq1-20020a05680823c100b003b9e69fc0a7mr1186428oib.61.1702014977461; Thu, 07 Dec 2023 21:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702014977; cv=none; d=google.com; s=arc-20160816; b=fKT5CAXLZ43HpVOf0n5rKUnTpRcft+Apr7VaMtCjwvM7cLZGtAVR52vz3uL3iyAQTL 592vjHQjSqBpkCps+Z3y4C7WuSlXVxLpQr1zzY9RV9Vx448iD+Cas63FiU9iv+F7Sg5n EFOixHa1lG0OyoStATg+SZUZUibjWAtXkwEI8+0Zet6Keoa7O8pxk0rwQQ5xKGJkh0gf JmxQLYj6PX+DYcDhx4t9lRObp8oJyd7SoR2nwL8sw4s+7MaVyRFP+JiaQvMmVTSsJVrk w8HF1RlmG1jH2bDMWeUYwB5WVc0Uq1FehAILBCK8ODJUwmjWEtfW4NVkVvvp8N9TbOn1 ZLUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/zgqNM1BLjQpwqOX8AAkpOEPaYmCztUSTZLlWDykd+Y=; fh=GWiN7/yH5ZaeB7dNf34H6takS9oI70VVB29etA3Fg9Y=; b=AzV1bb8boEAkCyGqWIoSrf8T2mXlcIEHUI+NDBqd3u8N5Iysg+OrBaad6OPhmEzFYH X3VXJJkalGR/wwoYpmSl96CPuvR37NCLnReNDOB5Jfn2PVIxqXFzxbMmr0v4INcLv+ki xRrjGv2hdtATqy9y/q1f6jI/osWu9lDXv+2NepSEmZKMplhpCMszY1Z1nb7ur4lhL1aM L+JRYVFoe4JmYMZy2vJ22Ptri3YLCyst7i2Nl0AHlcIINnJ/7btUr41R0cySbisHG4uF cZkYp0fAX8/wH7XRChZwwfwVyMj4sX4sxoiMj1CNAEYfyvA+cGQrT+gAwOq+rsgB56Nc QG5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HyNaN4jO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id 14-20020a63174e000000b005b896ecd1efsi969728pgx.172.2023.12.07.21.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HyNaN4jO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E234185BF2F5; Thu, 7 Dec 2023 21:56:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573242AbjLHFzv (ORCPT + 99 others); Fri, 8 Dec 2023 00:55:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573238AbjLHFzS (ORCPT ); Fri, 8 Dec 2023 00:55:18 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9356171F for ; Thu, 7 Dec 2023 21:55:15 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d0538d9bbcso15753855ad.3 for ; Thu, 07 Dec 2023 21:55:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014915; x=1702619715; 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=/zgqNM1BLjQpwqOX8AAkpOEPaYmCztUSTZLlWDykd+Y=; b=HyNaN4jO36Y3dQjRUjxnl/YivfNCiWNb3xYU4wqX8ZOI5UIjeFbzV1l3h2cdnMrbhd fI3c6ZB8d1JYo1a1c4YnVbwTqEXvVA0oEUthuLtZJjChmrpK9wzwrl4vu6/gGzlANjmf ygC+sJq+ps53oKiHSwdYcPc2wm4rxfI6sBv/4x8poR/GbMtmgo5oVsOo46f1/z0+RjdC XDYQXFwlvAsAcyqpRnGLt7F4fnbr66Wed+9USZr7uZUDBArRgrpehD52kh+teXkZHenl dVxUwZufUYMiZkmWGBYTgI/MQq3ccVTZrj+0JgUSFQFz7OAsL+45U9d4jhAtD2vdJNpK /toQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014915; x=1702619715; 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=/zgqNM1BLjQpwqOX8AAkpOEPaYmCztUSTZLlWDykd+Y=; b=o9VjQMlvozCY1pS/9xqDap2EDEdCartvJ5u7vtumxOwKOLL0qU0px/8Bo9lh2bRZpR Am3lEyesBqjY2HgDx4+Ij4ncWooW9wWeCk1/nWqI0e3IrCygd1Y9/Je7Qjf4qyHZYyv0 xCa/AiM12JWBMRjEScswtgmPLBOOi+wbnUcSYNkxk+6gt/H9G+sivCe4MWdUuAhHf6ZS aOlYImKKHXVbBwyObHt1bpueLZud7doVWRxvu4Nc1MfuGdbz96MVn8XhW9fYcP36TL8i NfRVOBUciHuNpsNjy1EwdtqUiN7fMfpJmBtJzFOxhqJ6yP/boowCzkfTv1HozozC8im+ tI4A== X-Gm-Message-State: AOJu0YwlJZTX1jRN0WM0qm3tpN00cbAh/72mZhkKqysySs9GzzQu5jLC bHA3xDg3daFYuzBiy48CFUO+jg== X-Received: by 2002:a17:902:e88a:b0:1d0:68a:4a46 with SMTP id w10-20020a170902e88a00b001d0068a4a46mr4585686plg.3.1702014915181; Thu, 07 Dec 2023 21:55:15 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id s22-20020a170902989600b001ce5b859a59sm786250plp.305.2023.12.07.21.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:14 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [RFC PATCH 10/12] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:40 -0800 Message-ID: <20231208055501.2916202-11-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208055501.2916202-1-samuel.holland@sifive.com> References: <20231208055501.2916202-1-samuel.holland@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 07 Dec 2023 21:56:12 -0800 (PST) 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. Signed-off-by: Samuel Holland --- drivers/gpu/drm/amd/display/Kconfig | 2 +- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 33 +---------------- drivers/gpu/drm/amd/display/dc/dml/Makefile | 36 ++----------------- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 36 ++----------------- 4 files changed, 6 insertions(+), 101 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 4ae4720535a5..b64f917174ca 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 /** * DOC: DC FPU manipulation overview @@ -87,20 +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_VSX_COMP)) - enable_kernel_vsx(); - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) - enable_kernel_altivec(); - else 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); @@ -122,18 +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_VSX_COMP)) - disable_kernel_vsx(); - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) - disable_kernel_altivec(); - else 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 ea7d60f9a9b4..5aad0f572ba3 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 -maltivec -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) frame_warn_flag := -Wframe-larger-than=2048 diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index acff3449b8d7..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 -maltivec -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) -- 2.42.0