From mboxrd@z Thu Jan 1 00:00:00 1970 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 8F07FC4345F for ; Fri, 12 Apr 2024 16:58:23 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qHpM05H9XeK3rUF/nOZG0tvhr+todAT5lH4X1hBei1o=; b=sIfQyBamBGSAvq vRSL7plumbQoB2eZ3KKsh4agyKhWiMPAp8Fmmxxvhquq3mepp0ht4I+5D46/nCHeAM32kP43i5W90 Z2w0iss7UtV0M55XgIA2J+Gs6AmjWmEkDq+5rT/I5mn1jNoi5aTNWImOvAM8T3A9dtmc1EGWarWMF Jgf0sfe0ttUp3Pd3Cl615P6ZU2Dc4mKBp2uSrk1jkmP0BfiPZV2bz+pEvMV0+dw4aDRZDSsZMXoUv xl3rRv0ztaUTMYoox2PtKxVf4CyQbcQoRwTpfftAVXgzdPsCiprl1vR7ydedAjKCoboDHRW8F6PI8 eP+v309oYiOHnNBklJEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKE9-00000000ZLm-2Wag; Fri, 12 Apr 2024 16:58:13 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvKE6-00000000ZKT-25I5 for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 16:58:12 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6ed267f2936so936258b3a.3 for ; Fri, 12 Apr 2024 09:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712941088; x=1713545888; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=FJWVQnWLX/pkislYxbbN5qnILpyF7P63m18zWA+EsbY=; b=JE6jeG/oa9WxGl4EUpneHJuKGZuleuVb8gWA6OfTMMDsdHrQ+rJpCvm0JwUVeMCNTF bzwXwbF+aMu+gQfeKxajrHqIgQzQTpCPgGUs8LZNXZel3ONgoBvDennYNvkD6pOEbrlG ne1khTsbg10chs40m0pen4dZ+d8aB3qCtgmyAZP2LuX27sLXz1iG6EuhqOomI2tEWfpd 776VhuNdwKofpRjCOm1RcLlO37RYroFPaQWkK0PxvdBb6+LeXXWaC0r585wjXGpZAwsa KILq4nnF55EXS/jLMZ08qsmb5vx4Qc+Jry37tZA2bn6Xok9I+vEdZ1ZbLLJb6x8hthLE wo4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712941088; x=1713545888; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FJWVQnWLX/pkislYxbbN5qnILpyF7P63m18zWA+EsbY=; b=huel+FMlOtoLpFjFmGmnDd0ev5UkpenAHVr/b2WQ+B+L6Hd9vpcEBjh0ARaAx4FjpX 4a8+u7uS7LdnlzDfaV/wEnROz7KEn2fHg+/4+zdnlj9+NPtL5c4gnUhthje1mIcoD46J xUNj/gSXCb6EoTPyi4gPP0zADRCF/ZAORJVfGrMHfzTobrR6ObrRi5LoajCqZn6uUf6k ZRUUYQO8KwxcHJoPcVztrwcQpiFIICwvR3bSBZBQi+4UwBkz6EI/8ILuM7Ll3Y6cNXqm 07TH+8hBssYJg3RLv3rClSkcuvNMZPk3RZm5fugwiwloFmiuQzQBlj7HlpzcP4X/XgvS 2/sA== X-Forwarded-Encrypted: i=1; AJvYcCW1du1179cA2IWe5u33D8O2nGeb41hOyvPRsoz3A3lo5H4IbVxS28yXvNwPky9Lskx5kT0/zsGpP42mCC4WtnLz7v5yBfFNV4nlDkKo2BC325gmuVU= X-Gm-Message-State: AOJu0YxZIzMjtze+tueL9GfbvmXYQpFAM9+KH9unxnc2ElHnJcfR2pSy WAx4p4I0kRnMYQPeTzwbPlxIEq6IXfbMdAcRaQrrXVP6DuGBVHpPQWiNjFUO4FA= X-Google-Smtp-Source: AGHT+IGPCmN3W2HTZ0QmJ+6REUIlwbvOotgDE2tr5rxL5ipmW/2VnsTgQx/xnNwczxd72R2Uusa6Og== X-Received: by 2002:a05:6a20:5648:b0:1a7:4b6f:7934 with SMTP id is8-20020a056a20564800b001a74b6f7934mr3088514pzc.17.1712941088421; Fri, 12 Apr 2024 09:58:08 -0700 (PDT) Received: from ghost ([2601:647:5700:6860:121b:da6b:94f1:304]) by smtp.gmail.com with ESMTPSA id a26-20020aa7865a000000b006ea8ba9902asm3085131pfo.28.2024.04.12.09.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 09:58:07 -0700 (PDT) Date: Fri, 12 Apr 2024 09:58:04 -0700 From: Charlie Jenkins To: Conor Dooley Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Evan Green , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Jonathan Corbet , Shuah Khan , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 06/19] riscv: Extend cpufeature.c to detect vendor extensions Message-ID: References: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> <20240411-dev-charlie-support_thead_vector_6_9-v1-6-4af9815ec746@rivosinc.com> <20240412-sprawl-product-1e1d02e25bca@wendy> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240412-sprawl-product-1e1d02e25bca@wendy> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_095810_845876_97B076A6 X-CRM114-Status: GOOD ( 27.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 12, 2024 at 01:30:08PM +0100, Conor Dooley wrote: > On Thu, Apr 11, 2024 at 09:11:12PM -0700, Charlie Jenkins wrote: > > static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct riscv_isainfo *isainfo, > > > - unsigned long *isa2hwcap, const char *isa) > > + struct riscv_isainfo *isavendorinfo, unsigned long vendorid, > > + unsigned long *isa2hwcap, const char *isa) > > { > > /* > > * For all possible cpus, we have already validated in > > @@ -349,8 +384,30 @@ static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct risc > > const char *ext = isa++; > > const char *ext_end = isa; > > bool ext_long = false, ext_err = false; > > + struct riscv_isainfo *selected_isainfo = isainfo; > > + const struct riscv_isa_ext_data *selected_riscv_isa_ext = riscv_isa_ext; > > + size_t selected_riscv_isa_ext_count = riscv_isa_ext_count; > > + unsigned int id_offset = 0; > > > > switch (*ext) { > > + case 'x': > > + case 'X': > > One quick remark is that we should not go and support this stuff via > riscv,isa in my opinion, only allowing it for the riscv,isa-extensions > parsing. We don't have a way to define meanings for vendor extensions in > this way. ACPI also uses this codepath and at the moment the kernel's > docs say we're gonna follow isa string parsing rules in a specific version > of the ISA manual. While that manual provides a format for the string and > meanings for standard extensions, there's nothing in there that allows us > to get consistent meanings for specific vendor extensions, so I think we > should avoid intentionally supporting this here. Getting a "consistent meaning" is managed by a vendor. If a vendor supports a vendor extension and puts it in their DT/ACPI table it's up to them to ensure that it works. How does riscv,isa-extensions allow for a consistent meaning? > > I'd probably go as far as to actively skip vendor extensions in > riscv_parse_isa_string() to avoid any potential issues. > > > + bool found; > > + > > + found = get_isa_vendor_ext(vendorid, > > + &selected_riscv_isa_ext, > > + &selected_riscv_isa_ext_count); > > + selected_isainfo = isavendorinfo; > > + id_offset = RISCV_ISA_VENDOR_EXT_BASE; > > + if (!found) { > > + pr_warn("No associated vendor extensions with vendor id: %lx\n", > > + vendorid); > > This should not be a warning, anything we don't understand should be > silently ignored to avoid spamming just because the kernel has not grown > support for it yet. Sounds good. - Charlie > > Thanks, > Conor. > > > + for (; *isa && *isa != '_'; ++isa) > > + ; > > + ext_err = true; > > + break; > > + } > > + fallthrough; > > case 's': > > /* > > * Workaround for invalid single-letter 's' & 'u' (QEMU). > > @@ -366,8 +423,6 @@ static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct risc > > } > > fallthrough; > > case 'S': > > - case 'x': > > - case 'X': > > case 'z': > > case 'Z': > > /* > > @@ -476,8 +531,10 @@ static void __init riscv_parse_isa_string(unsigned long *this_hwcap, struct risc > > set_bit(nr, isainfo->isa); > > } > > } else { > > - for (int i = 0; i < riscv_isa_ext_count; i++) > > - match_isa_ext(&riscv_isa_ext[i], ext, ext_end, isainfo); > > + for (int i = 0; i < selected_riscv_isa_ext_count; i++) > > + match_isa_ext(&selected_riscv_isa_ext[i], ext, > > + ext_end, selected_isainfo, > > + id_offset); > > } > > } > > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel