From patchwork Wed Mar 27 10:11:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 1916663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Rd33i+Tr; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=vrull.eu header.i=@vrull.eu header.a=rsa-sha256 header.s=google header.b=dcZoAKWs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V4MsY6P15z23sQ for ; Wed, 27 Mar 2024 21:12:01 +1100 (AEDT) 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yh0X5EBFe+OwEA9u88O6Qz1J62hZXG9w47Z2WbwFdPI=; b=Rd33i+TrFMdjhZ hQNtofVsc2h8f2DE/ToLmxDTZbxxVCn0iSOpybDKpE5xnTHFdx6DDFMIGBlj/ytOBlHwPOhmX6Wrn eqLm2GQi2v+xNTCq1v5wHrOQFbbXjeNvDi8i5ewXqMHsfNPEv8WyUw4ihO/lRcVyaZjOvFSGlBgUE fCCtj0Ofxl8jZ0aorqJl2Z1Sft9X6iDgdw9oUWpEJBVGQiUatwyXb/A6JkD8mb5sVid+2zZVzetL8 CrdZHs5pRkC5eXFXtOGRTs0ACu2leYHg+MZ3tXUUA2vg3mwNDJaCzHlGt8gR3QBHyJW3Z4cSYeuQ5 /86rlAqjMxnqbAI5D39w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG9-00000008MBu-1c0q; Wed, 27 Mar 2024 10:11:53 +0000 Received: from mail-ed1-f45.google.com ([209.85.208.45]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG6-00000008M9q-3NzV for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:52 +0000 Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-56bdf81706aso6906884a12.2 for ; Wed, 27 Mar 2024 03:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534307; x=1712139107; darn=lists.infradead.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=HCn0Z/+/hpHDPypDW2ERtEbkNmjR8TyLoR4xZ68u2hI=; b=dcZoAKWsLsqOT9g3l2yFkjH68qLDy3T1Q5mldWlY6VqzIsbwZDQ1kNS2HY8Zmj4ykF a1xVRZwv283bKvHkyBbRWSyt8i6AJq66R0m9bJNVnDhkAcp95AlV3S3RJgI1iVZSC6kz 6RJvg0YmmvO/IwRjnxPYYfdZ9MaWOYNEEt0RWj8GKkaz3AU4VK2fLtSiHedngRsTBI5i i3H60gSnSsfCw+zVE3s6Djs6ySIte5KUyDxdoadFRYXDCpgVzy0yUwJVUq9uin3D+NrT S1fAa/ioVvJ8jLrp11gjwHSu4BDHEHGRnY4R8WaRcBMbMwXyIKaEmuw3gGkOAcKw75Gf rfXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534307; x=1712139107; 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=HCn0Z/+/hpHDPypDW2ERtEbkNmjR8TyLoR4xZ68u2hI=; b=KHAPvRXUembJixNoBGFxJMNmG/tjeZKe/ZZ81obi9xQVCSdOQ4gKd1cChBRxFnt71E HL2b+clvLzh/Kow6B6IwuJjLXmhOX+l7dW6zARlFQt1UuYpmtsddnoYv4CTkTuvjI/oM 43vStRrkiVQBeUKKtE/wLM//oGZG0C7lXMEGYJDLvIbKVfbj4JWBNwajZfF7sa+Y9/Z/ QKOzoNzfpOjBviqK9aaxfYh8eEAk56nUsGwVY86IiD5i14YBlQYffAxWidQUyfkWr7/e 1gV5/0IS9dGGgZApvd6J0uIBaQOB+nmg2FvhTiJLnkBdmkI6MHbZk3ajdzdhxVX6pWol IJpw== X-Gm-Message-State: AOJu0YxNsU3y0UCU5wM/rOtFAElZbqdDo1GMPKCg4623x8SX/I+GMxEW zBvfvfiEEGU/KlKPf1u4O6PaiTYbJ4gEc1sa+7wssmPQU6+pT7I7xe/9gLh2xO2nJgKrM6UKEon gvs0= X-Google-Smtp-Source: AGHT+IH/QjbfRPHF9gC0RokohkdQNcvzvvz3MWqzyovG8oRozWpVwuZiAS6PGE4N2tcZaVJPxjPn+A== X-Received: by 2002:a50:9547:0:b0:565:dfac:a686 with SMTP id v7-20020a509547000000b00565dfaca686mr2468401eda.38.1711534307591; Wed, 27 Mar 2024 03:11:47 -0700 (PDT) Received: from antares.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id dh16-20020a0564021d3000b0056c1c4b870asm2451653edb.16.2024.03.27.03.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:46 -0700 (PDT) From: =?utf-8?q?Christoph_M=C3=BCllner?= To: opensbi@lists.infradead.org, Philipp Tomsich , Cooper Qu , Zhiwei Liu , Huang Tao , Alistair Francis Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH 4/9] platform: generic: thead: Add CSR read handler for T-Head C9xx Date: Wed, 27 Mar 2024 11:11:32 +0100 Message-ID: <20240327101137.3644359-5-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327101137.3644359-1-christoph.muellner@vrull.eu> References: <20240327101137.3644359-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_031150_874088_A5B30FB8 X-CRM114-Status: GOOD ( 15.41 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: T-Head C9xx harts provide a TH_MXSTATUS CSR, that allows viewing the state of vendor extensions. Let's provide a mechanism to handle read requests to this CSR, where the actual value of the CSR is pro [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.45 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.45 listed in wl.mailspike.net] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org T-Head C9xx harts provide a TH_MXSTATUS CSR, that allows viewing the state of vendor extensions. Let's provide a mechanism to handle read requests to this CSR, where the actual value of the CSR is provided. Signed-off-by: Christoph Müllner --- platform/generic/include/thead/c9xx_csr.h | 16 ++++++++++++ platform/generic/thead/Kconfig | 4 +++ platform/generic/thead/objects.mk | 2 ++ platform/generic/thead/thead_c9xx_csr.c | 30 +++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 platform/generic/include/thead/c9xx_csr.h create mode 100644 platform/generic/thead/thead_c9xx_csr.c diff --git a/platform/generic/include/thead/c9xx_csr.h b/platform/generic/include/thead/c9xx_csr.h new file mode 100644 index 0000000..8740afa --- /dev/null +++ b/platform/generic/include/thead/c9xx_csr.h @@ -0,0 +1,16 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Authors: + * Christoph Müllner + */ + +#ifndef __RISCV_THEAD_C9XX_CSR_H____ +#define __RISCV_THEAD_C9XX_CSR_H____ + +struct sbi_trap_regs; + +int thead_c9xx_read_csr(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val); + +#endif // __RISCV_THEAD_C9XX_CSR_H____ diff --git a/platform/generic/thead/Kconfig b/platform/generic/thead/Kconfig index c50d38e..b20885c 100644 --- a/platform/generic/thead/Kconfig +++ b/platform/generic/thead/Kconfig @@ -1,5 +1,9 @@ # SPDX-License-Identifier: BSD-2-Clause +config THEAD_C9XX_CSR + bool "T-HEAD c9xx M-mode vendor CSR support" + default n + config THEAD_C9XX_PMU bool "T-HEAD c9xx M-mode PMU support" default n diff --git a/platform/generic/thead/objects.mk b/platform/generic/thead/objects.mk index 84f9faf..5606d36 100644 --- a/platform/generic/thead/objects.mk +++ b/platform/generic/thead/objects.mk @@ -5,6 +5,8 @@ # Copyright (C) 2023 Alibaba Group Holding Limited. # +platform-objs-$(CONFIG_THEAD_C9XX_CSR) += thead/thead_c9xx_csr.o + platform-objs-$(CONFIG_THEAD_C9XX_PMU) += thead/thead_c9xx_pmu.o platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_tlb_trap_handler.o diff --git a/platform/generic/thead/thead_c9xx_csr.c b/platform/generic/thead/thead_c9xx_csr.c new file mode 100644 index 0000000..155b3f3 --- /dev/null +++ b/platform/generic/thead/thead_c9xx_csr.c @@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Authors: + * Christoph Müllner + */ + +#include +#include +#include +#include +#include + +int thead_c9xx_read_csr(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val) +{ + int ret = 0; + + switch (csr_num) { + case THEAD_C9XX_CSR_MXSTATUS: + *csr_val = csr_read(THEAD_C9XX_CSR_MXSTATUS); + break; + + default: + ret = SBI_ENOTSUPP; + break; + } + + return ret; +}