All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale
@ 2023-02-08 18:39 Tom Rini
  2023-02-08 19:07 ` Simon Glass
  2023-02-08 20:00 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Rini @ 2023-02-08 18:39 UTC (permalink / raw)
  To: u-boot; +Cc: Simon Glass

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 <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale
  2023-02-08 18:39 [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale Tom Rini
@ 2023-02-08 19:07 ` Simon Glass
  2023-02-08 19:08   ` Tom Rini
  2023-02-08 20:00 ` Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Glass @ 2023-02-08 19:07 UTC (permalink / raw)
  To: Tom Rini; +Cc: U-Boot Mailing List

On Wed, 8 Feb 2023 at 11:39, Tom Rini <trini@konsulko.com> wrote:
>
> 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 <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  test/lib/lmb.c | 44 ++++++++++++++++++++++++++------------------
>  1 file changed, 26 insertions(+), 18 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

nit below

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

regions

Should the word 'be' be there?

[..]

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale
  2023-02-08 19:07 ` Simon Glass
@ 2023-02-08 19:08   ` Tom Rini
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2023-02-08 19:08 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]

On Wed, Feb 08, 2023 at 12:07:00PM -0700, Simon Glass wrote:
> On Wed, 8 Feb 2023 at 11:39, Tom Rini <trini@konsulko.com> wrote:
> >
> > 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 <sjg@chromium.org>
> > Signed-off-by: Tom Rini <trini@konsulko.com>
> > ---
> >  test/lib/lmb.c | 44 ++++++++++++++++++++++++++------------------
> >  1 file changed, 26 insertions(+), 18 deletions(-)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> nit below
> 
> >
> > 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
> 
> regions
> 
> Should the word 'be' be there?

My re-re-word was wrong, I'll adjust it, read it aloud and repeat until
it's right before pushing, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale
  2023-02-08 18:39 [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale Tom Rini
  2023-02-08 19:07 ` Simon Glass
@ 2023-02-08 20:00 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2023-02-08 20:00 UTC (permalink / raw)
  To: u-boot; +Cc: Simon Glass

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

On Wed, Feb 08, 2023 at 01:39:18PM -0500, Tom Rini wrote:

> 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 <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-08 20:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 18:39 [PATCH] test: lmb: Rework lib_test_lmb_max_regions test to scale Tom Rini
2023-02-08 19:07 ` Simon Glass
2023-02-08 19:08   ` Tom Rini
2023-02-08 20:00 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.