From patchwork Wed Sep 6 13:10:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1830405 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=Lmd7iukM; 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=MBQpy1xw; 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=Za19KuPJ; 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 4RgjSl64s1z1yh1 for ; Wed, 6 Sep 2023 23:11:49 +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=ODuE+LgFlXgJRjkmqGSQNeC40U+BcfQFtgUE8hqyxaU=; b=Lmd7iukMmLd5y1 tWe0bb/AO0VMiznlTINoi//1HBKZA4abrkB1h3Inp8KRTX04QtV3cLbYtR6+0SWVCo8IggspaBH4T Ia8XsTMvlcb/SzvMdY7hHG2NonN5iJ8SE7nRwpe5aeCAITF1OfHE6DHjKPErduvqN8ceiuXcZpuzP zKb7L8NsQS34poNnLoCTPyntchVumat7wtXoow5B3AG0grmwC6h0dVcp6U/2N9G+2BqwxrrZb9Cm+ gTRNUwO3Enhzq12dsAfCw03dGLY5oA2t82UNIdBzW/ov0P74W3yHM5L+4UsjzfK4+D++YF044YuuF waetpxFfwD+K22pg1BhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdsJd-009toK-09; Wed, 06 Sep 2023 13:11:29 +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 1qdsJb-009tmF-1I for opensbi@bombadil.infradead.org; Wed, 06 Sep 2023 13:11:27 +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=UXGj7FL3czIzL3ySFWXI6kBMdzdyL6M9bW6LjlPjNGY=; b=MBQpy1xwK6Y0dgAGIg/MSp3yj7 r/IQsEHcr44EGWlseGL2w1NtqK9DAw2po6Ng5kn43Kdztc7DpLGxLS0dyJPC3N2ntWBCjXWNbOZnx xCxAw/Mef44OCiUJVUnmT6w+Cvp/TmFZg2EK2R0/LmA4BE+hhNMlnGIFjfWRa/C2BGiQL7pY21ifA IqQ3/fw7bjJ7LaIlg5KUJuE5zz5djs0x6Bk/P7tqpLxYzrml2FjwBh0AT3wy/1FkLiJaU56kvXMuw WyppaNeo/3UTsONi1DmEACfK+vAfMXLaa3pqnTlVSCh+x05RAetlS14o6YKH9tgvGQPdYOif6qcfH 9AdH9lGg==; Received: from m126.mail.126.com ([220.181.12.27]) by desiato.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdsJQ-0017Fd-3A for opensbi@lists.infradead.org; Wed, 06 Sep 2023 13:11:22 +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=UXGj7 FL3czIzL3ySFWXI6kBMdzdyL6M9bW6LjlPjNGY=; b=Za19KuPJKVFyxYQJ39Vvc DU82E+Xe8zrmnH6V+LgfwkXKtNvO8DCl6bmxsRgMOBTbpg3yheNOOw72gcFkJi9d TCryaJtCPFItYV4GLGUBRIkh37cFp9ApwkiZIkF89qpouNJ6Cfwqt6AqUcfgP2wj e2OLPMtLAEI4UrUnDptX1E= Received: from T490.lan (unknown [210.22.74.39]) by zwqz-smtp-mta-g1-1 (Coremail) with SMTP id _____wDn7_82evhk8rrFAQ--.18324S3; Wed, 06 Sep 2023 21:10:17 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , Xing Xiaoguang , Anup Patel Subject: [PATCH v5 1/2] platform: Allow platforms to specify the size of tlb fifo Date: Wed, 6 Sep 2023 21:10:03 +0800 Message-Id: <20230906131004.427047-2-wxjstz@126.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906131004.427047-1-wxjstz@126.com> References: <20230906131004.427047-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDn7_82evhk8rrFAQ--.18324S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxur1fZFykAFyfXr13tr1fJFb_yoW7Jw43pF Wv93Z3ta18KFyxtw4xA3WDZrWakw4FgrWUKryUu3sayas3Xr1DWF90qr1jyrnrJrs5A3Wa gF1IvrW8CF45ZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziBOJ8UUUUU= X-Originating-IP: [210.22.74.39] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdRviOmSdLc6GxwAAst X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230906_141119_967308_F7E52341 X-CRM114-Status: GOOD ( 12.68 ) 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 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 ++-- platfo [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] 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_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_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 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, From patchwork Wed Sep 6 13:10:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1830407 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=4LzsEi1B; 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=qX5Xh31Q; 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 4RgjnD4ZBTz1yh1 for ; Wed, 6 Sep 2023 23:26:08 +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=gc4bGtv6bo3MEvewK6w+JVxf31jw+ZO67isFT7bRWy0=; b=4LzsEi1Bsbfynb hl7L4K3pzurypToCGm1phIiTP0Gitqwz0BI7V+VPsednTgY4EbBukT1zUSh5LiCS6949I2p7TxZAU CzTldMthTbBJ86s6kKduMUS63QoB4IHgMNokEbuz4cOzW34KYCe4KK8uaxjrqCkbhmt3dHStaSYQH 3p1tmzaguvsIR22OKr0ov9wkOCe56cc7gxhOaaLhSKrUzhUPMXd911Ip0dJcqHqTrxuY7AyXQ7rk5 akEhDVlyvsOhgaV6VF3TVyeWKx9mn4E52NC7Sp8ujXa5qMdX/S63LzeqHZKcs+lcOj6ms8Z7Mbta8 zQQNW43FzzZW6yGdcnzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdsXV-00A30b-00; Wed, 06 Sep 2023 13:25:49 +0000 Received: from m126.mail.126.com ([220.181.12.26]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdsXR-00A2ud-0k for opensbi@lists.infradead.org; Wed, 06 Sep 2023 13:25:47 +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=3QgF4 ar02v1bg/OLBAFRFV2uLHjxd47EM2Uvnb14Fi4=; b=qX5Xh31QBZGT08Sh6omeJ lz7uVZYtaRGscxgFike3mXyNBgWossgf1iE28E5reMHunAqLJOOzXMNTHRacptz6 v2G6AGlP6w9nDu1dzEdCC2n6Tq4dW9lAwW+gm4w5NMvk1n1tM0MgLFaH5cXSTA0i tzz2JjK09xpUUmAJZevjsU= Received: from T490.lan (unknown [210.22.74.39]) by zwqz-smtp-mta-g1-1 (Coremail) with SMTP id _____wDn7_82evhk8rrFAQ--.18324S4; Wed, 06 Sep 2023 21:10:17 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W , Xing Xiaoguang Subject: [PATCH v5 2/2] lib: sbi: alloc tlb fifo by sbi_malloc Date: Wed, 6 Sep 2023 21:10:04 +0800 Message-Id: <20230906131004.427047-3-wxjstz@126.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906131004.427047-1-wxjstz@126.com> References: <20230906131004.427047-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wDn7_82evhk8rrFAQ--.18324S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr4Dtr4rtFWxZryUtFykGrg_yoW8Aw4UpF 9F9F9rtw4FyryktrW7ua1jvayfGa4v9r4UJryjqr93Z348ZF15JrZ3Cr1jqa4kJrsIvw15 trsFvryxuF15Wr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRYNtxUUUUU= X-Originating-IP: [210.22.74.39] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdRviOmSdLc6GxwABss X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230906_062545_625469_88454169 X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. 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: If the system is defined from tlb_fifo_num_entries, the scratch may be too small to hold the fifo, so it is alloc through the heap. Signed-off-by: Xiang W Signed-off-by: Xing Xiaoguang --- lib/sbi/sbi_tlb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 If the system is defined from tlb_fifo_num_entries, the scratch may be too small to hold the fifo, so it is alloc through the heap. Signed-off-by: Xiang W Signed-off-by: Xing Xiaoguang --- lib/sbi/sbi_tlb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index 92648da..24bf76b 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -421,8 +422,7 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) sbi_scratch_free_offset(tlb_sync_off); return SBI_ENOMEM; } - tlb_fifo_mem_off = sbi_scratch_alloc_offset( - sbi_platform_tlb_fifo_num_entries(plat) * SBI_TLB_INFO_SIZE); + tlb_fifo_mem_off = sbi_scratch_alloc_offset(sizeof(tlb_mem)); if (!tlb_fifo_mem_off) { sbi_scratch_free_offset(tlb_fifo_off); sbi_scratch_free_offset(tlb_sync_off); @@ -448,7 +448,14 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) tlb_sync = sbi_scratch_offset_ptr(scratch, tlb_sync_off); tlb_q = sbi_scratch_offset_ptr(scratch, tlb_fifo_off); - tlb_mem = sbi_scratch_offset_ptr(scratch, tlb_fifo_mem_off); + tlb_mem = sbi_scratch_read_type(scratch, void*, tlb_fifo_mem_off); + if (!tlb_mem) { + tlb_mem = sbi_malloc( + sbi_platform_tlb_fifo_num_entries(plat) * SBI_TLB_INFO_SIZE); + if (!tlb_mem) + return SBI_ENOMEM; + sbi_scratch_write_type(scratch, void*, tlb_fifo_mem_off, tlb_mem); + } ATOMIC_INIT(tlb_sync, 0);