[PATCH 2/3] platform: generic: Extra memory for housekeeping

Anup Patel anup at brainfault.org
Tue Sep 30 04:34:01 PDT 2025


On Wed, Aug 6, 2025 at 6:39 AM <wu.fei9 at sanechips.com.cn> wrote:
>
> Allocate the extra housekeeping metadata for heap or the expected free
> memory size cannot be achieved.
>
> Signed-off-by: Wu Fei <wu.fei9 at sanechips.com.cn>

No need for this patch since we now have dynamically growing house keeping.

Regards,
Anup

> ---
>  include/sbi/sbi_heap.h      | 3 +++
>  lib/sbi/sbi_heap.c          | 5 +++++
>  platform/generic/platform.c | 1 +
>  3 files changed, 9 insertions(+)
>
> diff --git a/include/sbi/sbi_heap.h b/include/sbi/sbi_heap.h
> index a4b3f0c..3d3feee 100644
> --- a/include/sbi/sbi_heap.h
> +++ b/include/sbi/sbi_heap.h
> @@ -98,4 +98,7 @@ int sbi_heap_init_new(struct sbi_heap_control *hpctrl, unsigned long base,
>                        unsigned long size);
>  int sbi_heap_alloc_new(struct sbi_heap_control **hpctrl);
>
> +/** Return the total heap size with housekeeping **/
> +unsigned long sbi_heap_total_size(unsigned long usable_size);
> +
>  #endif
> diff --git a/lib/sbi/sbi_heap.c b/lib/sbi/sbi_heap.c
> index 646c2e0..7aa27b1 100644
> --- a/lib/sbi/sbi_heap.c
> +++ b/lib/sbi/sbi_heap.c
> @@ -279,3 +279,8 @@ int sbi_heap_alloc_new(struct sbi_heap_control **hpctrl)
>         *hpctrl = sbi_calloc(1, sizeof(struct sbi_heap_control));
>         return 0;
>  }
> +
> +unsigned long sbi_heap_total_size(unsigned long usable_size)
> +{
> +       return usable_size + usable_size / (HEAP_HOUSEKEEPING_FACTOR - 1);
> +}
> diff --git a/platform/generic/platform.c b/platform/generic/platform.c
> index 47e771a..442f7d5 100644
> --- a/platform/generic/platform.c
> +++ b/platform/generic/platform.c
> @@ -41,6 +41,7 @@ static u32 fw_platform_calculate_heap_size(u32 hart_count)
>
>         /* For TLB fifo */
>         heap_size += SBI_TLB_INFO_SIZE * (hart_count) * (hart_count);
> +       heap_size = sbi_heap_total_size(heap_size);
>
>         return BIT_ALIGN(heap_size, HEAP_BASE_ALIGN);
>  }
> --
> 2.43.0
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list