Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2120089rdb; Thu, 7 Dec 2023 20:51:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeoG8MxrIdetPaTzNX7zDvj3K5L7tvM5KutZKkKF1LotQ4mrykDMy2XOh8Gl9Qu6AbXREV X-Received: by 2002:a17:90b:4a81:b0:286:ba9c:8931 with SMTP id lp1-20020a17090b4a8100b00286ba9c8931mr2698867pjb.13.1702011112243; Thu, 07 Dec 2023 20:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702011112; cv=none; d=google.com; s=arc-20160816; b=0jUlB/8ImBJr8gqnBQOZyq87CCbIcR4+A8nk44OM3MQPDEoyo5M6NUdORIDS1dch1B gV9Sk6uueNvBJ4kBdL/2/yTkFflqg07S5wcf/lx0itIp+8A+x32VcI04RP1sni24e506 u6RCZ2qa0FOVT9Wsdikfkw5iKJ7iiFWxb6UagYDM8ng8poHIavNUy7CIAnBIAiM2Xurk U9ywxWwCY5K39YnWS5dpDZA7UVnnn7mfP59OFLcjw4RFdhgBtdyXUMIlpqOW1UXPOQGL 6+e6eFu/X1nhqp4ELBvkjdL7/gdniFlvar8zCgr12N1t4biHZL93J+Sua6Q92IqXdJSR gSrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Siq5/aLB+N8os3ShA228wuqtqMbftMOZ84Ddlbg3k10=; fh=EakyIgHwXD3iOeb7kHIxwUKiObaVnNVXqvNGC6ZR6Tc=; b=bZFG/+hZ0vDK3aDDBiiq0cMkNcXkF3LNYx1IoSHbUPDjhAbUq/LTnUGNQ8rnxOC/Aa yyw+KCAErZoi9XRE97wi7sx6ErhQ7VD2R6GDL9pglsKZhnaTMXbbB/zVOJABqciB3+gN N7ZTbxKok0CknvPl68jfXxPDd0hlvMyqIn+lhEAwVBIa5Dr0UOhcdJnWnppBm7c1I6kM kMvsXvXw0re7Y2m/1SHfx1p/vxFS17qnwuB2g0nltGhEFBo7RzBuM/K3Z0n+a195cbSL fEhnyDrpkHCItRBvfo52OcEtRHuixr6OZBxGdY6P8Fk4GSj/pDj9F/er+XPg7fVtKYgR Bajg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HvZSylFf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x4-20020a17090a9dc400b00286530bddecsi2181700pjv.105.2023.12.07.20.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 20:51:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HvZSylFf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 5CA328235781; Thu, 7 Dec 2023 20:51:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573132AbjLHEtw (ORCPT + 99 others); Thu, 7 Dec 2023 23:49:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573162AbjLHEtt (ORCPT ); Thu, 7 Dec 2023 23:49:49 -0500 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2DB41734 for ; Thu, 7 Dec 2023 20:49:55 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-77f3b4394fdso70412285a.0 for ; Thu, 07 Dec 2023 20:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702010995; x=1702615795; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Siq5/aLB+N8os3ShA228wuqtqMbftMOZ84Ddlbg3k10=; b=HvZSylFfgTw4/EzNnDO7HhqVGULEsFS4BpNRhHitANhJH0km497hczzh2h0FSkm04n rhj6qopq70FRH1CUM4Y9Xk4rtusb1lYturbj18RmDBvPNCXSWQ6vyRLKsJBTwq6iyCVG KkXHhZZ2ZIcw1scjdvORIgojefYObOkKkeGMqDafxVQKG0EzjryltxHgqC+GcFKI5mh/ hhf0M6b4/gcBrzpzgWw2v+yygjHulQHUBhB3OmbmbRcY/n+a+AMkAXmibaKSJaWf/AG2 8A3uZyuYL+1JukY+iUs9Bv4H5l60aQ4jLEB2Y6VDEbnfnaC/FVzP5Vm3CczTO9e7dSO+ fmeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702010995; x=1702615795; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Siq5/aLB+N8os3ShA228wuqtqMbftMOZ84Ddlbg3k10=; b=C7hD1W5OvjN8Fxm1NuOKjN2TAFPuUuCdSCmdcbPfUzjEt14ZdYa/buNkLp9Ph/3oRw jBkpHTqqU+t2MDX+EL1vB9LgWxkBDqFo+nhVZgQLOaXaFZ88qelI+5rj5a16nPDZrsYc nY7SURTehwhKXSWX49SEAnVEpH4M/5xEbgNwbfZiW6/MjnmY8kJwM1suRYayUodLGR4c oykgeSEuIYo+PtSg2I364Bk8Loaq4cP0lGQN1dANJBIrXxcOnQhQroqsAwaAkQZoXHn9 R/3w4xzcdnmCnqYmdJ8zOKLrKIXDEep1EAFz2Fo9txvjOohiKHS2IL/JiHDwqLsb9usV JE0A== X-Gm-Message-State: AOJu0YyxA4wn5XQ6Ld/pFac1tY/HkZbY/l/f4Sj+hLAqB4l9NJPtLrVp Ygq19rPpg0sDNHfGd4LkzTECBw== X-Received: by 2002:a05:620a:1a8a:b0:77f:338c:a713 with SMTP id bl10-20020a05620a1a8a00b0077f338ca713mr2602110qkb.62.1702010994966; Thu, 07 Dec 2023 20:49:54 -0800 (PST) Received: from ?IPV6:2600:1700:2000:b002:41c5:bf1:860b:1e95? ([2600:1700:2000:b002:41c5:bf1:860b:1e95]) by smtp.gmail.com with ESMTPSA id ov11-20020a05620a628b00b0077f05db2663sm430776qkn.66.2023.12.07.20.49.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Dec 2023 20:49:54 -0800 (PST) Message-ID: <6d4cecd5-9083-4d68-a7e2-266dae9e3952@sifive.com> Date: Thu, 7 Dec 2023 22:49:53 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] drm/amd/display: Support DRM_AMD_DC_FP on RISC-V Content-Language: en-US To: Christoph Hellwig Cc: Palmer Dabbelt , Harry Wentland , Leo Li , Rodrigo Siqueira , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , =?UTF-8?Q?Christian_K=C3=B6nig?= , Alex Deucher , Pan Xinhui , Daniel Vetter , amd-gfx@lists.freedesktop.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, Josh Poimboeuf , Peter Zijlstra , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org References: <20231122030621.3759313-1-samuel.holland@sifive.com> <20231122030621.3759313-4-samuel.holland@sifive.com> From: Samuel Holland In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 07 Dec 2023 20:51:37 -0800 (PST) Hi Christoph, On 2023-11-22 2:40 AM, Christoph Hellwig wrote: >> - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG)) >> + select DRM_AMD_DC_FP if ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG >> + select DRM_AMD_DC_FP if PPC64 && ALTIVEC >> + select DRM_AMD_DC_FP if RISCV && FPU >> + select DRM_AMD_DC_FP if LOONGARCH || X86 > > This really is a mess. Can you add a ARCH_HAS_KERNEL_FPU_SUPPORT > symbol that all architetures that have it select instead, and them > make DRM_AMD_DC_FP depend on it? Yes, I have done this for v2, which I will send shortly. >> -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) >> +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) || defined(CONFIG_RISCV) >> kernel_fpu_begin(); >> #elif defined(CONFIG_PPC64) >> if (cpu_has_feature(CPU_FTR_VSX_COMP)) >> @@ -122,7 +124,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) >> +#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) || defined(CONFIG_RISCV) >> kernel_fpu_end(); >> #elif defined(CONFIG_PPC64) >> if (cpu_has_feature(CPU_FTR_VSX_COMP)) > > And then this mess can go away. We'll need to decide if we want to > cover all the in-kernel vector support as part of it, which would > seem reasonable to me, or have a separate generic kernel_vector_begin > with it's own option. I think we may want to keep vector separate for performance on architectures with separate FP and vector register files. For now, I have limited my changes to FPU support only, which means I have removed VSX/Altivec from here; the AMDGPU code doesn't need Altivec anyway. >> diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile >> index ea7d60f9a9b4..5c8f840ef323 100644 >> --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile >> +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile >> @@ -43,6 +43,12 @@ dml_ccflags := -mfpu=64 >> dml_rcflags := -msoft-float >> endif >> >> +ifdef CONFIG_RISCV >> +include $(srctree)/arch/riscv/Makefile.isa >> +# Remove V from the ISA string, like in arch/riscv/Makefile, but keep F and D. >> +dml_ccflags := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/') >> +endif >> + >> ifdef CONFIG_CC_IS_GCC >> ifneq ($(call gcc-min-version, 70100),y) >> IS_OLD_GCC = 1 > > And this is again not really something we should be doing. > Instead we need a generic way in Kconfig to enable FPU support > for an object file or set of, that the arch support can hook > into. I've included this in v2 as well. > Btw, I'm also really worried about folks using the FPU instructions > outside the kernel_fpu_begin/end windows in general (not directly > related to the RISC-V support). Can we have objecttool checks > for that similar to only allowing the unsafe uaccess in the > uaccess begin/end pairs? ARM partially enforces this at compile time: it disallows calling kernel_neon_begin() inside a translation unit that has NEON enabled. That doesn't prevent the programmer from calling a FPU-enabled function from outside a begin/end section, but it does prevent the compiler from generating unexpected FPU usage behind your back. I implemented this same functionality for RISC-V. Actually tracking all possibly-FPU-tainted functions and their call sites is probably possible, but a much larger task. Regards, Samuel