From patchwork Tue Aug 15 02:31:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1821244 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=Ryre/SDV; 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=LPSGYm7V; 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=NeecB4bw; 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 4RPwKc0HzDz1yf9 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=L4egIc+Lp88jrnj9jjYM2TTGLv7t5lLSyQ6sDWkFLTw=; b=Ryre/SDVVeY+Cg c5V1Yk4A8+PLN1WVkl9h0SDay1v+obwIHSwQHxhC0pflAvl8Go73JS5BN7fekVYQvQwtGvc+4T7Pz N1ZbNFkZb3CMxsbxHpBtZLvLUj9n/UjqyJrZ7LJ33VNCy+Z5OVmZuamMzZlM4Tm2IbLGxT6LdGzZ+ IaWwORg8HPAU2MV25tpI43cm1ktkhodxLj24LAQc6j+jQ+qJ3R5aXl/HKT0PblNL+fK1MKpZTlWw8 yVtYRyohLLcaFRnmiKPkqYBJhFjavcWBidiWaWQDqQf3IomG/ZFJgzOENsutf9hcbRM0GFU+W7tN+ W9K878TGt5TCiNTP4drQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVjrJ-000k9e-16; Tue, 15 Aug 2023 02:32:37 +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 1qVjrH-000k96-0f for opensbi@bombadil.infradead.org; Tue, 15 Aug 2023 02:32:35 +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=FSGKns/aDAgPHj6xvkopsPbytSgWdgo1IX+F1UT2Lbo=; b=LPSGYm7Vdxrnq0bCBj5KZw8qgr YlSZead13Cqkjf6bMMY+s4lDVEAWR8sn8YpAqPum+QP+cHvZcKM7loiAf7qpk71Uc8hcnJczF7ERs RmACJcaQkzGOP+wtCa19J2EKDemJz5LHsNnFcf6nzM0MUlnt1YP1XvGaLz1SQvDHrIvpbN0kqZmRY GE64PC3/OXb4tgSjmZPn3jDm90Bx6Ua6LGzsoLCvPbpmbCOlzs5QYswLLug+beWR14a1BIlhBsv8O K1K0eisCJqLz3bXMCUxf+V7dE8N6/8aFWHndoI4blWkJ1p4MlEiavV+tcdYk++9cmGxZw42UaVvlH ccea9GvQ==; Received: from m126.mail.126.com ([220.181.12.26]) by desiato.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVjrC-00BJ92-1H for opensbi@lists.infradead.org; Tue, 15 Aug 2023 02:32:33 +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=FSGKn s/aDAgPHj6xvkopsPbytSgWdgo1IX+F1UT2Lbo=; b=NeecB4bwkZ27vDvgdpIU+ W8wN69z8weGIcjB0QJFXLYn9Azs6zbAhGvSTTK3Jt0XvXC//mOEm3IKbkKwMe6o/ IkHHDe1VVtGgW4QsPLFiiDR4JLg3uIhMjZx4NixD1EAOPrCVs9F6srIkfE+Hzgwm VOclhVCVFi1RGW/O/hYkto= Received: from t490.lan (unknown [210.22.74.39]) by zwqz-smtp-mta-g1-1 (Coremail) with SMTP id _____wDn7Z1549pk1q2gBw--.16740S4; Tue, 15 Aug 2023 10:31:27 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 2/2] lib: sbi: alloc tlb fifo by sbi_malloc Date: Tue, 15 Aug 2023 10:31:11 +0800 Message-Id: <20230815023111.349647-3-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--.16740S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr4DCF1UKFWfuryrJr1xAFb_yoW8Kry8pF ZFkF9rtr4IkryktrW7Za1DZ34rG3s293yUJryjgr95J34UuF15Jr93Cr1Ut3WkJrZIvw1Y kwsFvrWxuF15Gr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zR6pBfUUUUU= X-Originating-IP: [210.22.74.39] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbiJgXMOlpD9Wan1gAAsu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230815_033231_793228_9DAB9E5C X-CRM114-Status: UNSURE ( 9.73 ) X-CRM114-Notice: Please train this message. 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: 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 | 19 ++++++ 1 file changed, 6 insertions(+), 13 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.26 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 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 | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c index 92648da..7b3ec0a 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) @@ -421,16 +421,8 @@ 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); - if (!tlb_fifo_mem_off) { - 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_scratch_free_offset(tlb_fifo_off); sbi_scratch_free_offset(tlb_sync_off); return ret; @@ -438,9 +430,7 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot) tlb_event = ret; tlb_range_flush_limit = sbi_platform_tlbr_flush_limit(plat); } else { - if (!tlb_sync_off || - !tlb_fifo_off || - !tlb_fifo_mem_off) + if (!tlb_sync_off || !tlb_fifo_off) return SBI_ENOMEM; if (SBI_IPI_EVENT_MAX <= tlb_event) return SBI_ENOSPC; @@ -448,7 +438,10 @@ 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_malloc( + sbi_platform_tlb_fifo_num_entries(plat) * SBI_TLB_INFO_SIZE); + if (!tlb_mem) + return SBI_ENOMEM; ATOMIC_INIT(tlb_sync, 0);