From patchwork Mon Aug 14 11:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1820986 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=pI5McjG+; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=lxlVxLLo; 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=WoFIPLmd; 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 4RPXKd3HW8z1yf2 for ; Mon, 14 Aug 2023 21:31:31 +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: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:In-Reply-To:References: List-Owner; bh=Ju0KbPaldxS1Bc+yhWU8x0rliuL3ENLuUJKkxcBiQOo=; b=pI5McjG+9euKI0 CjQn5fpmXAmcQclUw1Ax26tOGLO3+uhPx+TckbXzG9sKQxRrsnaM5zI78hTPBeCP9cjXXKlxg739Z q7yQcnbSTn1whhjcH1SBDq10wKUV0Onumm0E/NubkjCt9cMYSKv/ZxVfHK0ZFuT+w6eAf48CpTe+Q k5APk1zuI4makSBEWNjNHCRooOi0yU2Tn0eX+0GEswr3ODeeFDXxm3A25t6REF1gOIiJ9W38H3PdU gUIfaw+oku6Pi1siUWWsB8ZROipyPd9qaFyzEXOcu4f6YPJKkAW7ulVmo4KmuInj272ZGUp2GLBA3 HLWBtGqaXo65oWwS1kkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVVmv-00Gxjd-1X; Mon, 14 Aug 2023 11:31:09 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVVmt-00GxjP-2i for opensbi@bombadil.infradead.org; Mon, 14 Aug 2023 11:31:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=CdIvN05kMGiXJ8yLt28vyK9EFE+HieyIqwHOm78THAg=; b=lxlVxLLowFksC5xBuj8NGkND6A 2nPdhRwSy4co8/+fE2EyL8VJ9H6SGB0pp3dvYXOya6yl0uyFMdjy1wme8yiBulurn8rinB6nLa3/K 4RDzsyifigJWibpZCn4p1EUanSEUdUR6cTiJCZlfDiIBy8iy7soVN4MJSWzUCwwJEYbdZWTRtUTvQ zqagvcLVCHvSP8REUul5eZTlzHo31mgOMKarDlUKdmoqYZ5T3CnpVCkTZQmxmkEJ9na4JA7U2UOJJ rkxh/Vwk5cIcSzhjllpyckBN+gU6srTI6wWcd938I11TBldt79YQm5mEDh3r2VENwm69kIruejtyf CQuMYK6w==; Received: from m126.mail.126.com ([220.181.12.35]) by casper.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1qVVmn-001fwf-ED for opensbi@lists.infradead.org; Mon, 14 Aug 2023 11:31:06 +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=CdIvN 05kMGiXJ8yLt28vyK9EFE+HieyIqwHOm78THAg=; b=WoFIPLmdwpQhzjC3bM5KK zoLDSwhkEXt539Eu4nOQVAxSkPlGm30ZNA7vL4BEYXFQMIztakZHqQDaURPCqiQa 3h1S3Z2wcvMUmFf5vdwhpnE7hpBjBJfFOUXPLkw6rjrvFF1ZSlkuTbjxlnfcFmIF uS3zvh7rEnSdCrXb4aGVgo= Received: from t490.lan (unknown [210.22.74.39]) by zwqz-smtp-mta-g1-0 (Coremail) with SMTP id _____wA3P4cDENpkqqzABw--.35437S2; Mon, 14 Aug 2023 19:29:08 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH] lib: sbi: alloc tlb fifo by sbi_malloc Date: Mon, 14 Aug 2023 19:29:05 +0800 Message-Id: <20230814112905.151466-1-wxjstz@126.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CM-TRANSID: _____wA3P4cDENpkqqzABw--.35437S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr4DAFykXrW8uFW7Jw4UXFb_yoW5JryfpF ZFkF1Dtr4IyrykKrW7Aa1DZryfK34v93y7Gryjgr95Ja4UZr1rJr93Ar1Ut3WkJrZIyw1a kwsFvryfuF15Gr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zKNt4hUUUUU= X-Originating-IP: [210.22.74.39] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi1wfLOl53b5lX1AAAs9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230814_123102_063713_E2CBCCC6 X-CRM114-Status: UNSURE ( 9.34 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.6 on casper.infradead.org summary: Content analysis details: (-1.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] 0.9 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [220.181.12.35 listed in bl.mailspike.net] 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_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.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 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 --- lib/sbi/sbi_tlb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index 92648da..517ef90 100644 --- a/lib/sbi/sbi_tlb.c +++ b/lib/sbi/sbi_tlb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,6 @@ static unsigned long tlb_sync_off; static unsigned long tlb_fifo_off; -static unsigned long tlb_fifo_mem_off; static unsigned long tlb_range_flush_limit; static void tlb_flush_all(void) @@ -407,7 +407,7 @@ int sbi_tlb_request(ulong hmask, ulong hbase, struct sbi_tlb_info *tinfo) int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) { int ret; - void *tlb_mem; + void *tlb_mem = NULL; atomic_t *tlb_sync; struct sbi_fifo *tlb_q; const struct sbi_platform *plat = sbi_platform_ptr(scratch); @@ -421,16 +421,16 @@ 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( + tlb_mem = sbi_malloc( sbi_platform_tlb_fifo_num_entries(plat) * SBI_TLB_INFO_SIZE); - if (!tlb_fifo_mem_off) { + if (!tlb_mem) { sbi_scratch_free_offset(tlb_fifo_off); sbi_scratch_free_offset(tlb_sync_off); return SBI_ENOMEM; } ret = sbi_ipi_event_create(&tlb_ops); if (ret < 0) { - sbi_scratch_free_offset(tlb_fifo_mem_off); + sbi_free(tlb_mem); sbi_scratch_free_offset(tlb_fifo_off); sbi_scratch_free_offset(tlb_sync_off); return ret; @@ -440,7 +440,7 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) } else { if (!tlb_sync_off || !tlb_fifo_off || - !tlb_fifo_mem_off) + !tlb_mem) return SBI_ENOMEM; if (SBI_IPI_EVENT_MAX <= tlb_event) return SBI_ENOSPC; @@ -448,7 +448,6 @@ 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); ATOMIC_INIT(tlb_sync, 0);