summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-04-23 12:21:37 -0400
committerTom Rini <trini@konsulko.com>2021-04-23 12:21:37 -0400
commit84baa65dffdbce20752279101548ba888be53b3e (patch)
tree430720a45d81277ca3cd9ee85be755d55f0f2e72 /lib
parent4d85f42716ceff1143e55c7697dd559cfc438489 (diff)
parent0089affee275e47047be8ae9deac6ca08a5da478 (diff)
Merge branch '2021-04-22-assorted-updates'
- Move LMB to Kconfig, improve functionality - Add partlabel support to more fs cmds
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig44
-rw-r--r--lib/lmb.c17
2 files changed, 53 insertions, 8 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index ab8c9ccd60..6d2d41de30 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -439,7 +439,7 @@ config LZ4
is included. The LZ4 algorithm can run in-place as long as the
compressed image is loaded to the end of the output buffer, and
trades lower compression ratios for much faster decompression.
-
+
NOTE: This implements the release version of the LZ4 frame
format as generated by default by the 'lz4' command line tool.
This is not the same as the outdated, less efficient legacy
@@ -700,6 +700,48 @@ config LIB_ELF
Support basic elf loading/validating functions.
This supports for 32 bit and 64 bit versions.
+config LMB
+ bool "Enable the logical memory blocks library (lmb)"
+ default y if ARC || ARM || M68K || MICROBLAZE || MIPS || NDS32 || \
+ NIOS2 || PPC || RISCV || SANDBOX || SH || X86 || XTENSA
+ help
+ Support the library logical memory blocks.
+
+config LMB_USE_MAX_REGIONS
+ bool "Use a commun number of memory and reserved regions in lmb lib"
+ depends on LMB
+ default y
+ help
+ Define the number of supported memory regions in the library logical
+ memory blocks.
+ This feature allow to reduce the lmb library size by using compiler
+ optimization when LMB_MEMORY_REGIONS == LMB_RESERVED_REGIONS.
+
+config LMB_MAX_REGIONS
+ int "Number of memory and reserved regions in lmb lib"
+ depends on LMB && LMB_USE_MAX_REGIONS
+ default 8
+ help
+ Define the number of supported regions, memory and reserved, in the
+ library logical memory blocks.
+
+config LMB_MEMORY_REGIONS
+ int "Number of memory regions in lmb lib"
+ depends on LMB && !LMB_USE_MAX_REGIONS
+ default 8
+ help
+ Define the number of supported memory regions in the library logical
+ memory blocks.
+ The minimal value is CONFIG_NR_DRAM_BANKS.
+
+config LMB_RESERVED_REGIONS
+ int "Number of reserved regions in lmb lib"
+ depends on LMB && !LMB_USE_MAX_REGIONS
+ default 8
+ help
+ Define the number of supported reserved regions in the library logical
+ memory blocks.
+
endmenu
config PHANDLE_CHECK_SEQ
diff --git a/lib/lmb.c b/lib/lmb.c
index d126f8dc04..c08c4d942b 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -20,8 +20,6 @@ void lmb_dump_all_force(struct lmb *lmb)
printf("lmb_dump_all:\n");
printf(" memory.cnt = 0x%lx\n", lmb->memory.cnt);
- printf(" memory.size = 0x%llx\n",
- (unsigned long long)lmb->memory.size);
for (i = 0; i < lmb->memory.cnt; i++) {
printf(" memory.reg[0x%lx].base = 0x%llx\n", i,
(unsigned long long)lmb->memory.region[i].base);
@@ -30,8 +28,6 @@ void lmb_dump_all_force(struct lmb *lmb)
}
printf("\n reserved.cnt = 0x%lx\n", lmb->reserved.cnt);
- printf(" reserved.size = 0x%llx\n",
- (unsigned long long)lmb->reserved.size);
for (i = 0; i < lmb->reserved.cnt; i++) {
printf(" reserved.reg[0x%lx].base = 0x%llx\n", i,
(unsigned long long)lmb->reserved.region[i].base);
@@ -99,10 +95,17 @@ static void lmb_coalesce_regions(struct lmb_region *rgn, unsigned long r1,
void lmb_init(struct lmb *lmb)
{
+#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 = lmb->memory_regions;
+ lmb->reserved.region = lmb->reserved_regions;
+#endif
lmb->memory.cnt = 0;
- lmb->memory.size = 0;
lmb->reserved.cnt = 0;
- lmb->reserved.size = 0;
}
static void lmb_reserve_common(struct lmb *lmb, void *fdt_blob)
@@ -185,7 +188,7 @@ static long lmb_add_region(struct lmb_region *rgn, phys_addr_t base, phys_size_t
if (coalesced)
return coalesced;
- if (rgn->cnt >= MAX_LMB_REGIONS)
+ if (rgn->cnt >= rgn->max)
return -1;
/* Couldn't coalesce the LMB, so add it to the sorted table. */