From patchwork Tue Aug 15 02:31:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1821243 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=XfJ30A2C; 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=HlvW+u5u; 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=K2VfSRtG; 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 4RPwKc4Z8fz1yfb for ; Tue, 15 Aug 2023 12:32:52 +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=3M++L9XhWw6J1yGflNH9j945VosXL84GD7J+yLMA8KQ=; b=XfJ30A2C/jg0nJ LidNwQLnKQjntqxSZ+B/bav2hrfJCfraCtVWIAwX4jFf16rifhFvDx52s+/TDnJI1RskWWDtown2j foz5VDMsF0UuDd33F+7jXY1ShNq5QlwYLDpz/lYiPLEatmWFkvzXIDc8FVeO5c40zf4jCTBY6QI4h ADJljvWeey3hj0b077F4xr6Txc682Slkz9wwn6DaGHlJ8TuXJ+tgeJE3y4dCUauXjtnWIgTs44oGg SeREXyoGCymOTpwFiQcyXytw6zyUjS6COiARQE9OZmAmapNJTG+9jviyVkeJMw/sYOAno/jHxpLVG OeB7iqag1J+vx4lJdAVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVjrI-000k9S-2v; Tue, 15 Aug 2023 02:32:36 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVjrG-000k93-2w for opensbi@bombadil.infradead.org; Tue, 15 Aug 2023 02:32:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5v8ZU/whGQzZBK0jCWiFrZkyosOMmpOmO4UJ27eJ6Qk=; b=HlvW+u5u7shxU0jjtfj4sEOudL QmxCtr373Ovf/abrNhkBEuE17vpyvkO6BR91ZzN6NHwB/waaTieAezFFIs7Q3LkqDeADAzZeDoxf+ I3hBN2cXQlZqgjgfCv75X0NAyijwzCE3Fp8ijlIWIg9jSL6khSx/WozqU6cKmeomxSNWqsX12lrsF uY9IPgIfhd8tzGAZ4GVek5HNxOwkKgFJr29McOksA/gfZCC1yJcstSmhVzey3thGhrBGcGvUty+Qv ZW0m8tizCuGjiYjh+sbgi58CvWCglGR/b5HJFXcIBegE03AySuBRuzWYlNhw/kU/Y+vBEnuown8xh 6iCtxBEg==; Received: from m126.mail.126.com ([220.181.12.28]) by desiato.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVjr9-00BJ3X-0q for opensbi@lists.infradead.org; Tue, 15 Aug 2023 02:32:31 +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=5v8ZU /whGQzZBK0jCWiFrZkyosOMmpOmO4UJ27eJ6Qk=; b=K2VfSRtGwyU5uicck5H+5 frGFId7fysjffsQNCzwvLJ8+H6DW9liv/mub8N8MAR9YLH1rnLm3sDevix86zRvq aCaXLM5AYLlemThzHmpvsLy4/LJXHQD8W+uC6HckqfzRy1VUGh9E5CkzX6GPPpSo i/7ta2LIVqwCT7gaC6fKyc= Received: from t490.lan (unknown [210.22.74.39]) by zwqz-smtp-mta-g1-1 (Coremail) with SMTP id _____wDn7Z1549pk1q2gBw--.16740S3; Tue, 15 Aug 2023 10:31:24 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 1/2] platform: Allow platforms to specify the size of tlb fifo Date: Tue, 15 Aug 2023 10:31:10 +0800 Message-Id: <20230815023111.349647-2-wxjstz@126.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230815023111.349647-1-wxjstz@126.com> References: <20230815023111.349647-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDn7Z1549pk1q2gBw--.16740S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxur1DXF4xWr4DAw1kXF47Arb_yoW5KFy8pF ZrCFn3Ka1xKFyxt34xAanruFWrGa1F9rWUKryjq34fAFyxXFn5JrnxJF4jyrnrJrs7Aay2 qFs2vr4UCF15ur7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zEBOJwUUUUU= X-Originating-IP: [210.22.74.39] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiFx-MOlpEG-rSvAABsu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230815_033228_216910_95C118F5 X-CRM114-Status: GOOD ( 12.20 ) 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: 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 --- include/sbi/sbi_platform.h | 29 +++++++++++++++++++++++++++++ include/sbi/sbi_tlb.h | 2 -- lib/sbi/sbi_tlb.c | 4 ++-- 3 files changed, 31 insertions(+), 4 deletions(-) Content analysis details: (-0.2 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 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [220.181.12.28 listed in bl.mailspike.net] 0.0 RCVD_IN_MSPIKE_BL Mailspike blocklisted 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 --- include/sbi/sbi_platform.h | 29 +++++++++++++++++++++++++++++ include/sbi/sbi_tlb.h | 2 -- lib/sbi/sbi_tlb.c | 4 ++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 3e9616f..5929042 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -39,6 +39,8 @@ #define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x60 + __SIZEOF_POINTER__) /** Offset of hart_index2id in struct sbi_platform */ #define SBI_PLATFORM_HART_INDEX2ID_OFFSET (0x60 + (__SIZEOF_POINTER__ * 2)) +/** Offset of tlb_fifo_num_entries in struct sbi_platform */ +#define SBI_PLARFORM_TLB_FIFO_NUM_ENTRIES (0x60 + (__SIZEOF_POINTER__ * 3)) #define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT (1UL << 12) @@ -192,6 +194,15 @@ struct sbi_platform { * 2. HART id < SBI_HARTMASK_MAX_BITS */ const u32 *hart_index2id; + + /** + * For some systems with too many harts, too small tlb fifo + * may cause harts to wait. For such systems, this number + * can be increased. + * + * This value can be change in platform_override->fw_init + */ + u32 tlb_fifo_num_entries; }; /** @@ -243,6 +254,11 @@ _Static_assert( == SBI_PLATFORM_HART_INDEX2ID_OFFSET, "struct sbi_platform definition has changed, please redefine " "SBI_PLATFORM_HART_INDEX2ID_OFFSET"); +_Static_assert( + offsetof(struct sbi_platform, tlb_fifo_num_entries) + == SBI_PLARFORM_TLB_FIFO_NUM_ENTRIES, + "struct sbi_platform definition has changed, please redefine " + "SBI_PLARFORM_TLB_FIFO_NUM_ENTRIES"); /** Get pointer to sbi_platform for sbi_scratch pointer */ #define sbi_platform_ptr(__s) \ @@ -370,6 +386,19 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat, return true; return false; } +/** + * Get number of tlb fifo 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 && plat->tlb_fifo_num_entries) + return plat->tlb_fifo_num_entries; + return 8; +} /** * Check whether given HART is allowed to do cold boot 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; }