intel/pmclib: Avoid PMC ABASE read of SLP_TYP and STATUS in ramstage

The patch updates platform_is_resuming() API such that platform resume
state is determined from the saved state (CBMEM) instead of checking PMC
registers (PM1_STS & PM1_CNT) as they are getting cleared (before/early)
ramstage.

coreboot sends DISCONNECT IPC command which times out during resume (S3)
if system has servoV4 connected on port0. The issue occurs only during
the first cycle of resume (S3) test cycle after cold boot due to side
effect of platform_is_resuming() API that is not determining the resume
(S3) state correctly in ramstage.

PM1_STS and PM1_CNT register gets cleared at the start of ramstage.
platform_is_resuming() function was checks the cleared register value
and fails the condition of resume (S3) resulting in sending DISCONNECT
IPC command. Checking the platform resume state from the CBMEM saved
state using acpe_get_sleep_type() function helps cross verify the
system previous state at the later part of ramstage.

localhost ~ # cbmem -c | grep ERROR
[ERROR]  EC returned error result code 3
[ERROR]  PMC IPC timeout after 1000 ms
[ERROR]  PMC IPC command 0x200a7 failed
[ERROR]  pmc_send_ipc_cmd failed
[ERROR]  Failed to setup port:0 to initial state
[ERROR]  PMC IPC timeout after 1000 ms
[ERROR]  PMC IPC command 0x200a7 failed
[ERROR]  pmc_send_ipc_cmd failed
[ERROR]  Failed to setup port:1 to initial state
[ERROR]  GENERIC: 0.0 missing read_resources
[ERROR]  PMC IPC timeout after 1000 ms
[ERROR]  PMC IPC command 0xd0 failed
[ERROR]  PMC: Failed sending PCI Enumeration Done Command

BUG=b:227289581
TEST=Verified system boots to OS and verified below tests on
Redrix (ADL-P) and Nivviks (ADL-N)
1. coreboot doesn't send the DISCONNECT during S3 resume
2. suspend S3 passes with both suzyq and servoV4 connected
3. After S3 resume, system detects the pen drive with Superspeed
4. After system resumes from S3, hot-plug the pen drive, system detects
   the pen drive

Signed-off-by: Harsha B R <harsha.b.r@intel.com>
Change-Id: I353ab49073bc4b5288943e19a75efa04bd809227
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66126
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Sridhar Siricilla <sridhar.siricilla@intel.com>
Reviewed-by: Krishna P Bhat D <krishna.p.bhat.d@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Harsha B R 2022-07-25 17:24:37 +05:30 committed by Paul Fagerburg
parent 59b9d96d62
commit 5754eade4a
1 changed files with 5 additions and 0 deletions

View File

@ -475,6 +475,11 @@ void pmc_global_reset_enable(bool enable)
int platform_is_resuming(void)
{
/* Read power state from PMC data structure */
if (ENV_RAMSTAGE)
return acpi_get_sleep_type() == ACPI_S3;
/* Read power state from PMC ABASE */
if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS))
return 0;