From c2f6da00f458f03dd19ee6256e959da4c26c987f Mon Sep 17 00:00:00 2001 From: Marshall Dawson Date: Mon, 4 Dec 2017 15:28:10 -0700 Subject: soc/amd/common: Add S3 resume functions to wrapper Add new functions that can execute InitRtb, InitResume, LateResume, and FinalResume. Note that the name AmdInitRtb supersedes the deprecated AmdS3Save. TEST=Suspend/Resume Kahlee with complete S3 patch stack BUG=b:69614064 Change-Id: I5c6a9c1a679a1c4d3f7d1d3b41a32efd0a2c2c01 Signed-off-by: Marshall Dawson Reviewed-on: https://review.coreboot.org/22730 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- .../common/block/include/amdblocks/agesawrapper.h | 3 +- src/soc/amd/common/block/pi/agesawrapper.c | 137 +++++++++++++++++++++ src/soc/amd/common/block/pi/amd_late_init.c | 2 +- 3 files changed, 140 insertions(+), 2 deletions(-) (limited to 'src/soc/amd/common/block') diff --git a/src/soc/amd/common/block/include/amdblocks/agesawrapper.h b/src/soc/amd/common/block/include/amdblocks/agesawrapper.h index 5c2f4eb9dd..44ddba2018 100644 --- a/src/soc/amd/common/block/include/amdblocks/agesawrapper.h +++ b/src/soc/amd/common/block/include/amdblocks/agesawrapper.h @@ -43,9 +43,10 @@ AGESA_STATUS agesawrapper_amdinitmid(void); void *agesawrapper_getlateinitptr(int pick); AGESA_STATUS agesawrapper_amdlaterunaptask(UINT32 Func, UINTN Data, void *ConfigPtr); -AGESA_STATUS agesawrapper_amdS3Save(void); +AGESA_STATUS agesawrapper_amdinitrtb(void); AGESA_STATUS agesawrapper_amdinitresume(void); AGESA_STATUS agesawrapper_amds3laterestore(void); +AGESA_STATUS agesawrapper_amds3finalrestore(void); AGESA_STATUS agesawrapper_fchs3earlyrestore(void); AGESA_STATUS agesawrapper_fchs3laterestore(void); diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c index 66928fba25..dca72222ce 100644 --- a/src/soc/amd/common/block/pi/agesawrapper.c +++ b/src/soc/amd/common/block/pi/agesawrapper.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -374,6 +375,142 @@ AGESA_STATUS agesawrapper_amdlaterunaptask(UINT32 Func, UINTN Data, return Status; } +AGESA_STATUS agesawrapper_amdinitrtb(void) +{ + AGESA_STATUS Status; + AMD_INTERFACE_PARAMS AmdParamStruct = { + .AgesaFunctionName = AMD_INIT_RTB, + .AllocationMethod = PostMemDram, + .StdHeader.CalloutPtr = &GetBiosCallout, + }; + AMD_RTB_PARAMS *RtbParams; + + create_struct(&AmdParamStruct); + + RtbParams = (AMD_RTB_PARAMS *)AmdParamStruct.NewStructPtr; + + timestamp_add_now(TS_AGESA_INIT_RTB_START); + Status = AmdInitRtb(RtbParams); + timestamp_add_now(TS_AGESA_INIT_RTB_DONE); + + if (Status != AGESA_SUCCESS) { + agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus); + ASSERT(Status == AGESA_SUCCESS); + } + + if (save_s3_info(RtbParams->S3DataBlock.NvStorage, + RtbParams->S3DataBlock.NvStorageSize, + RtbParams->S3DataBlock.VolatileStorage, + RtbParams->S3DataBlock.VolatileStorageSize)) + printk(BIOS_ERR, "S3 data not saved, resuming impossible\n"); + + AmdReleaseStruct(&AmdParamStruct); + + return Status; +} + +AGESA_STATUS agesawrapper_amdinitresume(void) +{ + AGESA_STATUS status; + AMD_INTERFACE_PARAMS AmdParamStruct = { + .AgesaFunctionName = AMD_INIT_RESUME, + .AllocationMethod = PreMemHeap, + .StdHeader.CalloutPtr = &GetBiosCallout, + }; + AMD_RESUME_PARAMS *InitResumeParams; + size_t nv_size; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + create_struct(&AmdParamStruct); + + InitResumeParams = (AMD_RESUME_PARAMS *)AmdParamStruct.NewStructPtr; + + get_s3nv_info(&InitResumeParams->S3DataBlock.NvStorage, &nv_size); + InitResumeParams->S3DataBlock.NvStorageSize = nv_size; + + timestamp_add_now(TS_AGESA_INIT_RESUME_START); + status = AmdInitResume(InitResumeParams); + timestamp_add_now(TS_AGESA_INIT_RESUME_DONE); + + if (status != AGESA_SUCCESS) + agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus); + AmdReleaseStruct(&AmdParamStruct); + + return status; +} + +AGESA_STATUS agesawrapper_amds3laterestore(void) +{ + AGESA_STATUS Status; + AMD_INTERFACE_PARAMS AmdParamStruct = { + .AgesaFunctionName = AMD_S3LATE_RESTORE, + .AllocationMethod = ByHost, + .StdHeader.CalloutPtr = &GetBiosCallout, + }; + AMD_S3LATE_PARAMS *S3LateParams; + size_t vol_size; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + amd_initcpuio(); + + create_struct(&AmdParamStruct); + + S3LateParams = (AMD_S3LATE_PARAMS *)AmdParamStruct.NewStructPtr; + + get_s3vol_info(&S3LateParams->S3DataBlock.VolatileStorage, &vol_size); + S3LateParams->S3DataBlock.VolatileStorageSize = vol_size; + + timestamp_add_now(TS_AGESA_S3_LATE_START); + Status = AmdS3LateRestore(S3LateParams); + timestamp_add_now(TS_AGESA_S3_LATE_DONE); + + if (Status != AGESA_SUCCESS) { + agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus); + ASSERT(Status == AGESA_SUCCESS); + } + AmdReleaseStruct(&AmdParamStruct); + + return Status; +} + +AGESA_STATUS agesawrapper_amds3finalrestore(void) +{ + AGESA_STATUS Status; + AMD_INTERFACE_PARAMS AmdParamStruct = { + .AgesaFunctionName = AMD_S3FINAL_RESTORE, + .AllocationMethod = ByHost, + .StdHeader.CalloutPtr = &GetBiosCallout, + }; + AMD_S3FINAL_PARAMS *S3FinalParams; + size_t vol_size; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + create_struct(&AmdParamStruct); + + S3FinalParams = (AMD_S3FINAL_PARAMS *)AmdParamStruct.NewStructPtr; + + get_s3vol_info(&S3FinalParams->S3DataBlock.VolatileStorage, &vol_size); + S3FinalParams->S3DataBlock.VolatileStorageSize = vol_size; + + timestamp_add_now(TS_AGESA_S3_FINAL_START); + Status = AmdS3FinalRestore(S3FinalParams); + timestamp_add_now(TS_AGESA_S3_FINAL_DONE); + + if (Status != AGESA_SUCCESS) { + agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus); + ASSERT(Status == AGESA_SUCCESS); + } + AmdReleaseStruct(&AmdParamStruct); + + return Status; +} + static int agesa_locate_file(const char *name, struct region_device *rdev, uint32_t type) { diff --git a/src/soc/amd/common/block/pi/amd_late_init.c b/src/soc/amd/common/block/pi/amd_late_init.c index 3eb3674c09..3695ce4f51 100644 --- a/src/soc/amd/common/block/pi/amd_late_init.c +++ b/src/soc/amd/common/block/pi/amd_late_init.c @@ -33,7 +33,7 @@ static void agesawrapper_post_device(void *unused) if (!acpi_s3_resume_allowed()) return; - do_agesawrapper(agesawrapper_amdS3Save, "amdS3Save"); + do_agesawrapper(agesawrapper_amdinitrtb, "amdinitrtb"); } BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT, -- cgit v1.2.3