Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3703356rdb; Wed, 27 Dec 2023 17:48:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbDHuwuCbxYN3QsRFiYxzU2ldTawQ3A6/yX8VSajkWYcM8hJe0aYQ7l+ARR0BoV6Gu6DC3 X-Received: by 2002:a05:6a21:a5a4:b0:196:50c0:e32 with SMTP id gd36-20020a056a21a5a400b0019650c00e32mr111394pzc.50.1703728131388; Wed, 27 Dec 2023 17:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728131; cv=none; d=google.com; s=arc-20160816; b=ZF+PxrpgXVHYz/ylKboULw6xMg2pTuirzOisASfIZj7dIOtYtM4pnGpShyDdhwUJ24 KXh4P3MvAFZ9H9wfVtRIKaMVObKjql2gj7vEPGhc46yl92ecpyGsVKAIxprqwJDRrGvl RuV/aMLqRKgUTwhZAXjhvzeh/98IsHnUXibZg4QZeDhpSk4kskq03YbGw1aTzrL0H3X3 D7FohdWTxa32t1CFi2dvTcKtMv8iTqzsj3eaojKw9TVnpHOUSfNSXhXLLmPtmNWP7aAi 9fynIxSqeEBFNdT4lAXVJYNIZy6XcC6n7QlqF9IJkuCE2FaueCR1/wgobyVfr9NxelXW 0ecg== 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=C2MND6WwIohPzgleMTaIy0ci/VPA95sqr1KaUSNr79k=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=EySf+krab62amFTzr1Ky+MgnIPhd3qnBpS30ItS5g2K+hnwq73VdrErKNxW2d68xi8 3D6zdtykBH0vRBU5HM+RyJ3MJRlpu3hs1XVE4iiizJrGR9AOzpUeYt8PpMKtlf5xlqOJ aoSR1r1HAVYWrybPsZCNNAQtM6nDdMP9RViNndEmHoeme7ADpe2HvoFLYG0SEHUbdo0q zvKOgV1cxxqkJxS/DylHKL0k5WUsXp63OQKZ4Tdw7dyQNHs5Bm5JA19ZeVEb1436w+8A eK7sg/ybbl6xrkjOzFoosw94WYiw4E0NHZ+SEonMf5Wnr1UOC5BUhRE64MvO3PE7Gj2N NJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BelVkE1g; spf=pass (google.com: domain of linux-kernel+bounces-12378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x15-20020a63170f000000b005b99697d854si11839513pgl.673.2023.12.27.17.48.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:48:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BelVkE1g; spf=pass (google.com: domain of linux-kernel+bounces-12378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12378-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3971BB22FE3 for ; Thu, 28 Dec 2023 01:45:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0054C155; Thu, 28 Dec 2023 01:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="BelVkE1g" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 9A7DD8C0A for ; Thu, 28 Dec 2023 01:42:38 +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-pf1-f178.google.com with SMTP id d2e1a72fcca58-6d9af1f12d5so2545809b3a.3 for ; Wed, 27 Dec 2023 17:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727758; x=1704332558; 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=C2MND6WwIohPzgleMTaIy0ci/VPA95sqr1KaUSNr79k=; b=BelVkE1gP+ExM/Q1wxZRzHWTPmAX9hejhcDS/DdsfhMuiNXUUN21wJ7qaIQMr2VEYw OL8jL7/1pKXo+qtIKXYSvCTglFODibzGqQv0aW8wTgo5rxdfHR1dVqPoDWLiHjAbxU1i 4duCMKJTh562W2jiY692tdqEMNub3rEK713diQW9Wa0XsuJdJGNvUM7fX8sDT6pEi6qi 62i18E65meJ/pt3+NzS6yERSy3/tMobdVf7EyoWEaHt7IOpdndlDukkW1qEm6kQFqNoK E2xupJVjmZHLjIbBdiAK3OAMw/DT5AxzLcuxqmyb2dcDFKBGTQHShJ4F+xCP2GHy5MqH tZHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727758; x=1704332558; 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=C2MND6WwIohPzgleMTaIy0ci/VPA95sqr1KaUSNr79k=; b=PqOkovbQwg6Pox9dwhUoaYKIGhD60zpjZg5N2aFkxGyeTFPCmEBG+gj/+hSBRC2Qbk 9PLKINIhPDVZ8fyJZ01TndRr94tuPomrS+5IKL+vbExM8GwhRV59h7ICr7GVl3YdaqhJ UzM68igLO1sVRaoOqfjdVT8BPNuOw4HH0M1WkhvdEyto0LRSOICS3F/GHYYAKK5k/UvU obBSANZdN+g4ULWtThPXux9FlNfDf7BVhMuGUkIMefNDfAUgZT475LT6KxX82g0c1dUO SiqDmMaTVZA2CpafQtrCiTcvljqgFnMf2na87kdo2j8Y3BQAVaOE1SwFQIYL/L0NYJp9 VUPQ== X-Gm-Message-State: AOJu0YwlmFc9IFpVtxhI9UXfztYW+smv0v8MGY1XwET45hrY/n5J0gZs mJGtDyeela2GoCh3PLDRqd0WlJNWoItKVg== X-Received: by 2002:a05:6a20:7fa9:b0:195:105d:f40f with SMTP id d41-20020a056a207fa900b00195105df40fmr11064267pzj.81.1703727758078; Wed, 27 Dec 2023 17:42:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:37 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 12/14] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:42:02 -0800 Message-ID: <20231228014220.3562640-13-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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 554c39024a40..be15d366b786 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) -- 2.42.0