std: mem size sign set [1/1]

PD#SWPL-204046

Problem:
std seurmem and memsize handle

Solution:
std flow set

Verify:
s7

Change-Id: I1c700ec916da43ebd3f8326f779fc72a8cc38375
Signed-off-by: luke.liu <luke.liu@amlogic.com>
This commit is contained in:
luke.liu
2025-02-28 10:43:54 +08:00
committed by Dongjin Kim
parent 9857ce4dc1
commit ef04392c93
2 changed files with 36 additions and 0 deletions

View File

@@ -995,8 +995,16 @@ void __init register_nosave_region(unsigned long start_pfn, unsigned long end_pf
}
}
/* This allocation cannot fail */
#ifndef CONFIG_AMLOGIC_STD
region = memblock_alloc(sizeof(struct nosave_region),
SMP_CACHE_BYTES);
#else
if(!slab_is_available())
region = memblock_alloc(sizeof(struct nosave_region),
SMP_CACHE_BYTES);
else
region = kzalloc(sizeof(struct nosave_region), GFP_KERNEL);
#endif
if (!region)
panic("%s: Failed to allocate %zu bytes\n", __func__,
sizeof(struct nosave_region));
@@ -1733,7 +1741,11 @@ int hibernate_preallocate_memory(void)
{
struct zone *zone;
unsigned long saveable, size, max_size, count, highmem, pages = 0;
#ifdef CONFIG_AMLOGIC_STD
unsigned long alloc, save_highmem, pages_highmem, avail_normal, mini_pages;
#else
unsigned long alloc, save_highmem, pages_highmem, avail_normal;
#endif
ktime_t start, stop;
int error;
@@ -1798,6 +1810,9 @@ int hibernate_preallocate_memory(void)
/* Estimate the minimum size of the image. */
pages = minimum_image_size(saveable);
#ifdef CONFIG_AMLOGIC_STD
mini_pages = pages;
#endif
/*
* To avoid excessive pressure on the normal zone, leave room in it to
* accommodate an image of the minimum size (unless it's already too
@@ -1832,6 +1847,18 @@ int hibernate_preallocate_memory(void)
else
alloc = 0;
pages = preallocate_image_memory(alloc, avail_normal);
#ifdef CONFIG_AMLOGIC_STD
/*
* Define the mini_pages variable to be equivalent to the minimum size of
* the std function to create an image. pages represents the maximum number
* of pages that can be allocated. If pages is greater than mini_pages, it
* means there is enough space to store the std image and the pre-allocation
* is successful. Otherwise, it fails.
*/
if (pages >= mini_pages){
alloc = pages;
}
#endif
if (pages < alloc) {
/* We have exhausted non-highmem pages, try highmem. */
alloc -= pages;

View File

@@ -34,7 +34,16 @@
#include "power.h"
#ifdef CONFIG_AMLOGIC_STD
/*
* If the std function needs to use the same image every time it resumes,
* then set HIBERNATE_SIG to "SWAPSPACE2". This way, every time it resumes,
* as long as it is "SWAPSPACE2", it will go through the wakeup process.
*/
#define HIBERNATE_SIG "SWAPSPACE2"
#else
#define HIBERNATE_SIG "S1SUSPEND"
#endif
/*
* When reading an {un,}compressed image, we may restore pages in place,