Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F8F6C636D7 for ; Wed, 8 Feb 2023 18:39:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5EFCD85F34; Wed, 8 Feb 2023 19:39:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="HnIcROvW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C77E885F3A; Wed, 8 Feb 2023 19:39:25 +0100 (CET) Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8639C85F0D for ; Wed, 8 Feb 2023 19:39:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x835.google.com with SMTP id g7so21905307qto.11 for ; Wed, 08 Feb 2023 10:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fj/kJHUqzanVUxSjCHPTWDj4E2X/PYJv6uZCNEend/Q=; b=HnIcROvWqn/F/qDodBhn4ZA2wU08RtE8ADwanR518AC45YJ8A3lQ90zZcNBns20V6r +8dFOsEYsOyeMkKY8DJecfbsXuW5W4Jih3R7JXLE5yYVaiFK4vg4uAglU03pskrhvcx7 zESftux5TMjrB1UjwtOl3atrz/zRtyxh6NZXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fj/kJHUqzanVUxSjCHPTWDj4E2X/PYJv6uZCNEend/Q=; b=VNw8dI8WWJ6F6NgzZww0ygqqARDzpTuKkKvda8SvxP1Ov7iiaJ+UVZUVAewV6Qsvh0 wV0hAAb4DIe1hmNDeqE7MCjdfrTpcpnL2lAuYmYI782xhxkogBQjLVeq4NcXcwab0280 SzMMOFIVkXsrJcqraEAtAHQwQROhiH60lD0QoJcPn9o/YM+PWIuJD7WPNCikL6R8Of1a 8UV6JwbhbfqH7MB3bQhpbQrKu9LIHueXMHeJGqSBPdBWEL9CSjnIRByCCGKSOfvcxAyK i+Q5TxD0TbkFkMwxYPMrpmMSQdti5eF8uXU8dpjbhCc7qvrVCRbS7pSV77fnKX/ixE2k X+DQ== X-Gm-Message-State: AO0yUKU8pgVqsW0QpBw1eCezXkU93wVY1BuvZkETZ6g601l8MtQdHTCK OM+F+XUrxSgOrIbunskVuZwPT9HkiKJreXhQU4w= X-Google-Smtp-Source: AK7set8Z4gaGF+geRp/FQi4o4pqBdK7aP/8UVJy5BLdvVfnAsCf9itdxnmxCwtEvieorVd1yGbgHBQ== X-Received: by 2002:a05:622a:60b:b0:3ba:b957:41c2 with SMTP id z11-20020a05622a060b00b003bab95741c2mr8627368qta.61.1675881560206; Wed, 08 Feb 2023 10:39:20 -0800 (PST) Received: from bill-the-cat.lan (2603-6081-7b00-6400-90cc-7e59-435b-3104.res6.spectrum.com. [2603:6081:7b00:6400:90cc:7e59:435b:3104]) by smtp.gmail.com with ESMTPSA id o12-20020ac841cc000000b003b9a573aec6sm11997826qtm.70.2023.02.08.10.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 10:39:19 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale Date: Wed, 8 Feb 2023 13:39:18 -0500 Message-Id: <20230208183918.3768060-1-trini@konsulko.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean First, this test depends on CONFIG_LMB_USE_MAX_REGIONS, so add that as a test before building. Second, instead of using a hard-coded value of 8, which is the default of CONFIG_LMB_USE_MAX_REGIONS previously, use that directly and update the comments. The only trick here is that one part of the test itself also was written with the value of 8 itself in mind. Rework the size of the lmb region we allocate to scale with the value of CONFIG_LMB_USE_MAX_REGIONS. Cc: Simon Glass Signed-off-by: Tom Rini --- test/lib/lmb.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/test/lib/lmb.c b/test/lib/lmb.c index 157c26394d6f..b24c85d203ae 100644 --- a/test/lib/lmb.c +++ b/test/lib/lmb.c @@ -665,10 +665,17 @@ static int lib_test_lmb_get_free_size(struct unit_test_state *uts) DM_TEST(lib_test_lmb_get_free_size, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); +#ifdef CONFIG_LMB_USE_MAX_REGIONS static int lib_test_lmb_max_regions(struct unit_test_state *uts) { const phys_addr_t ram = 0x00000000; - const phys_size_t ram_size = 0x8000000; + /* + * All of 32bit memory space will be contain regionns for this test, so + * we need to scale ram_size (which in this case is the size of the lmb + * region) to match. + */ + const phys_size_t ram_size = ((0xFFFFFFFF >> CONFIG_LMB_MAX_REGIONS) + + 1) * CONFIG_LMB_MAX_REGIONS; const phys_size_t blk_size = 0x10000; phys_addr_t offset; struct lmb lmb; @@ -677,54 +684,55 @@ static int lib_test_lmb_max_regions(struct unit_test_state *uts) lmb_init(&lmb); ut_asserteq(lmb.memory.cnt, 0); - ut_asserteq(lmb.memory.max, 8); + ut_asserteq(lmb.memory.max, CONFIG_LMB_MAX_REGIONS); ut_asserteq(lmb.reserved.cnt, 0); - ut_asserteq(lmb.reserved.max, 8); + ut_asserteq(lmb.reserved.max, CONFIG_LMB_MAX_REGIONS); - /* Add 8 memory regions */ - for (i = 0; i < 8; i++) { + /* Add CONFIG_LMB_MAX_REGIONS memory regions */ + for (i = 0; i < CONFIG_LMB_MAX_REGIONS; i++) { offset = ram + 2 * i * ram_size; ret = lmb_add(&lmb, offset, ram_size); ut_asserteq(ret, 0); } - ut_asserteq(lmb.memory.cnt, 8); + ut_asserteq(lmb.memory.cnt, CONFIG_LMB_MAX_REGIONS); ut_asserteq(lmb.reserved.cnt, 0); - /* error for the 9th memory regions */ - offset = ram + 2 * 8 * ram_size; + /* error for the (CONFIG_LMB_MAX_REGIONS + 1) memory regions */ + offset = ram + 2 * (CONFIG_LMB_MAX_REGIONS + 1) * ram_size; ret = lmb_add(&lmb, offset, ram_size); ut_asserteq(ret, -1); - ut_asserteq(lmb.memory.cnt, 8); + ut_asserteq(lmb.memory.cnt, CONFIG_LMB_MAX_REGIONS); ut_asserteq(lmb.reserved.cnt, 0); - /* reserve 8 regions */ - for (i = 0; i < 8; i++) { + /* reserve CONFIG_LMB_MAX_REGIONS regions */ + for (i = 0; i < CONFIG_LMB_MAX_REGIONS; i++) { offset = ram + 2 * i * blk_size; ret = lmb_reserve(&lmb, offset, blk_size); ut_asserteq(ret, 0); } - ut_asserteq(lmb.memory.cnt, 8); - ut_asserteq(lmb.reserved.cnt, 8); + ut_asserteq(lmb.memory.cnt, CONFIG_LMB_MAX_REGIONS); + ut_asserteq(lmb.reserved.cnt, CONFIG_LMB_MAX_REGIONS); /* error for the 9th reserved blocks */ - offset = ram + 2 * 8 * blk_size; + offset = ram + 2 * (CONFIG_LMB_MAX_REGIONS + 1) * blk_size; ret = lmb_reserve(&lmb, offset, blk_size); ut_asserteq(ret, -1); - ut_asserteq(lmb.memory.cnt, 8); - ut_asserteq(lmb.reserved.cnt, 8); + ut_asserteq(lmb.memory.cnt, CONFIG_LMB_MAX_REGIONS); + ut_asserteq(lmb.reserved.cnt, CONFIG_LMB_MAX_REGIONS); /* check each regions */ - for (i = 0; i < 8; i++) + for (i = 0; i < CONFIG_LMB_MAX_REGIONS; i++) ut_asserteq(lmb.memory.region[i].base, ram + 2 * i * ram_size); - for (i = 0; i < 8; i++) + for (i = 0; i < CONFIG_LMB_MAX_REGIONS; i++) ut_asserteq(lmb.reserved.region[i].base, ram + 2 * i * blk_size); return 0; } +#endif DM_TEST(lib_test_lmb_max_regions, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -- 2.34.1