From patchwork Tue Jul 23 07:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Zong-You Xie X-Patchwork-Id: 1963642 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=X16AquA5; 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 4WSqJM41Whz1yXp for ; Tue, 23 Jul 2024 17:57:55 +1000 (AEST) 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=1FVPGDxGcOsBS9Po6MwkjgwYPTg/BmoBjgpxeBsql1Q=; b=X16AquA5CD/yta FPIgBPbPDsn4hoyR6JtuQEbnC8d3Q/0i3U13k2ccEVgMMWbsiq2jzFngHd+5XluSSIRiUqdK91cvz syHsVhbrUJr2qCrZzves/GrXFsIqi6Z1VJ97/Q1VZtIbd4fFarovTdB9Zx9KfKaRcUO6W/IB61ILu CcGWOjGrwtRFGSyEYc4yn4hY6fIb7CgQxcFWz/3GRa6PKtHzecM384NoEsBB5SwiLw59fAqbBrUkK 2imdMtvsT+HmTOuJ/LAs/vDtTZC05Ki83HuqPsiWIqNk8TWLTfxdxalkCJiJCFqpRvnCBH6uHwwbs P7Yxi0vSHhNKwu4GuYLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWAP6-0000000BmXP-3GFT; Tue, 23 Jul 2024 07:57:48 +0000 Received: from 60-248-80-70.hinet-ip.hinet.net ([60.248.80.70] helo=Atcsqr.andestech.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWAP3-0000000BmUK-2MRq for opensbi@lists.infradead.org; Tue, 23 Jul 2024 07:57:48 +0000 Received: from mail.andestech.com (ATCPCS31.andestech.com [10.0.1.89]) by Atcsqr.andestech.com with ESMTPS id 46N7vYoG035908 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 23 Jul 2024 15:57:34 +0800 (+08) (envelope-from ben717@andestech.com) Received: from atctrx.andestech.com (10.0.15.190) by ATCPCS31.andestech.com (10.0.1.89) with Microsoft SMTP Server id 14.3.498.0; Tue, 23 Jul 2024 15:57:34 +0800 From: Ben Zong-You Xie To: CC: Ben Zong-You Xie Subject: [PATCH 2/4] platform: generic: andes: add a new Andes SBI call to probe Andes PMA feature Date: Tue, 23 Jul 2024 15:57:26 +0800 Message-ID: <20240723075728.587110-3-ben717@andestech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723075728.587110-1-ben717@andestech.com> References: <20240723075728.587110-1-ben717@andestech.com> MIME-Version: 1.0 X-Originating-IP: [10.0.15.190] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 46N7vYoG035908 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_005745_898915_2245F455 X-CRM114-Status: GOOD ( 18.18 ) X-Spam-Score: -0.9 (/) 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: Add a new Andes SBI call to check whether PPMA is supported by hardware or not. Signed-off-by: Ben Zong-You Xie --- platform/generic/andes/ae350.c | 2 ++ platform/generic/andes/andes_pma.c | 8 ++++++-- platform/generic/andes/andes_sbi.c | 5 +++++ platform/g [...] Content analysis details: (-0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 TVD_RCVD_IP Message was received from an IP address 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 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 Add a new Andes SBI call to check whether PPMA is supported by hardware or not. Signed-off-by: Ben Zong-You Xie Reviewed-by: Anup Patel --- platform/generic/andes/ae350.c | 2 ++ platform/generic/andes/andes_pma.c | 8 ++++++-- platform/generic/andes/andes_sbi.c | 5 +++++ platform/generic/include/andes/andes_pma.h | 12 ++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/platform/generic/andes/ae350.c b/platform/generic/andes/ae350.c index 63c10bc..a1ab6b9 100644 --- a/platform/generic/andes/ae350.c +++ b/platform/generic/andes/ae350.c @@ -19,6 +19,7 @@ #include #include #include +#include static struct smu_data smu = { 0 }; extern void __ae350_enable_coherency_warmboot(void); @@ -120,4 +121,5 @@ const struct platform_override andes_ae350 = { .final_init = ae350_final_init, .extensions_init = andes_pmu_extensions_init, .pmu_init = andes_pmu_init, + .vendor_ext_provider = andes_sbi_vendor_ext_provider, }; diff --git a/platform/generic/andes/andes_pma.c b/platform/generic/andes/andes_pma.c index 9c37720..a884bf7 100644 --- a/platform/generic/andes/andes_pma.c +++ b/platform/generic/andes/andes_pma.c @@ -241,7 +241,6 @@ static int andes_fdt_reserved_memory_fixup(void *fdt, int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, unsigned int pma_regions_count) { - unsigned long mmsc = csr_read(CSR_MMSC_CFG); unsigned int dt_populate_cnt; unsigned int i, j; unsigned long pa; @@ -254,7 +253,7 @@ int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, if (pma_regions_count > ANDES_MAX_PMA_REGIONS) return SBI_EINVAL; - if ((mmsc & MMSC_CFG_PPMA_MASK) == 0) + if (!andes_sbi_probe_pma()) return SBI_ENOTSUPP; /* Configure the PMA regions */ @@ -290,3 +289,8 @@ int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, return 0; } + +bool andes_sbi_probe_pma(void) +{ + return (csr_read(CSR_MMSC_CFG) & MMSC_CFG_PPMA_MASK) ? true : false; +} diff --git a/platform/generic/andes/andes_sbi.c b/platform/generic/andes/andes_sbi.c index 43bafdc..a7ca4a5 100644 --- a/platform/generic/andes/andes_sbi.c +++ b/platform/generic/andes/andes_sbi.c @@ -5,12 +5,14 @@ */ #include #include +#include #include #include enum sbi_ext_andes_fid { SBI_EXT_ANDES_FID0 = 0, /* Reserved for future use */ SBI_EXT_ANDES_IOCP_SW_WORKAROUND, + SBI_EXT_ANDES_PMA_PROBE, }; static bool andes_cache_controllable(void) @@ -41,6 +43,9 @@ int andes_sbi_vendor_ext_provider(long funcid, case SBI_EXT_ANDES_IOCP_SW_WORKAROUND: out->value = andes_apply_iocp_sw_workaround(); break; + case SBI_EXT_ANDES_PMA_PROBE: + out->value = andes_sbi_probe_pma(); + break; default: return SBI_EINVAL; diff --git a/platform/generic/include/andes/andes_pma.h b/platform/generic/include/andes/andes_pma.h index 5ea1247..147dca1 100644 --- a/platform/generic/include/andes/andes_pma.h +++ b/platform/generic/include/andes/andes_pma.h @@ -47,4 +47,16 @@ struct andes_pma_region { int andes_pma_setup_regions(const struct andes_pma_region *pma_regions, unsigned int pma_regions_count); +/** + * Programmable PMA(PPMA) is a feature for Andes. PPMA allows dynamic adjustment + * of memory attributes in the runtime. It contains a configurable amount of PMA + * entries implemented as CSRs to control the attributes of memory locations. + * + * Check if hardware supports PPMA + * + * @return true if PPMA is supported + * @return false if PPMA is not supported + */ +bool andes_sbi_probe_pma(void); + #endif /* _ANDES_PMA_H_ */