From patchwork Fri Jun 7 18:52:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 802334 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp949763wro; Fri, 7 Jun 2024 11:57:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUxSr1FQ1KE5gV8JpEiyvvpEpBNw/mzB5CbXIhHOgvwRT5VJhLuvwpKHEbzHRyRaL+zxfg0MnaWNli7+jydfbTt X-Google-Smtp-Source: AGHT+IEwWT73mbRxH1oRnYgFq03KhlEpjKRPnyzh1U1R5VXxXrzZcscnWUzGYS2cEzYcJBTGagXj X-Received: by 2002:a50:bb03:0:b0:57a:72fc:c515 with SMTP id 4fb4d7f45d1cf-57c50972f4emr2548068a12.29.1717786651482; Fri, 07 Jun 2024 11:57:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717786651; cv=none; d=google.com; s=arc-20160816; b=VvK7dON2eeyYKqj3GyEXS60uOyMC2fdXuQlHQQE5H7FTeOg4GQqF+xzQLbBIBkZglF GUUnIbkrGEyqj9jxKVQg+cYtRP3z+z1QA/kh0N86j8rK4XtqR6l3HJBihwp3GJBYRYQW n7gyBCK9+WzZtJFSaAQrre4ixZ3uKMVf5kvqTkheGDBV6ISsQNYLz7nXV5G9EL2vTB8R 4fPTI5Y2V3kqrXjdRTipsayclx+tJDW3yzaDNvGmkTwyUTyCGmcu9+SCQ4ZWvIv9kzYD zh+e8GNwFWGyvfdwLeK3mo4Xb0YA+Sr11RN/sKTA1O24cbEwt5ChBYrQgmzRX+oGxKQA pV8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=LXBPHlQih6V3x/bFDaY2UyU4SVEaGfyHAUzBY8ZOuFs=; fh=xLSOOz5Q0Mrmzd+lwBRTYS7D/8TpUWM8TEHgIjpMzow=; b=o7bDuO1mA530miXV6fD+f5m57P+DvNhwrUJ34UWM8bpw0XDISY4QOvzlDIta+3niqy 6FMxaBP8t1G0FZF3cAXTxv6kWFbxVKeIfBWqMCzQ7URvxD3mMIJE4m5kgpspTg59RUQk 1xcnWqSi7/oTLNiyiAsXN/YOCJNryEyoeZ80W81sssuPc8nicjG+DPZByAGqxegB5DmO /xbpSJLzALisIraWajJvAgqhoCh+XTv9bpnulB5DTwqKNneNKfhE3LySZkuKERU5+Uzp YXkL7VhhxbrBDvzNZLStLEAx/BBo9DZmktP4oxALxv/v5bG4rDqwYyFAGQtOtTxGY/X1 gS+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae25f918si2121601a12.508.2024.06.07.11.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 11:57:31 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A019488506; Fri, 7 Jun 2024 20:54:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 31B238848F; Fri, 7 Jun 2024 20:54:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 9141E88551 for ; Fri, 7 Jun 2024 20:54:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6B5BB1480; Fri, 7 Jun 2024 11:55:11 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F4833F792; Fri, 7 Jun 2024 11:54:44 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Fabio Estevam , Sughosh Ganu Subject: [RFC PATCH 23/31] test: lmb: initialise the lmb structure before tests Date: Sat, 8 Jun 2024 00:22:32 +0530 Message-Id: <20240607185240.1892031-24-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240607185240.1892031-1-sughosh.ganu@linaro.org> References: <20240607185240.1892031-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The LMB allocations are now persistent and global, and with that all the local instances of the structure variable have been removed. Every LMB test cases that are run require a clean slate of the structure -- facilitate that by adding an initialisation function which gets called at the start of every test. Signed-off-by: Sughosh Ganu --- include/lmb.h | 4 ++++ lib/lmb.c | 17 +++++++++++++++++ test/lib/lmb.c | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/include/lmb.h b/include/lmb.h index 1d4cd255d2..08ece0a90b 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -148,6 +148,10 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align); */ void lmb_reserve_common(void *fdt_blob); +#if defined(CONFIG_SANDBOX) +void lmb_init(void); +#endif /* CONFIG_SANDBOX */ + #endif /* __KERNEL__ */ #endif /* _LINUX_LMB_H */ diff --git a/lib/lmb.c b/lib/lmb.c index c9f6ca692e..2798ce0989 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -718,3 +718,20 @@ static int efi_mem_map_update_sync(void *ctx, struct event *event) } EVENT_SPY_FULL(EVT_EFI_MEM_MAP_UPDATE, efi_mem_map_update_sync); #endif /* MEM_MAP_UPDATE_NOTIFY */ + +#if CONFIG_IS_ENABLED(SANDBOX) +void lmb_init(void) +{ +#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS) + lmb.memory.max = CONFIG_LMB_MAX_REGIONS; + lmb.reserved.max = CONFIG_LMB_MAX_REGIONS; +#else + lmb.memory.max = CONFIG_LMB_MEMORY_REGIONS; + lmb.reserved.max = CONFIG_LMB_RESERVED_REGIONS; + lmb.memory.region = memory_regions; + lmb.reserved.region = reserved_regions; +#endif + lmb.memory.cnt = 0; + lmb.reserved.cnt = 0; +} +#endif /* SANDBOX */ diff --git a/test/lib/lmb.c b/test/lib/lmb.c index ace1ddf4e4..260ebcfcd3 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -77,6 +77,8 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram, ut_assert(alloc_64k_addr >= ram + 8); ut_assert(alloc_64k_end <= ram_end - 8); + lmb_init(); + if (ram0_size) { ret = lmb_add(ram0, ram0_size); ut_asserteq(ret, 0); @@ -235,6 +237,8 @@ static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram) /* check for overflow */ ut_assert(ram_end == 0 || ram_end > ram); + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); @@ -299,6 +303,8 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram, /* check for overflow */ ut_assert(ram_end == 0 || ram_end > ram); + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); ASSERT_LMB(&lmb, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); @@ -382,6 +388,8 @@ static int lib_test_lmb_at_0(struct unit_test_state *uts) long ret; phys_addr_t a, b; + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); @@ -418,6 +426,8 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts) const phys_size_t ram_size = 0x20000000; long ret; + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); @@ -473,6 +483,8 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) /* check for overflow */ ut_assert(ram_end == 0 || ram_end > ram); + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); @@ -597,6 +609,8 @@ static int test_get_unreserved_size(struct unit_test_state *uts, /* check for overflow */ ut_assert(ram_end == 0 || ram_end > ram); + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0); @@ -664,6 +678,8 @@ static int lib_test_lmb_max_regions(struct unit_test_state *uts) phys_addr_t offset; int ret, i; + lmb_init(); + ut_asserteq(lmb.memory.cnt, 0); ut_asserteq(lmb.memory.max, CONFIG_LMB_MAX_REGIONS); ut_asserteq(lmb.reserved.cnt, 0); @@ -722,6 +738,8 @@ static int lib_test_lmb_flags(struct unit_test_state *uts) const phys_size_t ram_size = 0x20000000; long ret; + lmb_init(); + ret = lmb_add(ram, ram_size); ut_asserteq(ret, 0);