From patchwork Wed Mar 27 10:11:29 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: 1916661 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=dAxUq5ik; 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=fpJKKtGG; 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 4V4MsY2VMTz1yXq for ; Wed, 27 Mar 2024 21:11:59 +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=hrq2lSha9F/lZ4/WsEB0WclLDFPckPEsAMy/be0j5Y4=; b=dAxUq5ikhPQV5a upi+5pcgQ0xLQaUzOV1ZUFx3UaeztrAis3Sz3e02Na6dGl27JNyXxy1ZTM53og0wybn7pHgNYdUGO /5ULxot7a5dUNq83q9lmL2mT1xtysCzT6VvgR4QNXs/pbbfbsTvuh6pqbeIoneEjghAZ4eYp0ZTWH wSzQ6RIbT1ZA3zCUb7Vgyy20WFrSXv7kBsNxiWyp49Euw+xWsaUqqi51ei1xNFxW9qE2AT4xi+kTt 2+SXmZYa9ibKSCT8bzse4u0zQHaV5jIS1tUagTUSoyBW5gNLlNwPdJiYXHtXmLGHgsSPfIpBWnZNm rGrMFxCavhfeXeCYUepw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG7-00000008MB5-3Tzj; Wed, 27 Mar 2024 10:11:51 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG2-00000008M8g-3rHr for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:49 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56c147205b9so1294078a12.0 for ; Wed, 27 Mar 2024 03:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534304; x=1712139104; 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=HXh4D9WbcqREhvV7IzjN/yaNphUlCFZDBPC/N6KbuIA=; b=fpJKKtGGVQINeiPskkD7/1+W7qlrQKIOsNUhd0Qsbd1+zCu5csfo9DdsyIvPzLcA+P 0VGHnOqEY9wOMRaunpqkWmCMhXVa5F+N8RBeY99pn4/X95R3x2XF10bwzVgWe8PduNt7 bEHZihoecuIWt0Rl8xovdGB/AtGDbYbgeiVAwuXMVpO8Cjt2CHadbd2KBkhjtlThG8BO IE13TXNZAsIL4EoDnxCT6REmyJHauegK7mr1V30QPBZ44X9JKBvc87VD2nkEXxbmHnCW sZYI9BapU10KhltknDZHfzXDqhTfGA0smnbWGLYq/z/+uLmCr7E2SFRfEIm4hg5wVBnn J2Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534304; x=1712139104; 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=HXh4D9WbcqREhvV7IzjN/yaNphUlCFZDBPC/N6KbuIA=; b=KjWRzRuWBn2mNcPbaCFP5OulMZUOZn2buHM3ZAQO6LF984wSXJoNqqXTusId19++V1 hh75OF6okkD+8UaR5JNouCpIMgCnLL3kmrBY5Cm2vjkL5u7r/xe5pKfknodTe/h4v+Wb ooFnrMT8Jx2SL21oP5yyICLbMzUTa/cotnDg59wgIf/JVmS1mGVrHKXQCNnjZqATRVft UQEN9H46ntNGqFHOOMBgHyrkO4AVoer1bMg+kFyeRdP8oUmEMZGZhOXYW1a/TbO1vLxZ tDgcdhw2fhGZzlix+oF1jZHp+n318xQByn48T7Sjt9+0j67/ltCj4xC7koziBOLVkBSH rsHQ== X-Gm-Message-State: AOJu0YxhTIf6d7G6chrAf/smxfaq8EQeXnqzLza2n05rCANqA9rHxJk2 +HALw8AlEeD/Vwosk0k1tiz84AU3rNUYP4zFW3pZ6dAR3l+G9e8mcO7cGeF9tfxTzP65O1XdtnN pVIw= X-Google-Smtp-Source: AGHT+IGXN1gXlOyahkSKD0cEFdMve+kE0cQ7/tUdm5QF2mZe4NK2O6F4VO2CrSFzOpR+JP7+vOQu0g== X-Received: by 2002:a50:9ec3:0:b0:56b:aa17:813a with SMTP id a61-20020a509ec3000000b0056baa17813amr3254221edf.21.1711534303935; Wed, 27 Mar 2024 03:11:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:43 -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 1/9] sbi_platform: Add mechanism to handle CSR reads/writes in platform Date: Wed, 27 Mar 2024 11:11:29 +0100 Message-ID: <20240327101137.3644359-2-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_031147_057144_A0FDAA23 X-CRM114-Status: GOOD ( 11.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__Platforms_may_want_to_provide_access_t?= =?unknown-8bit?q?o_custom_CSRs=2E_Let=27s?= =?unknown-8bit?q?_add_a_layer_that_allows_platforms_to_implement_CSR_read/wr?= =?unknown-8bit?q?ite_handlers=2C_where?= =?unknown-8bit?q?_custom_CSRs_can_be_accessed=2E_Signed-off-by=3A_Christoph_?= =?unknown-8bit?q?M=C3=BCllner_=3Cchristoph=2Emuellner=40vrull=2Eeu=3E?= =?unknown-8bit?q?_---_include/sbi/sbi=5Fplatform=2Eh_=7C_48_++++++++++++++++?= =?unknown-8bit?q?++++++++++++++++++++++?= =?unknown-8bit?q?_1_file_changed=2C_48_insertions=28+=29_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-0=2E2_points=2C_5=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MzUgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= 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 Platforms may want to provide access to custom CSRs. Let's add a layer that allows platforms to implement CSR read/write handlers, where custom CSRs can be accessed. Signed-off-by: Christoph Müllner --- include/sbi/sbi_platform.h | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 581935a..5dbbfea 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -148,6 +148,12 @@ struct sbi_platform_operations { /** platform specific handler to fixup store fault */ int (*emulate_store)(int wlen, unsigned long addr, union sbi_ldst_data in_val); + /** Platform-specific handler to read custom CSRs. */ + int (*read_csr)(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val); + /** Platform-specific handler to write custom CSRs. */ + int (*write_csr)(int csr_num, struct sbi_trap_regs *regs, + ulong csr_val); }; /** Platform default per-HART stack size for exception/interrupt handling */ @@ -728,6 +734,48 @@ static inline int sbi_platform_emulate_store(const struct sbi_platform *plat, return SBI_ENOTSUPP; } +/** + * Ask platform to read from CSR. + * + * @param plat pointer to struct sbi_platform + * @param csr_num CSR number + * @param regs Pointer to register state + * @param csr_val Pointer where the read value will be stored + * + * @return 0 on success and negative error code on failure + */ +static inline int sbi_platform_read_csr(const struct sbi_platform *plat, + int csr_num, + struct sbi_trap_regs *regs, + ulong *csr_val) +{ + if (plat && sbi_platform_ops(plat)->read_csr) + return sbi_platform_ops(plat)->read_csr(csr_num, regs, csr_val); + + return SBI_ENOTSUPP; +} + +/** + * Ask platform to write to CSR. + * + * @param plat pointer to struct sbi_platform + * @param csr_num CSR number + * @param regs Pointer to register state + * @param csr_val Value to write + * + * @return 0 on success and negative error code on failure + */ +static inline int sbi_platform_write_csr(const struct sbi_platform *plat, + int csr_num, + struct sbi_trap_regs *regs, + ulong csr_val) +{ + if (plat && sbi_platform_ops(plat)->write_csr) + return sbi_platform_ops(plat)->write_csr(csr_num, regs, csr_val); + + return SBI_ENOTSUPP; +} + #endif #endif From patchwork Wed Mar 27 10:11:30 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: 1916664 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=XWx6Kkhm; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=LRD+V2M1; 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=Ifva4PAF; 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 4V4Msd6LnDz1yXq for ; Wed, 27 Mar 2024 21:12:05 +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=kvhYfZ62KH1F6ZpsrgMCGVqaP7q+XNDNT0yc2LSWJvA=; b=XWx6KkhmXVuLxh Ti5w3EiO760y82Od72NOL1HnJ+hhikonZ2mIa2wca3ifAJXu4D99k0kVLnJFTBlVICH+OcDC8xphn 6LL3agO/ASzCR8A1G2XjmCDer7maKABJU2H+7cEdz3zdeJQ/L8nm6+WuB0tsdUn1koylu+ElV3GNQ 6E9Ew8/YHkZ1whj6At2I8EXVEJMs90A/Ny0yh9tSXtg8RYgc2k/KYlSj6ENn8UgcV/6Fq9fWK3+wl ZU6asuA94zcd+4VeV8BydjzQzkI7RaPXD06fCK3kkqCeSc3EbqukZX6D5g5taay2t0qbj8NhYmL/D q3GEjK+Rr4eYqzSWbY1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGD-00000008MFI-2Kn1; Wed, 27 Mar 2024 10:11:57 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGB-00000008MCu-0meo for opensbi@bombadil.infradead.org; Wed, 27 Mar 2024 10:11:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=KDmDl/1PKT+igpYbEhegBIxLzOiwrzrRPLnM7H4bwm0=; b=LRD+V2M1m58k7Qsy5gaIEQNna4 ll9Jgp1TFcHhVWwEoSlXXDKrikw6yErolMPnHTLAoP0hPmrQl9fvO5lhaBm+qFq+eDhJPtDE2Pw0l TLcqJ5AEUuskW2SrIbL6zg74BET6f+xo/z+Z83RiXo7moolVsWYTQkePGDD27am/fn4B5g2RX87YQ Y1PYr5CoWR1onGxDyieC4eQFRnC5u5PKlc1uQJpvuk6ljj4Swh3Tl9YGQDhq/4XeThXM4wePvWZkH 5K/e8MMlYQ7EQ3bkQoBEc6WNc4HUoUdX8kD8dydzmXqDXQeCTIyYuoprFRBNvAB0crZdcZkPtS2G6 +nWgYpMA==; Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG4-00000000AE9-2Dgz for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:51 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a46de423039so376423066b.0 for ; Wed, 27 Mar 2024 03:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534305; x=1712139105; 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=KDmDl/1PKT+igpYbEhegBIxLzOiwrzrRPLnM7H4bwm0=; b=Ifva4PAFlqy6WIqfnI6HtXxsigQm290STITHaAVEUzfs7G1kbfPL3P28OIfz/Oa14J 8SiVaGzDq14uDtNJAILL92ercnZI3LjYlcecJGLnXg9qI1OoY/fOcaMmJGLTEwBjIJKr xEBVs61eoFb0mtbzA7RTC8eBoM5coYRlavsJqseMGsHdWT5I2efAzbU6VRIlxcAUoaLi TVbkd1Q7tGP/FWyd3zDSN47OYdPHCu5U5MvTK5fhE2YzmN0Qb3gTFHZrVUFXUVuC44Fk zBo5z47PyuzCXlY1AOlU6U1Pvxyj6cotpK0+S4ufxZf4tY7qgCiXD6NjYczZ8BgPvfs3 2OGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534305; x=1712139105; 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=KDmDl/1PKT+igpYbEhegBIxLzOiwrzrRPLnM7H4bwm0=; b=HIPfi5JZgLzAt5slAMUaA5W9frWjP+UXzEw4l4Y+Y5xK7ZCpSPyGgp1Wf6dwBPWiHv yQmJsrwiL1goTJHT/3QnP3firQHGenTi+Tnooqa/c1IK08bYvRY0h0Anv5xi3gKiTEOI 9HCFSG6BxZtC09kma9u1venhYbvBnEYHr0V0r9mKnbdzKpphJHhx2b4AcbScsvYnHPBA yrYUvXeyrM+R9Z/2MqK9plZvQPQzQTtn42VrcqYZRCiXKqd137dg5y5wI3QHuLctz+oG MwiEC6xB/d4UZ1L3cal39UGa/Q8JAgSMmJtmoz0Nwl1b6ZyrOQszdlXITp/t+f8tYyyv uAaw== X-Gm-Message-State: AOJu0YxsBTX7qPbyRixekrw++shRJfkNWlKBqUSLRJsGb+enRijs37tH FQief0dweoMaaP5sW0LujV0xMMfrm11wGd8yxGj4hTt79ORkwqpzP4iOqigtu+bLT/UsV6rCl68 IVHA= X-Google-Smtp-Source: AGHT+IEBNjKgESYF86f9EukHDiN2sOGOmlYratxBxPptwLWPauL/m5Bqk2QDZyvu5IQ1js8d6UTMZw== X-Received: by 2002:a50:d61b:0:b0:56b:a8ea:9642 with SMTP id x27-20020a50d61b000000b0056ba8ea9642mr2212446edi.14.1711534305127; Wed, 27 Mar 2024 03:11:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:44 -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 2/9] platform: generic: Add mechanism to handle CSR reads/writes in overrides Date: Wed, 27 Mar 2024 11:11:30 +0100 Message-ID: <20240327101137.3644359-3-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_101149_389519_FF0B8066 X-CRM114-Status: GOOD ( 11.33 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: Overrides may want to provide access to custom CSRs. Let's add a layer that allows platform overrides to implement CSR read/write handlers, where custom CSRs can be accessed. This utilizes the corresp [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:633 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Overrides may want to provide access to custom CSRs. Let's add a layer that allows platform overrides to implement CSR read/write handlers, where custom CSRs can be accessed. This utilizes the corresponding platform hooks to access CSRs. Signed-off-by: Christoph Müllner --- platform/generic/include/platform_override.h | 4 ++++ platform/generic/platform.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index b0585c2..6802126 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -34,6 +34,10 @@ struct platform_override { struct sbi_trap_regs *regs, struct sbi_ecall_return *out, const struct fdt_match *match); + int (*read_csr)(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val); + int (*write_csr)(int csr_num, struct sbi_trap_regs *regs, + ulong csr_val); }; #endif diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 1f46b76..07fa9cc 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -273,6 +273,24 @@ static int generic_vendor_ext_provider(long funcid, generic_plat_match); } +static int generic_read_csr(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val) +{ + if (generic_plat && generic_plat->read_csr) + return generic_plat->read_csr(csr_num, regs, csr_val); + + return SBI_ENOTSUPP; +} + +static int generic_write_csr(int csr_num, struct sbi_trap_regs *regs, + ulong csr_val) +{ + if (generic_plat && generic_plat->write_csr) + return generic_plat->write_csr(csr_num, regs, csr_val); + + return SBI_ENOTSUPP; +} + static void generic_early_exit(void) { if (generic_plat && generic_plat->early_exit) @@ -408,6 +426,8 @@ const struct sbi_platform_operations platform_ops = { .timer_exit = fdt_timer_exit, .vendor_ext_check = generic_vendor_ext_check, .vendor_ext_provider = generic_vendor_ext_provider, + .read_csr = generic_read_csr, + .write_csr = generic_write_csr, }; struct sbi_platform platform = { From patchwork Wed Mar 27 10:11:31 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: 1916665 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=2oSBwTf8; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=T58UkQs8; 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=qJsiVjQZ; 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 4V4Msd6lMXz1yYW for ; Wed, 27 Mar 2024 21:12:05 +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=T5335Pmcv0Et1wDREp1++mH4X4nDTWc9Od6WxdKka0U=; b=2oSBwTf8pNqwpT 3NnKi9BIu3go80z8cdX2smLADKBWOweoCy39sk7ipCkeyj07TW8K8QmvZnjeUjdD9HkMTz7N3Cr9V hvP/H23+7igTexhx0nwE9CPmTe4wYLA2k+S/MATLzIntKbL1e9k+GLAI8E7B7AXs9ScfCOdlah2gw KPPFANo0J921HsLWvUYeEzacxUQnlKRPX5vtGlX4LDBF+cassrAqVWDt/QGZIQ5w0jRsqo0tnCAaP CbgsfVdC5+3bCTPEFUAJaVpFto1UsTR/oB4jYBbilpfi5NUHT9GENf5/8pUWwbsXb4aSAkDOqKn/+ lIXls8x1UZzsVfHrlScg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGE-00000008MG8-3Jt8; Wed, 27 Mar 2024 10:11:58 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGB-00000008MDJ-1ldr for opensbi@bombadil.infradead.org; Wed, 27 Mar 2024 10:11:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=s2rS3JcA0EXzqCvZjEhzySeQxDDQMRv/EcVFCgBVLVc=; b=T58UkQs8iJ6mibtp6ROFPvZT7H r4fHlvSsgMU8MarNTM23hNKFD2YCM0zk+cmGvcAX0N61GSxjXbTvY3Gy4raldX3F6bFQBmm7XDBlr uvE+JWDTHLaZtcaetN5PlephsqrNHoBGrWyI7RHd70q6PcbXBG8HGwc8h1tO6tUJr+PYyDLm4P2uq zDBS6qDgmC4Vz9r+NVQ0gizDyxpufM0yzFHOsqEqWecLi/UYDdp6XXkDul8rcmYvub0KAWl3xzX1r Jswj/7PKn/SfjYGbOmcER0BmKmZCjWCwbhYQi8ANj5i5zGys03DP/uxbnQGfdI9CbFG14TR8SwHFa bd8VEZHw==; Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG5-00000000AEB-0Q0u for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:52 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-515a97846b5so3835837e87.2 for ; Wed, 27 Mar 2024 03:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534306; x=1712139106; 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=s2rS3JcA0EXzqCvZjEhzySeQxDDQMRv/EcVFCgBVLVc=; b=qJsiVjQZTP/hkkJn2iKgTQGM28B3OhhKPS0A0DUNitUYOOaynaN0U0Z3I0P+j2PScF 9ITpsiAg5XhQV82YiX7839lUMf5mdBGN1idxb+yOwIGa2MimV8heYkj9MMk0XHv+9YOP l3xYUBWfzrOiCSfqLkZNpKGBYWLdKll25cj2Y2Fb63tTRlzv6LYHRXuU3oQELbmkxcGP dzHgiqzluLPVVugLg8ClZYtCuNprMyqNu7njIFx33WbpZ81lsbMbj1eFrOI+PUMUXmeo NCox9oFQXs2VcZT3W6JH0dAabL7NoxbPJOJpzJqjXdnkt/p0bEGMDwDFNE6FcMdjx0TX k7mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534306; x=1712139106; 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=s2rS3JcA0EXzqCvZjEhzySeQxDDQMRv/EcVFCgBVLVc=; b=UpHXKDj011w05bixYsM3GskCGMbV/e8HXLQZ5yG/45Ds9zjNsovRyjj4hixDaMLcyC RbU3HJrkccan9GHVte/CBciPM1f622BjxJhAPJcY3AYA8APg8vQYo/5HsnYk/cpwo4Qy XckJCRPxNE5e1mdQlQnVHXC+k0HHSnDOFObpueIQik9FO1eJgA9t2lOt+SQs0FTZBmtO UAAuOkrgkz/4uxJ6VugrzeMSpMgAMNqHrAhT6ENeMZiW8ZcNrwYAbZUH9CN+7aifbOU9 l9gX451FoIuWiDvTirnnZKFmd8VTITeNHVSRZb4k+9T+eHT6nPVeBxUiYP5W+3YF2npk aXlg== X-Gm-Message-State: AOJu0YxkgaiKd4eod8LFy0xR4TwmKJnP8IoXNZHV0eYK8nX234QXgwzs gBR26yCdzc7tXMMKera1g7dby3rII5mKtJQjytuRXWWScHj/bmJZhqL0sLSS5B5Ener3eTqSxbd 4NX4= X-Google-Smtp-Source: AGHT+IH4t2VgWGwoALvxfY/+P1LtoOMtb3km07ag4q+8E9FyFvurJgSp2MsFYRqhDzojeP83YlbmdQ== X-Received: by 2002:ac2:5b43:0:b0:513:c957:ea4d with SMTP id i3-20020ac25b43000000b00513c957ea4dmr532810lfp.43.1711534306354; Wed, 27 Mar 2024 03:11:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:45 -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 3/9] lib: sbi_emulate_csr: Utilize platform hooks for unknown CSRs Date: Wed, 27 Mar 2024 11:11:31 +0100 Message-ID: <20240327101137.3644359-4-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_101149_700770_EA339481 X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: In case we trap during CSR accesses, we have a few defined CSRs that are gracefully emulated. In case we don't know what to do with an unknown CSR, let's give the platform a chance to handle the CSR a [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:134 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 In case we trap during CSR accesses, we have a few defined CSRs that are gracefully emulated. In case we don't know what to do with an unknown CSR, let's give the platform a chance to handle the CSR access. Signed-off-by: Christoph Müllner --- lib/sbi/sbi_emulate_csr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sbi/sbi_emulate_csr.c b/lib/sbi/sbi_emulate_csr.c index 5f3b111..a6cb855 100644 --- a/lib/sbi/sbi_emulate_csr.c +++ b/lib/sbi/sbi_emulate_csr.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -147,7 +148,8 @@ int sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs, #undef switchcase_hpm default: - ret = SBI_ENOTSUPP; + ret = sbi_platform_read_csr(sbi_platform_ptr(scratch), + csr_num, regs, csr_val); break; } @@ -162,6 +164,7 @@ int sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs, ulong csr_val) { int ret = 0; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); ulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; #if __riscv_xlen == 32 bool virt = (regs->mstatusH & MSTATUSH_MPV) ? true : false; @@ -185,7 +188,8 @@ int sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs, break; #endif default: - ret = SBI_ENOTSUPP; + ret = sbi_platform_write_csr(sbi_platform_ptr(scratch), + csr_num, regs, csr_val); break; } 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; +} From patchwork Wed Mar 27 10:11:33 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: 1916708 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=Xe1WtBB6; 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=GFke8No/; 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 4V4PL80x3Zz1yWr for ; Wed, 27 Mar 2024 22:18:21 +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=tMrCCgPkBgGvRWz1kjm/f1OuUbIQfzeQqGZI46Ti45k=; b=Xe1WtBB6n/Z7FE iI/rMXYV3bOcuRKulrLR0m3jtqF3QmP3O2k0ojiYq9utYFdId9zMAgWQHmfZIKKT2YfPYbqcFWFY2 3YIZQeDagbStqNYxMbibY714U6QSXqWCMGNvTc5/D0lzyFa10mvFexRJJKVrkrgkClbt7DKnv5EEf NrTIfPs3/ks++Dw3fw9bb5/Cth0LrzyOAEZ3AldepaFP4l+lvQiioVaAh0iYrfzXyDzsD7iebbJJQ 5BTipINsBiBU6Lrsy2gtTuzMcgLBMurWLu+fhRsfDtkMtulTomeGO0buJVerfJI2Hp+AB2npZSDHp MM9wfGjbr3UaMutZCvww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpRIL-00000008ZyD-1gBE; Wed, 27 Mar 2024 11:18:13 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG7-00000008MAC-37P7 for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:53 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-56c404da0ebso451165a12.0 for ; Wed, 27 Mar 2024 03:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534308; x=1712139108; 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=4PoST6u2Srw27wTD2+rfPIihzdC0gxx+S5c1AsVVK9A=; b=GFke8No/B7xI9NZw5VW1fVZYfqolFfJomtug0S+4dHyNJH4Ob87OIo/eY+TwmQx1+J rF/hiinFoLqByvrXonrYo9I+lHMz0BA0vWMwOIGMRSUTWcuK1N6PcuQGgdFse/Y8QsnA WDKQxp8TPDYRigILLruuwAAuy47JWX2hqHOg1blTmNguG+hqrLcQTkt8dtGPLsUyXDUg h7fIAtOi2y09dSB28JoxXT084gZ54zNn4ni1rCLb9N6j7sIOYnyKuEVLpJ/8lBnUSPlR n2QHyCSd+9+VEzZrZVjeMIb6QHkfGNEPWtEHvzcG7v0Djw5n//etvN5GZFv/vWq3vCUU yg8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534308; x=1712139108; 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=4PoST6u2Srw27wTD2+rfPIihzdC0gxx+S5c1AsVVK9A=; b=hN6JZ00erekSaJIbqXLt7VIqY4wIgkKLeGtBfMN9RRoJVZt3zwcddmv4MHRWxjYAA7 iTriHwCAUquk/1SjpxrY13FrgGlMiRqAGe+yMaOccJTNZQRuFRi3dhIEm2w30F3+cQzR BNwpA/+WFmhFDu3LnFaGQdZXxe+vWzpnOb3iu8ODcjJ52gBZlRLvO5xG7iwT7LBuvy+B J2lxmTurpKwNVjIIIVDi0CB2+iESS4t8uVQ3iBMdv6pYnEM1MzxyuGWbLAv/mPVMFT9O Mo1K+7x9ls3aItfcIXwwS/eAsvAJReiaGsle7z4vGYXjj7O0iD14uh9byOiFtX34h808 XwNA== X-Gm-Message-State: AOJu0YzBA4DE3jIhW5tMpd0HSoutnfOvkhYNRQ3bC0mrK35di2oFHEu9 LZkbLN/A+58jnTP6S/q7GNp0UqePIGBCQqQfH16smCaqEnLrFCpFYNhgDJGBeoS/44y0Eqw+uHK MErw= X-Google-Smtp-Source: AGHT+IGSChDe8lXwwRFkacgzVVLNebPDx4aloccIDyoqd7LrCdx7pj3wmV6kUdwqSXntxo9u+jKqDw== X-Received: by 2002:a50:8a89:0:b0:56c:d33:7881 with SMTP id j9-20020a508a89000000b0056c0d337881mr3926252edj.23.1711534308698; Wed, 27 Mar 2024 03:11:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:48 -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 5/9] {allwinner/sun20i-d1,sophgo/sg2042,thead-generic}: Enable T-Head CSR read access Date: Wed, 27 Mar 2024 11:11:33 +0100 Message-ID: <20240327101137.3644359-6-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_031151_888237_4F7C8B5D X-CRM114-Status: UNSURE ( 9.71 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__Let=27s_enable_the_T-Head_CSR_read_han?= =?unknown-8bit?q?dler_for_all_platform-overrides?= =?unknown-8bit?q?_that_include_a_T-Head_hart=2E_Signed-off-by=3A_Christoph_M?= =?unknown-8bit?q?=C3=BCllner_=3Cchristoph=2Emuellner=40vrull=2Eeu=3E?= =?unknown-8bit?q?_---_platform/generic/Kconfig_=7C_3_+++_platform/generic/al?= =?unknown-8bit?q?lwinner/sun20i-d1=2Ec?= =?unknown-8bit?q?_=7C_2_++_platform/generic/sophgo/sg2042=2Ec_=7C_2_++_platf?= =?unknown-8bit?q?orm/gene_=5B=2E=2E=2E=5D_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-0=2E2_points=2C_5=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MzQgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= 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 Let's enable the T-Head CSR read handler for all platform-overrides that include a T-Head hart. Signed-off-by: Christoph Müllner --- platform/generic/Kconfig | 3 +++ platform/generic/allwinner/sun20i-d1.c | 2 ++ platform/generic/sophgo/sg2042.c | 2 ++ platform/generic/thead/thead-generic.c | 2 ++ 4 files changed, 9 insertions(+) diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig index c9b6011..82024a5 100644 --- a/platform/generic/Kconfig +++ b/platform/generic/Kconfig @@ -26,6 +26,7 @@ config PLATFORM_GENERIC_MINOR_VER config PLATFORM_ALLWINNER_D1 bool "Allwinner D1 support" depends on FDT_IRQCHIP_PLIC + select THEAD_C9XX_CSR select THEAD_C9XX_PMU default n @@ -53,6 +54,7 @@ config PLATFORM_SIFIVE_FU740 config PLATFORM_SOPHGO_SG2042 bool "Sophgo sg2042 support" + select THEAD_C9XX_CSR select THEAD_C9XX_ERRATA select THEAD_C9XX_PMU default n @@ -63,6 +65,7 @@ config PLATFORM_STARFIVE_JH7110 config PLATFORM_THEAD bool "THEAD C9xx support" + select THEAD_C9XX_CSR select THEAD_C9XX_ERRATA select THEAD_C9XX_PMU default n diff --git a/platform/generic/allwinner/sun20i-d1.c b/platform/generic/allwinner/sun20i-d1.c index ed19d5d..79bfe8b 100644 --- a/platform/generic/allwinner/sun20i-d1.c +++ b/platform/generic/allwinner/sun20i-d1.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -238,4 +239,5 @@ const struct platform_override sun20i_d1 = { .final_init = sun20i_d1_final_init, .fdt_fixup = sun20i_d1_fdt_fixup, .extensions_init = sun20i_d1_extensions_init, + .read_csr = thead_c9xx_read_csr, }; diff --git a/platform/generic/sophgo/sg2042.c b/platform/generic/sophgo/sg2042.c index ae2d702..86c498e 100644 --- a/platform/generic/sophgo/sg2042.c +++ b/platform/generic/sophgo/sg2042.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -60,4 +61,5 @@ const struct platform_override sophgo_sg2042 = { .match_table = sophgo_sg2042_match, .early_init = sophgo_sg2042_early_init, .extensions_init = sophgo_sg2042_extensions_init, + .read_csr = thead_c9xx_read_csr, }; diff --git a/platform/generic/thead/thead-generic.c b/platform/generic/thead/thead-generic.c index 72f4aaa..5771642 100644 --- a/platform/generic/thead/thead-generic.c +++ b/platform/generic/thead/thead-generic.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -50,4 +51,5 @@ const struct platform_override thead_generic = { .match_table = thead_generic_match, .early_init = thead_generic_early_init, .extensions_init = thead_generic_extensions_init, + .read_csr = thead_c9xx_read_csr, }; From patchwork Wed Mar 27 10:11:34 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: 1916666 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=ha5rEnMI; 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=joaSZJhK; 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 4V4Msh6Rxwz1yXq for ; Wed, 27 Mar 2024 21:12:08 +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=Ck17OMUPD/BQUEgIuy2DN7DnYZ4lS9NEKfCsnvhPqx0=; b=ha5rEnMI19Lmjl HHv4nab6bW+04bpsy7JX/YpJAOYRXj5ZfZLPQ6xFn4XDcKie388F6l0uaBJ78oC6vnRwtQFNliHxD mz6HgN1UpqyWymAwOusQrdBrXWFa+GPRjJ242WUqFDY7e0LNEu6QugPyLtNnpPSt6ZqE7e2cOsgC+ 7Us9mUL1+IctnEbFDdK8QjZ/jEWDiSXu8FG14b4FMpvfjZ9lAJE7MWwPEx73G8PVMyf5PNk6nPhhD lwXO4QmnVjG9+wWab9xi1p7jIAtbwtUlM4vMPxF7r5pg02oFJFgSs+LMfv+lEw3FATDV/X0zixBDr 1fVANXekP9NiJkXhKoIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGG-00000008MHY-2iUA; Wed, 27 Mar 2024 10:12:00 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG9-00000008MAp-24M7 for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:55 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-512bde3d197so4712235e87.0 for ; Wed, 27 Mar 2024 03:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534310; x=1712139110; 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=5UGfDYnwWheyskp5xuVjFpUhRNw+bSHKh1HOHUEWBPM=; b=joaSZJhKPwmfqZel0WlMAQbH1vM194HldMFH2dix7wpGyX760Lb+oIGVZi4I9QPs6A LHtEte+IC6Fh2XAU1XsUNoDf+xiWTZWq5vM/dDYnFCfjCS9ffiCJSQ3PP+INYhxSWw0d gSQt2jJv78/8PScnF5VeWPue3/9wL2Tv4zGzw/hnV76DhHwKc84KqGgaiI54JzdUkXYV DBvyHy/Wu0GmRFSnLVD0Vzs0/deQmDd60kJB+YeINC0rnW6i6Rf4DAc90fCVIdCV+YOE YrpAcpW0Prcy5whKDikyD2AsdBTDcpY2RXYWos5p6o6Ps2SPTcjNbaw0DY5fWPIzdtKs r87w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534310; x=1712139110; 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=5UGfDYnwWheyskp5xuVjFpUhRNw+bSHKh1HOHUEWBPM=; b=Dkow0jCXcsLonn8preVtTTeKz7cfMlk88dBdKEUYr1ChlTbZ+wo6EanIFsASazgLAb 3dLl8QKGmEOyX+bN+QZk/zVunPt6JHgQZunjFxPYXYdQFB4GX+dBpqlAYe2mEkC/DtXC RMd+I1mUJJUHj9r238KVjUHtBHfSYR5SYJlR/g/mgWkKLOH6/Dnb9BErzkE7E7ynapBP MkXR6VmIjiqSI4KEdnKmxwy7FkrYrf09lpdj0B4YjMDVPHqcagmciiSQGIcUzaOfi8IL ffmxqjhT6RLFzExCYoNldnFRHGviXxTiw3yo20Nqc7XxLsWjIycv7V1eXFFNE64BaMyU RB/Q== X-Gm-Message-State: AOJu0YyRTWcYWtvm2MZc9FVzpqcIuUxOGEZ7QSn7jbTSPzFjoinoUHVI JcakqYjeGsAUnFoUaFBH4fP7yQOJ7fl24j6Wbfthw1aVde3TdMPquiKNJl7mPJY+UkHwF4y6T1/ SA6Q= X-Google-Smtp-Source: AGHT+IFx0wspulT2KOGK8hrz34H2RCepZFL/nrZzZsOFbaAQ1haWZivDnKmgVai4emOMbzcvlU1+hA== X-Received: by 2002:a19:7706:0:b0:513:df6:dcd3 with SMTP id s6-20020a197706000000b005130df6dcd3mr605665lfc.48.1711534309896; Wed, 27 Mar 2024 03:11:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:49 -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 6/9] platform: thead: Rename thead-generic to thead-th1520 Date: Wed, 27 Mar 2024 11:11:34 +0100 Message-ID: <20240327101137.3644359-7-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_031153_684542_A6AEE12C X-CRM114-Status: GOOD ( 12.31 ) 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: The name generic is misleading since the compatible string list only has a single entry for the TH1520 ('thead,th1520'). Further, thead-generic is irrelevant for other platforms that include a T-Head [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:135 listed in] [list.dnswl.org] -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 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 The name generic is misleading since the compatible string list only has a single entry for the TH1520 ('thead,th1520'). Further, thead-generic is irrelevant for other platforms that include a T-Head CPU (e.g. the Allwinner D1). Therefore, let's rename thead-generic to thead-th1520. Signed-off-by: Christoph Müllner --- platform/generic/Kconfig | 4 ++-- platform/generic/configs/defconfig | 2 +- platform/generic/thead/objects.mk | 4 ++-- .../thead/{thead-generic.c => thead-th1520.c} | 20 +++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) rename platform/generic/thead/{thead-generic.c => thead-th1520.c} (61%) diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig index 82024a5..6d85e51 100644 --- a/platform/generic/Kconfig +++ b/platform/generic/Kconfig @@ -63,8 +63,8 @@ config PLATFORM_STARFIVE_JH7110 bool "StarFive JH7110 support" default n -config PLATFORM_THEAD - bool "THEAD C9xx support" +config PLATFORM_THEAD_TH1520 + bool "T-HEAD TH1520 support" select THEAD_C9XX_CSR select THEAD_C9XX_ERRATA select THEAD_C9XX_PMU diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig index 1ce6a12..52ec0f6 100644 --- a/platform/generic/configs/defconfig +++ b/platform/generic/configs/defconfig @@ -5,7 +5,7 @@ CONFIG_PLATFORM_SIFIVE_FU540=y CONFIG_PLATFORM_SIFIVE_FU740=y CONFIG_PLATFORM_SOPHGO_SG2042=y CONFIG_PLATFORM_STARFIVE_JH7110=y -CONFIG_PLATFORM_THEAD=y +CONFIG_PLATFORM_THEAD_TH1520=y CONFIG_FDT_GPIO=y CONFIG_FDT_GPIO_DESIGNWARE=y CONFIG_FDT_GPIO_SIFIVE=y diff --git a/platform/generic/thead/objects.mk b/platform/generic/thead/objects.mk index 5606d36..42f1f53 100644 --- a/platform/generic/thead/objects.mk +++ b/platform/generic/thead/objects.mk @@ -12,5 +12,5 @@ platform-objs-$(CONFIG_THEAD_C9XX_PMU) += thead/thead_c9xx_pmu.o platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_tlb_trap_handler.o platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_errata_tlb_flush.o -carray-platform_override_modules-$(CONFIG_PLATFORM_THEAD) += thead_generic -platform-objs-$(CONFIG_PLATFORM_THEAD) += thead/thead-generic.o +carray-platform_override_modules-$(CONFIG_PLATFORM_THEAD_TH1520) += thead_th1520 +platform-objs-$(CONFIG_PLATFORM_THEAD_TH1520) += thead/thead-th1520.o diff --git a/platform/generic/thead/thead-generic.c b/platform/generic/thead/thead-th1520.c similarity index 61% rename from platform/generic/thead/thead-generic.c rename to platform/generic/thead/thead-th1520.c index 5771642..86c265f 100644 --- a/platform/generic/thead/thead-generic.c +++ b/platform/generic/thead/thead-th1520.c @@ -16,14 +16,14 @@ #include #include -struct thead_generic_quirks { +struct thead_th1520_quirks { u64 errata; }; -static int thead_generic_early_init(bool cold_boot, +static int thead_th1520_early_init(bool cold_boot, const struct fdt_match *match) { - struct thead_generic_quirks *quirks = (void *)match->data; + struct thead_th1520_quirks *quirks = (void *)match->data; if (quirks->errata & THEAD_QUIRK_ERRATA_TLB_FLUSH) thead_register_tlb_flush_trap_handler(); @@ -31,25 +31,25 @@ static int thead_generic_early_init(bool cold_boot, return 0; } -static int thead_generic_extensions_init(const struct fdt_match *match, +static int thead_th1520_extensions_init(const struct fdt_match *match, struct sbi_hart_features *hfeatures) { thead_c9xx_register_pmu_device(); return 0; } -static struct thead_generic_quirks thead_th1520_quirks = { +static struct thead_th1520_quirks thead_th1520_quirks = { .errata = THEAD_QUIRK_ERRATA_TLB_FLUSH, }; -static const struct fdt_match thead_generic_match[] = { +static const struct fdt_match thead_th1520_match[] = { { .compatible = "thead,th1520", .data = &thead_th1520_quirks }, { }, }; -const struct platform_override thead_generic = { - .match_table = thead_generic_match, - .early_init = thead_generic_early_init, - .extensions_init = thead_generic_extensions_init, +const struct platform_override thead_th1520 = { + .match_table = thead_th1520_match, + .early_init = thead_th1520_early_init, + .extensions_init = thead_th1520_extensions_init, .read_csr = thead_c9xx_read_csr, }; From patchwork Wed Mar 27 10:11:35 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: 1916669 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=1pwEX9Pq; 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=E/vO39Y1; 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 4V4Msn3P12z1yXq for ; Wed, 27 Mar 2024 21:12:13 +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=MFcpQz6UWFOxI3chpU0YKa9Jk8GU8UP2Kkp3DBIHoMU=; b=1pwEX9Pq4WEOzu WWDZ7UaZTn7aU++wI87jj/cxaLhZeIWfr0hskjV1iqABpK+5HG+3JedKriUHOYVA49sy1mEt82dzn X2A59Si7laM/LqVEC7OjogLTREBlU/a1Ni9f8ivO7sVuCCSw27IorgZXIW0CsVN4+oO9SYQ3dOB8z /Y0BYv4MNdkD39taS3EGA6tzIGHC/I4INNSA7uT/9WGdS1TR0uf5q7K4Av67s9+0KD/SD9PTEqF9c AkYiUkAYRlLL5KYPXDjD3puiqU7bWEpdlXedcCvAtD5UwCBgta5fCPAH+QheoHLOrJ/he93JApdhx n+7zm1Pgoe5m1oZqgrKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGM-00000008MNA-21tD; Wed, 27 Mar 2024 10:12:06 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGF-00000008MBa-1FhK for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:12:01 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-56c3260a714so1492861a12.3 for ; Wed, 27 Mar 2024 03:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534311; x=1712139111; 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=97mocttYjcPIhfxpasXu6ExFH33zR2YkTIDU0krs8os=; b=E/vO39Y1xgjjUKLGcTRxmIzVfoRbvLLePuf2e9feS798fgs7k15+q6g+epT3zQb8Xs 0moQltODVW4/CHeSy9JeTCrNUZHrJrNd6/q+JqhtPY5ylHh+U+Qg1ZbcgieMJYHdRCJk zQZJVez1h0TV4eu7moZQNBgDcylGCM4znSqV92L8dlG7uEDmlVPJF1HFndO5lklQhTZZ Ru1aQWRrCVPQjZ/kyysbK58ERlNhzAysKnkq4rLdiF8A41HUhOVXpEmStLZRDwRPHWVH nYknzM9QF3N6QwWL1OJqW49Xyqz23krt19mv+LqOh5MWPHcR6hSnhqyEHpdUrsz+ZM+8 doMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534311; x=1712139111; 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=97mocttYjcPIhfxpasXu6ExFH33zR2YkTIDU0krs8os=; b=N9Vo77z/KEJ5LTPe5C19Gs2WyFD0KmylUI052iDG2pNCMUrXMv30gE8CQXeesllEBd dPMJglMyD/cm9dnNDCv8Wi0ie75iy+blhJhdA0BD0G2iofl8mjeRoZyqsqQZJD0EEOVF T/1iosiuPbTGI383DhKF5ryNSyMGx0naXFB4po0WyMIdJF1V8Rb2Q5pJFEgVMegJTsDQ ptd8i0Y0S5BTqaqOeUkt+eXUmoWaKRIcbcS9caS8mHdWA7hACG2+/ipaDTkvgq7LtrTS BxpV3aYe2o8PfTvXJTGer9Iux5v69zU8vPf89mT/gNVsbjOWtVazNvd8Naj2l0UooQIV rF3w== X-Gm-Message-State: AOJu0Yx4j0eQsasu3B8rxKIi3SJIlEZiMXn03wkxtrEn+XsA1/jm3QMi 7IQAjNCiAi6Wt29bXy8rVJmW0frvm83cdhe/9gCBJ8XoV4pURhqwR3j1e8aHrvmArFf22bfmNzR Hyso= X-Google-Smtp-Source: AGHT+IHsA4bGOT+XsGnsYsdCioIJBvGifVjN6dlHj4rETkwZdLIHz32iNSxVVMdwB9Z75I0Nun6vDw== X-Received: by 2002:a50:8d07:0:b0:568:cec0:2f84 with SMTP id s7-20020a508d07000000b00568cec02f84mr1614174eds.22.1711534311164; Wed, 27 Mar 2024 03:11:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:50 -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 7/9] platform: generic: Add mechanism to match via mvendorid Date: Wed, 27 Mar 2024 11:11:35 +0100 Message-ID: <20240327101137.3644359-8-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_031159_732566_ED1605B3 X-CRM114-Status: GOOD ( 16.97 ) 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: Currently, all platforms and their overrides are matched via FDT-compatible strings. While this is the right approach, we are sometimes confronted with platforms that don't provide the necessary FDT-c [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:52e listed in] [list.dnswl.org] -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 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 Currently, all platforms and their overrides are matched via FDT-compatible strings. While this is the right approach, we are sometimes confronted with platforms that don't provide the necessary FDT-compatible strings. To still be able to match a platforms, let's add a secondary matching mechanism for the MVENDORID CSR. Signed-off-by: Christoph Müllner --- platform/generic/include/platform_override.h | 1 + platform/generic/platform.c | 38 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index 6802126..a968346 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -17,6 +17,7 @@ struct platform_override { const struct fdt_match *match_table; + const unsigned long *match_vendor_ids; u64 (*features)(const struct fdt_match *match); u64 (*tlbr_flush_limit)(const struct fdt_match *match); u32 (*tlb_num_entries)(const struct fdt_match *match); diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 07fa9cc..e1b97c8 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -36,12 +36,28 @@ extern unsigned long platform_override_modules_size; static const struct platform_override *generic_plat = NULL; static const struct fdt_match *generic_plat_match = NULL; -static void fw_platform_lookup_special(void *fdt, int root_offset) +static unsigned long vendor_id_match(unsigned long vendor_id, + const unsigned long *vendor_ids) +{ + const unsigned long *vid_ptr = vendor_ids; + + while (*vid_ptr) { + if (*vid_ptr == vendor_id) + return vendor_id; + + vid_ptr++; + } + + return 0; +} + +static void fw_platform_lookup_override(void *fdt, int root_offset) { const struct platform_override *plat; const struct fdt_match *match; int pos; + /* First try to find a FDT match. */ for (pos = 0; pos < platform_override_modules_size; pos++) { plat = platform_override_modules[pos]; if (!plat->match_table) @@ -53,7 +69,23 @@ static void fw_platform_lookup_special(void *fdt, int root_offset) generic_plat = plat; generic_plat_match = match; - break; + return; + } + + /* No match via FDT -> try matching the vendor ID. */ + const unsigned long vendor_id = csr_read(CSR_MVENDORID); + for (pos = 0; pos < platform_override_modules_size; pos++) { + plat = platform_override_modules[pos]; + if (!plat->match_vendor_ids) + continue; + + unsigned long match = vendor_id_match(vendor_id, plat->match_vendor_ids); + if (!match) + continue; + + generic_plat = plat; + generic_plat_match = NULL; + return; } } @@ -154,7 +186,7 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1, if (root_offset < 0) goto fail; - fw_platform_lookup_special(fdt, root_offset); + fw_platform_lookup_override(fdt, root_offset); if (generic_plat && generic_plat->fw_init) generic_plat->fw_init(fdt, generic_plat_match); From patchwork Wed Mar 27 10:11:36 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: 1916667 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=E5ZOkfCZ; 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=S/PapnQl; 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 4V4Msk4ks2z1yXq for ; Wed, 27 Mar 2024 21:12:10 +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=8mVAc6LGmmRo3ybALnXkNI7RUkju8WIRidKwyXL63lA=; b=E5ZOkfCZXh6JQn 0r6NH5NKuvi9LJ8KVT4y1PO0XOhhDE/jJXPg1tVG4kykPGe9DMbqw4un8BJys4vCpNI5B80ptBabA EHub+7EWetESpYjBgbyx8wVtUzROmq2bBB1jorOghvYF32EYeAh4Szpnn3NbJFHQf5I2y10b46tC/ tunSe0YW4M2sJ1ARJCC1u3HyVBE38Xm4zViNep1rMQKVXTgZKGOWLPpmB88EsVzjYPSNa50MAWQuJ XbhwTcoFCqjtHkO0wDJ3c9Y9bFGuMocDpvOnmZNO2Ymd1aaowbxVoYlutj3uRwuCQ5QNDXsAKq2lU YtM5B+3aJICvMgKnlUbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGI-00000008MIq-16Nz; Wed, 27 Mar 2024 10:12:02 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGA-00000008MCE-1vUS for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:55 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-56c0d1bddc1so3842372a12.3 for ; Wed, 27 Mar 2024 03:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534312; x=1712139112; 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=zdNoZrXKSQBZhzJ7o8gpnVObKqyDlz13e3bX1DnieIU=; b=S/PapnQlvmlEa7OG035i8Mp4DugkeRm6mia+LMPblY816yTL9OJIEQIO0SvzOlLjMZ h4YNIaWTHY73cGb36UECWrHCB4qrIcQUdW6EHkbxDEU1beim45yL6TxGiDQTiCzQdkwF JK+2jFy8SBd52pFoFxlZzdXAGwEO5tFzDPHDufDmWqSTzFT+vj6uga6HwDI7WyHA/4UE L02Iqh5kb5b3IopVg+fNQ50C7Kh3dqboryMjfd3fqjioHHxf7/5dM2LFUkKAaRKqUqPS iHLjVrzcxZBaLe3TVi5nF40bAzsnmftUhOp5tnPubpGNZsoxfUpsdX5jmgQunYfJLxst iGTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534312; x=1712139112; 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=zdNoZrXKSQBZhzJ7o8gpnVObKqyDlz13e3bX1DnieIU=; b=he7RnF79HmFmHRDpTKpZeFjiOyisB8CPE7Dz9ySwoHc6+FeRHAc/yHHlyNfbtSIDSC X4So+mOXFe+pHKi6y1J417OtrHh+hkNknH77WKH2U+2gJ2j21pZw2a+h3e6Ml5+HOLO3 Gk3U4GrvKuyxAXsEAh8TyqHWigN1QLxNXYumGZGur92yWpdxlQYfU7LHvXdTDKUqTOpA AKVxBcEuP6UMIeJZBW3TgaAJS7vI015/qZ3WL1ZqnLGkY0Hfa6cNu3mLjxa1TGQem6yj 1pkrVnIWVkPAgP5ecDh3lPFH++h6Vrgt2FPC5UDCgLqFjjNacZw64g39eb9eYMXXXKn4 K/+A== X-Gm-Message-State: AOJu0YyWG4j8CQE0ijNGbLzLATt+0lbp1IljuBqWBisu48YQNS0t/T8U KFCqFhSoyWw6Ocs/BQrw/BKY5eYPcOG+5pScgVkgEqWlzKWIakBt8uSRkv+j/CbWOYMLzDcvPgg NdN0= X-Google-Smtp-Source: AGHT+IE55v8qee5T6wvmVfjV+rdZY5+wKLX9QKegIxyiY1uUmPJL7rzus37IdQiDtq09XNd5vLBOCA== X-Received: by 2002:a50:99d3:0:b0:56b:b6a2:2048 with SMTP id n19-20020a5099d3000000b0056bb6a22048mr610911edb.24.1711534312457; Wed, 27 Mar 2024 03:11:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:51 -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 8/9] platform: generic: thead: Add definition of T-Head's vendor ID Date: Wed, 27 Mar 2024 11:11:36 +0100 Message-ID: <20240327101137.3644359-9-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_031154_579206_7D9D97A4 X-CRM114-Status: UNSURE ( 8.71 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__This_patch_adds_a_macro_for_T-Head=27s?= =?unknown-8bit?q?_vendor_ID_to_the_C9xx?= =?unknown-8bit?q?_encodings=2E_Signed-off-by=3A_Christoph_M=C3=BCllner_=3Cch?= =?unknown-8bit?q?ristoph=2Emuellner=40vrull=2Eeu=3E?= =?unknown-8bit?q?_---_platform/generic/include/thead/c9xx=5Fencoding=2Eh_=7C?= =?unknown-8bit?q?_2_++_1_file_changed=2C?= =?unknown-8bit?q?_2_insertions=28+=29_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-0=2E2_points=2C_5=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDo1MzQgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= 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 This patch adds a macro for T-Head's vendor ID to the C9xx encodings. Signed-off-by: Christoph Müllner --- platform/generic/include/thead/c9xx_encoding.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/generic/include/thead/c9xx_encoding.h b/platform/generic/include/thead/c9xx_encoding.h index 58adbef..a4811f6 100644 --- a/platform/generic/include/thead/c9xx_encoding.h +++ b/platform/generic/include/thead/c9xx_encoding.h @@ -1,6 +1,8 @@ #ifndef __RISCV_THEAD_C9XX_ENCODING_H____ #define __RISCV_THEAD_C9XX_ENCODING_H____ +#define THEAD_VENDOR_ID 0x5b7 + /* T-HEAD C9xx M mode CSR. */ #define THEAD_C9XX_CSR_MXSTATUS 0x7c0 #define THEAD_C9XX_CSR_MHCR 0x7c1 From patchwork Wed Mar 27 10:11:37 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: 1916668 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=aTZ4A4hi; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=fAHZtXMc; 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=WgoeaL6X; 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 4V4Msl6Rh6z1yXq for ; Wed, 27 Mar 2024 21:12:11 +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=bh2iAlAGHJRTjF3reT2tYHCfrMx8+VowFhVETjmO5EE=; b=aTZ4A4hiioctWK takt91uq0KgMZ66wzkoe1RsfO+e10BNsYm+hMXOCPHeRgL+dkKRfGgSxwdIhhzFUi56aq1WJZjJkW ZlJulQXWd6masMQ029K4evDNSazy7tRiawXTA26kboaW8TiAySDDYhfNE6b/uOfjAKp/qE+jh7vI1 aJk+o5IyFtU3zk6Zkcc/BFxBBuP+GDidC5ndCdCI4MsEuZtAWz7Tib3HpeaD+vz9KC7yx74pX9jLq X3YAiqsWH46PnTHI5glVGlawqXjGInAOX5ceRLtXCKfenLR8Og0zhExiuvX/eZymZHiIVIpCPe/TN oZ0nPvP+Ckv+V6hlLFlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGK-00000008MLL-1qBG; Wed, 27 Mar 2024 10:12:04 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGG-00000008MHM-3igW for opensbi@bombadil.infradead.org; Wed, 27 Mar 2024 10:12:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=sdDamzyxWTmZZ1fBKFGAuSURrGvc93shUJBZpN8LPx0=; b=fAHZtXMc/ZphTyy/6Pozfw5/Pf tRVjtHhimKxcu/dUX2RJjOAm6Hl82HS8eb0wMs02Em9LU3AtTtw2fQjn4XehKw6N6qLXlmNBBKIzE bh19ouT2mMXMeBdjTi+pUadzI+TBb2uS9kYRqCchwfEvoMIS+F4Oj4ECE9tw3e3kZPrzn+fue21O4 MofvVtfS8YfyuypUUAOpFS77FROE3p7WB4FeDBZzdrEP6gNYRAu+AqXK/nQaGRTot2edaTAYsCskV zVbkV8Zvw28qSUucKpAgTcncwHHz8Gw9ZFs6YvKyBp1XdXdRUZ3xNmvgEzo9hLm+fyljSAKOk808/ kO7neR/g==; Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGB-00000000AEr-2fxY for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:59 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-56c36f8f932so1272772a12.0 for ; Wed, 27 Mar 2024 03:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534313; x=1712139113; 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=sdDamzyxWTmZZ1fBKFGAuSURrGvc93shUJBZpN8LPx0=; b=WgoeaL6X+7nm19hF2NU2TZsB8Lx54DafTzA1TnAO9QsrrQDG7SU8IvWYGf4yassI6O JfTREtAimMxjgI5v8t9WPQIRYT1xghxCaXBSEwW0pX9QzDJA+6XMFnn6dtYH5trQDyMJ ixRJ9Qx5VuqeMmW0a//LAN6y0ANGyL0KmDok1KRGu5C49Lg3uXoaPoQQEA7dhbQjobyY GmB7P/LVmK8l62IAhKEaftRXq2CCHrc02Nr7bGk49MFwnaE4qf1v/YUjgDP0GKlcGG9U 7p0RL1g8VtsK31y2oezjYOX5QzKm0mFQgyStPhikdN/ZqMcLels10hnWJR0jWGH9Jb6r KXQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534313; x=1712139113; 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=sdDamzyxWTmZZ1fBKFGAuSURrGvc93shUJBZpN8LPx0=; b=qCS/AvjX0YfaNQsTvVzRTyrY0aPfRi8+dZiDwo/XJ1wB6ZrznoSPommcGqFUZRiXlV JxvNWZph6doDFX3OecOPBEWug2Uuxpfbzy5DgYpaTX6lbRHE9H8FvsCZbr5wCGE67iwT /C3NkBnIi4R5Ul3zeN6iO4+YBVD4aJRF9zkv3wbiFy/huIgZrM9zm0P8o6uag9p3xQxd LrPNy/qhlvYYfqlp/fcezSJhnVk3jUvsU0etFg8KZ6TbHTps+Rl3v35vj23hjPkDRu2m 2K1ldtIOGYKqhqin2WsISanXAyKX10BIqMMQDBYsyrQsmGAQsJaWWcH9hBHTon6VpZrx 0/mQ== X-Gm-Message-State: AOJu0Yx1yhsIWF3q8MRXs1GMWlf35yq8CWVpWs3p3Xd1rocxew0w4uNS mU4Kxv0FeCTdCa3LLfiEy1KiJtu0b0tTttX1CWB1PERde4qXlUIpQZLXF2lcbggrNZxteWl4flL 0tH8= X-Google-Smtp-Source: AGHT+IEMta42o+Oy10r7YkYR6/PwTC/GFMf+pCmKhlnxf/ivQhiZsaeL+jdDO2H+5c45Luwj/KuVqg== X-Received: by 2002:a50:9303:0:b0:56c:16c9:cb00 with SMTP id m3-20020a509303000000b0056c16c9cb00mr3700201eda.12.1711534313641; Wed, 27 Mar 2024 03:11:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:53 -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 9/9] platform: generic: Add generic T-Head override Date: Wed, 27 Mar 2024 11:11:37 +0100 Message-ID: <20240327101137.3644359-10-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_101157_052327_BFEF4204 X-CRM114-Status: GOOD ( 14.59 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: Currently, we have support for three T-Head C9xx platforms: * Allwinner D1 * T-Head TH1520 * Sophgo SG2042 To make the platform detection more generic, let's add a T-Head generic override that matches on T-Head's vendor ID. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:529 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_SIGNED Message has a DKIM or DK signature, not necessarily valid 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 Currently, we have support for three T-Head C9xx platforms: * Allwinner D1 * T-Head TH1520 * Sophgo SG2042 To make the platform detection more generic, let's add a T-Head generic override that matches on T-Head's vendor ID. Proper detection of T-Head harts is needed so we can insert the CSR read-handler for th.mxstatus. Signed-off-by: Christoph Müllner --- platform/generic/Kconfig | 5 +++++ platform/generic/configs/defconfig | 1 + platform/generic/thead/objects.mk | 3 +++ platform/generic/thead/thead-generic.c | 27 ++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 platform/generic/thead/thead-generic.c diff --git a/platform/generic/Kconfig b/platform/generic/Kconfig index 6d85e51..e53582b 100644 --- a/platform/generic/Kconfig +++ b/platform/generic/Kconfig @@ -63,6 +63,11 @@ config PLATFORM_STARFIVE_JH7110 bool "StarFive JH7110 support" default n +config PLATFORM_THEAD_GENERIC + bool "T-HEAD generic support" + select THEAD_C9XX_CSR + default n + config PLATFORM_THEAD_TH1520 bool "T-HEAD TH1520 support" select THEAD_C9XX_CSR diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig index 52ec0f6..e435b6d 100644 --- a/platform/generic/configs/defconfig +++ b/platform/generic/configs/defconfig @@ -5,6 +5,7 @@ CONFIG_PLATFORM_SIFIVE_FU540=y CONFIG_PLATFORM_SIFIVE_FU740=y CONFIG_PLATFORM_SOPHGO_SG2042=y CONFIG_PLATFORM_STARFIVE_JH7110=y +CONFIG_PLATFORM_THEAD_GENERIC=y CONFIG_PLATFORM_THEAD_TH1520=y CONFIG_FDT_GPIO=y CONFIG_FDT_GPIO_DESIGNWARE=y diff --git a/platform/generic/thead/objects.mk b/platform/generic/thead/objects.mk index 42f1f53..9d3a7e2 100644 --- a/platform/generic/thead/objects.mk +++ b/platform/generic/thead/objects.mk @@ -12,5 +12,8 @@ platform-objs-$(CONFIG_THEAD_C9XX_PMU) += thead/thead_c9xx_pmu.o platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_tlb_trap_handler.o platform-objs-$(CONFIG_THEAD_C9XX_ERRATA) += thead/thead_c9xx_errata_tlb_flush.o +carray-platform_override_modules-$(CONFIG_PLATFORM_THEAD_GENERIC) += thead_generic +platform-objs-$(CONFIG_PLATFORM_THEAD_GENERIC) += thead/thead-generic.o + carray-platform_override_modules-$(CONFIG_PLATFORM_THEAD_TH1520) += thead_th1520 platform-objs-$(CONFIG_PLATFORM_THEAD_TH1520) += thead/thead-th1520.o diff --git a/platform/generic/thead/thead-generic.c b/platform/generic/thead/thead-generic.c new file mode 100644 index 0000000..f694b90 --- /dev/null +++ b/platform/generic/thead/thead-generic.c @@ -0,0 +1,27 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Authors: + * Christoph Müllner + */ + +#include +#include +#include +#include +#include + +static unsigned long thead_generic_vendor_ids[] = { + THEAD_VENDOR_ID, + 0, +}; + +static const struct fdt_match thead_generic_match[] = { + { }, +}; + +const struct platform_override thead_generic = { + .match_table = thead_generic_match, + .match_vendor_ids = thead_generic_vendor_ids, + .read_csr = thead_c9xx_read_csr, +};