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);