mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-17 18:34:42 +00:00
lmb: Fix LMB_MEMORY_REGIONS flag usage
Remove test on CONFIG_LMB_MEMORY_REGIONS introduced by commit7c1860fce4
("lmb: Fix lmb property's defination under struct lmb"). This code in lmb_init() is strange, because if CONFIG_LMB_USE_MAX_REGIONS and CONFIG_LMB_MEMORY_REGIONS are not defined, the implicit #else is empty and the required initialization is not done: lmb->memory.max = ? lmb->reserved.max = ? But this setting is not possible: - CONFIG_LMB_USE_MAX_REGIONS not defined - CONFIG_LMB_MEMORY_REGIONS not defined because CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS are defined as soon as the CONFIG_LMB_USE_MAX_REGIONS is not defined. This patch removes this impossible case #elif and I add some explanation in lmb.h to explain why in the struct lmb {} the lmb property is defined if CONFIG_LMB_MEMORY_REGIONS is NOT defined. This patch also removes CONFIG_LMB_XXX dependency on CONFIG_LMB as these defines are used in API file lmb.h and not only in library file. Fixes:5e2548c1d6
("lmb: Fix LMB_MEMORY_REGIONS flag usage") Reported-by: Mark Millard <marklmi@yahoo.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Acked-by: Michal Simek <michal.simek@amd.com>
This commit is contained in:
parent
b0b77fdf3d
commit
94c8da2121
3 changed files with 23 additions and 6 deletions
|
@ -35,6 +35,24 @@ struct lmb_property {
|
||||||
enum lmb_flags flags;
|
enum lmb_flags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For regions size management, see LMB configuration in KConfig
|
||||||
|
* all the #if test are done with CONFIG_LMB_USE_MAX_REGIONS (boolean)
|
||||||
|
*
|
||||||
|
* case 1. CONFIG_LMB_USE_MAX_REGIONS is defined (legacy mode)
|
||||||
|
* => CONFIG_LMB_MAX_REGIONS is used to configure the region size,
|
||||||
|
* directly in the array lmb_region.region[], with the same
|
||||||
|
* configuration for memory and reserved regions.
|
||||||
|
*
|
||||||
|
* case 2. CONFIG_LMB_USE_MAX_REGIONS is not defined, the size of each
|
||||||
|
* region is configurated *independently* with
|
||||||
|
* => CONFIG_LMB_MEMORY_REGIONS: struct lmb.memory_regions
|
||||||
|
* => CONFIG_LMB_RESERVED_REGIONS: struct lmb.reserved_regions
|
||||||
|
* lmb_region.region is only a pointer to the correct buffer,
|
||||||
|
* initialized in lmb_init(). This configuration is useful to manage
|
||||||
|
* more reserved memory regions with CONFIG_LMB_RESERVED_REGIONS.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct lmb_region - Description of a set of region.
|
* struct lmb_region - Description of a set of region.
|
||||||
*
|
*
|
||||||
|
@ -68,7 +86,7 @@ struct lmb_region {
|
||||||
struct lmb {
|
struct lmb {
|
||||||
struct lmb_region memory;
|
struct lmb_region memory;
|
||||||
struct lmb_region reserved;
|
struct lmb_region reserved;
|
||||||
#ifdef CONFIG_LMB_MEMORY_REGIONS
|
#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
|
||||||
struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
|
struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS];
|
||||||
struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
|
struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS];
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1057,7 +1057,6 @@ config LMB
|
||||||
|
|
||||||
config LMB_USE_MAX_REGIONS
|
config LMB_USE_MAX_REGIONS
|
||||||
bool "Use a common number of memory and reserved regions in lmb lib"
|
bool "Use a common number of memory and reserved regions in lmb lib"
|
||||||
depends on LMB
|
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
Define the number of supported memory regions in the library logical
|
Define the number of supported memory regions in the library logical
|
||||||
|
@ -1067,7 +1066,7 @@ config LMB_USE_MAX_REGIONS
|
||||||
|
|
||||||
config LMB_MAX_REGIONS
|
config LMB_MAX_REGIONS
|
||||||
int "Number of memory and reserved regions in lmb lib"
|
int "Number of memory and reserved regions in lmb lib"
|
||||||
depends on LMB && LMB_USE_MAX_REGIONS
|
depends on LMB_USE_MAX_REGIONS
|
||||||
default 16
|
default 16
|
||||||
help
|
help
|
||||||
Define the number of supported regions, memory and reserved, in the
|
Define the number of supported regions, memory and reserved, in the
|
||||||
|
@ -1075,7 +1074,7 @@ config LMB_MAX_REGIONS
|
||||||
|
|
||||||
config LMB_MEMORY_REGIONS
|
config LMB_MEMORY_REGIONS
|
||||||
int "Number of memory regions in lmb lib"
|
int "Number of memory regions in lmb lib"
|
||||||
depends on LMB && !LMB_USE_MAX_REGIONS
|
depends on !LMB_USE_MAX_REGIONS
|
||||||
default 8
|
default 8
|
||||||
help
|
help
|
||||||
Define the number of supported memory regions in the library logical
|
Define the number of supported memory regions in the library logical
|
||||||
|
@ -1084,7 +1083,7 @@ config LMB_MEMORY_REGIONS
|
||||||
|
|
||||||
config LMB_RESERVED_REGIONS
|
config LMB_RESERVED_REGIONS
|
||||||
int "Number of reserved regions in lmb lib"
|
int "Number of reserved regions in lmb lib"
|
||||||
depends on LMB && !LMB_USE_MAX_REGIONS
|
depends on !LMB_USE_MAX_REGIONS
|
||||||
default 8
|
default 8
|
||||||
help
|
help
|
||||||
Define the number of supported reserved regions in the library logical
|
Define the number of supported reserved regions in the library logical
|
||||||
|
|
|
@ -110,7 +110,7 @@ void lmb_init(struct lmb *lmb)
|
||||||
#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
|
#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
|
||||||
lmb->memory.max = CONFIG_LMB_MAX_REGIONS;
|
lmb->memory.max = CONFIG_LMB_MAX_REGIONS;
|
||||||
lmb->reserved.max = CONFIG_LMB_MAX_REGIONS;
|
lmb->reserved.max = CONFIG_LMB_MAX_REGIONS;
|
||||||
#elif defined(CONFIG_LMB_MEMORY_REGIONS)
|
#else
|
||||||
lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS;
|
lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS;
|
||||||
lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS;
|
lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS;
|
||||||
lmb->memory.region = lmb->memory_regions;
|
lmb->memory.region = lmb->memory_regions;
|
||||||
|
|
Loading…
Add table
Reference in a new issue