From patchwork Tue Aug 15 07:15:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1821262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=E1uVBl97; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=O25mG/9U; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RQ2cC4xsTz1ygB for ; Tue, 15 Aug 2023 17:15: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=KcCoPGAy396Y4fl2aB4GSOvubrMnEKlbL+Xnyypfb2g=; b=E1uVBl97v1zED0 btfhp0b3ikj84Vonce8GCkbi1iX/lRcBgGISA6Qn1Gul+i8WnomboM1B/u0ZzgGclKwIgKwYnRNHH cLwgURmR3hwdP5QX/OvoTnbJizhxD3bvfk+kffm9AZzGSTVw2UlPw+1IpCgGifUNfa5fzWoLeySnO 4sR4Sv5yX/N08M2uRTU03QKkokj5+ZTHZp07X1/jVCB+hK2G9qK+6IDEYO8YT2cHkdhhVsp9W/ADD wn9xiMCMHqchnBnu1ObdhwnukMqwi8/ObBGzz2rLSSUsfBXdfW/BxaX8/2BkqouofDKrH1B2/67/M cq6KwChA79JGeaNIp1oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVoH8-0013J8-2n; Tue, 15 Aug 2023 07:15:34 +0000 Received: from m126.mail.126.com ([220.181.12.29]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVoH5-0013I3-0C for opensbi@lists.infradead.org; Tue, 15 Aug 2023 07:15:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=miILV +uNdKWrzpdYwCf8tOJWb3ECW+TuidPsiZ6TAuU=; b=O25mG/9UuVa58wo5astaF yMhF8yblUQkwgbC7BUnSySzJXTMIdduAdDBIlS2u9V78yYkS86ZLCMZSQR0yqfkD BjDuk4ApZjVZLob0Xzh/rII72Nowy2nioLIpUPTMPzHQw4MivzxfJAuBa59h5+tj RX0lO4XpKnFZuIJG2oXJP0= Received: from t490.lan (unknown [210.22.74.39]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wBXXqYHJttkSyDVBw--.42514S3; Tue, 15 Aug 2023 15:15:24 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , Xing Xiaoguang Subject: [PATCH v4 1/2] platform: Allow platforms to specify the size of tlb fifo Date: Tue, 15 Aug 2023 15:15:15 +0800 Message-Id: <20230815071516.422658-2-wxjstz@126.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230815071516.422658-1-wxjstz@126.com> References: <20230815071516.422658-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wBXXqYHJttkSyDVBw--.42514S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxur13AF48tF18Jw13GF18AFb_yoW7JF47pF Wv93Z3ta18KFyxtw4xA3WDZrWakw4FgrWUKryUu3sayas3Xr1DWF90qr1jyrnrJrs5A3WY gFn2vrW8CF45ZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEPEf5UUUUU= X-Originating-IP: [210.22.74.39] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiFwrMOlpEG-z5nwACs2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230815_001531_476080_D1C475D0 X-CRM114-Status: GOOD ( 12.98 ) 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: For some platforms with a particularly high number of harts, if the tlb fifo is too small, it case harts to wait. Platforms should be allowed to specify the size of the tlb fifo. Signed-off-by: Xiang W Signed-off-by: Xing Xiaoguang --- include/sbi/sbi_platform.h | 18 ++++++++++++++++++ include/sbi/sbi_tlb.h | 2 -- lib/sbi/sbi_tlb.c | 4 ++-- platform/generic/include/platfor [...] 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.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 For some platforms with a particularly high number of harts, if the tlb fifo is too small, it case harts to wait. Platforms should be allowed to specify the size of the tlb fifo. Signed-off-by: Xiang W Signed-off-by: Xing Xiaoguang Reviewed-by: Anup Patel --- include/sbi/sbi_platform.h | 18 ++++++++++++++++++ include/sbi/sbi_tlb.h | 2 -- lib/sbi/sbi_tlb.c | 4 ++-- platform/generic/include/platform_override.h | 1 + platform/generic/platform.c | 8 ++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 3e9616f..e6a4a31 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -41,6 +41,7 @@ #define SBI_PLATFORM_HART_INDEX2ID_OFFSET (0x60 + (__SIZEOF_POINTER__ * 2)) #define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT (1UL << 12) +#define SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES 8 #ifndef __ASSEMBLER__ @@ -125,6 +126,9 @@ struct sbi_platform_operations { /** Get tlb flush limit value **/ u64 (*get_tlbr_flush_limit)(void); + /** Get tlb fifo num entries*/ + u32 (*get_tlb_num_entries)(void); + /** Initialize platform timer for current HART */ int (*timer_init)(bool cold_boot); /** Exit platform timer for current HART */ @@ -325,6 +329,20 @@ static inline u64 sbi_platform_tlbr_flush_limit(const struct sbi_platform *plat) return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; } +/** + * Get platform specific tlb fifo num entries. + * + * @param plat pointer to struct sbi_platform + * + * @return number of tlb fifo entries +*/ +static inline u32 sbi_platform_tlb_fifo_num_entries(const struct sbi_platform *plat) +{ + if (plat && sbi_platform_ops(plat)->get_tlb_num_entries) + return sbi_platform_ops(plat)->get_tlb_num_entries(); + return SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES; +} + /** * Get total number of HARTs supported by the platform * diff --git a/include/sbi/sbi_tlb.h b/include/sbi/sbi_tlb.h index 48f1962..55dcab0 100644 --- a/include/sbi/sbi_tlb.h +++ b/include/sbi/sbi_tlb.h @@ -20,8 +20,6 @@ /* clang-format on */ -#define SBI_TLB_FIFO_NUM_ENTRIES 8 - struct sbi_scratch; struct sbi_tlb_info { diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index 26a87f3..92648da 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -422,7 +422,7 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) return SBI_ENOMEM; } tlb_fifo_mem_off = sbi_scratch_alloc_offset( - SBI_TLB_FIFO_NUM_ENTRIES * SBI_TLB_INFO_SIZE); + sbi_platform_tlb_fifo_num_entries(plat) * SBI_TLB_INFO_SIZE); if (!tlb_fifo_mem_off) { sbi_scratch_free_offset(tlb_fifo_off); sbi_scratch_free_offset(tlb_sync_off); @@ -453,7 +453,7 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) ATOMIC_INIT(tlb_sync, 0); sbi_fifo_init(tlb_q, tlb_mem, - SBI_TLB_FIFO_NUM_ENTRIES, SBI_TLB_INFO_SIZE); + sbi_platform_tlb_fifo_num_entries(plat), SBI_TLB_INFO_SIZE); return 0; } diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index 0d9e5ee..bf4b112 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -18,6 +18,7 @@ struct platform_override { const struct fdt_match *match_table; 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); bool (*cold_boot_allowed)(u32 hartid, const struct fdt_match *match); int (*early_init)(bool cold_boot, const struct fdt_match *match); int (*final_init)(bool cold_boot, const struct fdt_match *match); diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 34b87f7..66a0b77 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -256,6 +256,13 @@ static u64 generic_tlbr_flush_limit(void) return SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT; } +static u32 generic_tlb_num_entries(void) +{ + if (generic_plat && generic_plat->tlb_num_entries) + return generic_plat->tlb_num_entries(generic_plat_match); + return SBI_PLATFORM_TLB_FIFO_NUM_ENTRIES; +} + static int generic_pmu_init(void) { return fdt_pmu_setup(fdt_get_address()); @@ -308,6 +315,7 @@ const struct sbi_platform_operations platform_ops = { .pmu_init = generic_pmu_init, .pmu_xlate_to_mhpmevent = generic_pmu_xlate_to_mhpmevent, .get_tlbr_flush_limit = generic_tlbr_flush_limit, + .get_tlb_num_entries = generic_tlb_num_entries, .timer_init = fdt_timer_init, .timer_exit = fdt_timer_exit, .vendor_ext_check = generic_vendor_ext_check,