Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp828648rba; Wed, 27 Mar 2024 13:04:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIafmdxQ0E0oERIO4Ms9KdlTqEGMP2f4Tc2+fA2mXxf1SbPTZyf0/rHbNI2PeJncua0Qj6AJJkZh3FGvLTkvYjjES992QX++VVdFIqsw== X-Google-Smtp-Source: AGHT+IEzts5vQrbGAYUc5JMoK/LMdN/yP6ui1N0T5grl0ihQ/T7YQu9To5mITlS3EmYUlMdEZsEy X-Received: by 2002:a9d:65d8:0:b0:6e4:b663:b204 with SMTP id z24-20020a9d65d8000000b006e4b663b204mr1077249oth.11.1711569884082; Wed, 27 Mar 2024 13:04:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711569884; cv=pass; d=google.com; s=arc-20160816; b=ZPZpFVtrql2cCNpv+8jskyY6yI4DGUtdZEGy31AUUE9Cc0/NQ93pMNhMEKOEwonS7P HaZsPX6UlUHT2hZiBw3Hk6o8OWtiP7Qj+x+ayb9obRxk0+vK9wA/Q18orbKzYIgAyKZ4 vGCZi+SVvbZTrTX4pTYvHALT5aEnCELtOFQE6QBQLcmQ+HSdH3h8sPHCQI21051UudIW DqNBiRsSDgXEiDFR5ZEtUnY/QGf0HQfnWo4ogRzTzl5HU/RVqBPIDHuFH7X35Ev+aes1 pzBDaBDtZ8D/mAfawVj7MtS+nVT6ncwurUanKC+JU75ar5ruQfjSTMaaTp79bTzDty58 mwIg== ARC-Message-Signature: i=2; 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=bM3Hi+5Alr7tzqsz3KXbQamZzAJvK/Ux1AY7aws8WNM=; fh=jSAHg5BGLnf7ze+M5KXvoeSVDAGwfav2I3x+KdWMty8=; b=OCPbgZa0TV+lBnAI7nvWCFFPkdMmLawgHHR2KYyhh0oCNLyB/dBKGCNlir5vSK/gwW mJb4r9dAT6e8y04U9nCYu0Vl4jYUeb4mB38bwDE8c7aczXKhRSltI7aWZfJB6uEnFsBb RcG7dg7q/RpsBtHWaHaaZBHaZ4OHXnHXCPSq0ynbiZmGDm6yXach6PnzA7XcUKrtn2qS dsLXjIXrujB4yUS/vM+x+cBrUa7vPMl0ghXyeBuuCaRZVlCT4ACEXfClXg4XVTAQuUUz ++3rh3eN1ePiXoEdiBRdHEon1eQneC4kv4X7xGCUfMqf3kzHFkLwgVY3v2lwER8VdTSK DzSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=gPcp9vYv; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121945-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a37-20020a05620a43a500b0078a5d2360f3si6539899qkp.541.2024.03.27.13.04.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=gPcp9vYv; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121945-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A1CFC1C3312E for ; Wed, 27 Mar 2024 20:04:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C07F4154C05; Wed, 27 Mar 2024 20:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="gPcp9vYv" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 05BE6154441 for ; Wed, 27 Mar 2024 20:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569737; cv=none; b=lum9wKdgkP6l8ySYLzx2RQb7f/EQ9cMsElF6BV2MjWTqCn/nCmBOaxBO+O7QublP/LuLzV1iw2G7T98lkHENfzWN81yJTWGemd2Fc9pe41DI3AATSJLewFx9viHTaqa3wKQlQYeJERn9GxL3g+8CWWaHUNrL7s2jZBxWU3jjSxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569737; c=relaxed/simple; bh=g4mhkWbOPq5UTkZ8eyYBkXzUJ8zECj1QnaC6Culjcfw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eZ2xW6h5qqYM13REKqlkpElItf+/evcB+R9yGfRsL0tjLLD2I4Paxh7qPnzTDKHbCBXP+KY7/8hOnKxGUMOJK3RmsOVdxmbyF7F2lxbZQto3ROMzMERY1SEIWi1mtB9yBoXjAnPbsZN6xsWahB8pFDHzoq9WIzqcosB6uToImU0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=gPcp9vYv; arc=none smtp.client-ip=209.85.214.169 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-pl1-f169.google.com with SMTP id d9443c01a7336-1def3340682so2199285ad.1 for ; Wed, 27 Mar 2024 13:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569735; x=1712174535; 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=bM3Hi+5Alr7tzqsz3KXbQamZzAJvK/Ux1AY7aws8WNM=; b=gPcp9vYv/QWPJ8uDrQ0o6MUAt6FwdJouyp6V3Z3ucB4Pj4HbDUXqi+x2WEVAZU29gH j3Ce7n/wzBvX346MjJp5QE1HgrmXb6ASRpOVSPzWDRky8d7DcqmUUs3nDJwJ3CQ4/uiy oj29p7SFDVeNLnsSYcZTwTQEEpUz6ZBs8E4sv+w1TfMdX4upoWAvU6W66zOo88r39g3m y15Wmnp4KtXkou6Kg+gJpxsQLP2nDlZdo0l2iV3yma4Ad3SOthAKbiNvtYCZb7o5K/HU 8zZ6lmg6XxFSQ5ceFE4/BMLxxwtmgFwMQcIuXWM3CgYOqGJmJ9FQM5xZ+djmQGRqF1VT SWqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569735; x=1712174535; 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=bM3Hi+5Alr7tzqsz3KXbQamZzAJvK/Ux1AY7aws8WNM=; b=utZmywhfHq+0cE3K5fnlptQnWgloPR1t9ohMUDNphtcDc807p6K7y2SY+gXWuDCjZ9 9I1Al9+tuMbIJUHylQ1O1nhOtxQGylp4AR7fCYRheexhWm2CmqLKxktB7X1zsGF78vA6 gRybtvNesWWhTyU+s2A1BSVPjn+XNhLvlhBrDev1Dpz2l2lWgmZ5ee/jpPd6K//zlw97 tS4g56XDm+CvJi+k8SJLpPAcBKSLKOC7TjWgSHO8e6MFlX3kRgYXAcoHbf8Gfbghew/G ZmgmdVLdwgME71naC5iGfn6VpMq7dE3uxJ7DGDTvRy1m1h/ZJkmZUZv0DYHHl9TQPNsF AZjQ== X-Gm-Message-State: AOJu0YxHuDKa47dgSwSGjWLUvQDTfmwYi6SwkO4dKhRXr+ArdsewlhKE TRjhuiUvENNZIJqWi8SS6QnI9pWLrdzC/T56h8WxibYwD45hWZkAL3MVzQiKMpM= X-Received: by 2002:a17:902:e5c1:b0:1e0:c91d:4487 with SMTP id u1-20020a170902e5c100b001e0c91d4487mr958029plf.43.1711569735358; Wed, 27 Mar 2024 13:02:15 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001dd0d0d26a4sm9446459plf.147.2024.03.27.13.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:14 -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 v3 12/14] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:43 -0700 Message-ID: <20240327200157.1097089-13-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240327200157.1097089-1-samuel.holland@sifive.com> References: <20240327200157.1097089-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. Acked-by: Alex Deucher Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (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) -- 2.43.1