Skip to content

Commit 0478215

Browse files
author
Josh Tsai
committed
Reduced the frequency to execute the PECI over eSPI transaction
We observed there are three functions that execute the PECI over the eSPI transaction. If one transaction is fail, EC will retry the transaction for a short time and this phenomenon will cause the below issue: 1. System warm boot hang 2. Type-C port loss function 3. System power on the first time fail (after removing coin battery, batt, and ac) 4. stress test fail (power on too slow) We read the peci gettemp via hook_second and store the value in the global variant, and bypass the variant value to other functions Signed-off-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com>
1 parent 458090b commit 0478215

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

board/hx30/peci_customization.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "chipset.h"
77
#include "console.h"
88
#include "board.h"
9+
#include "hooks.h"
910
#include "host_command.h"
1011
#include "peci.h"
1112
#include "peci_customization.h"
@@ -16,6 +17,8 @@
1617
#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
1718
#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
1819

20+
static int peci_temp;
21+
1922
/*****************************************************************************/
2023
/* Internal functions */
2124

@@ -250,22 +253,36 @@ __override int stop_read_peci_temp(void)
250253

251254
int peci_over_espi_temp_sensor_get_val(int idx, int *temp_ptr)
252255
{
253-
int i, rv;
256+
if (peci_temp == 0xfffe)
257+
return EC_ERROR_NOT_POWERED;
258+
259+
if (peci_temp == 0xffff)
260+
return EC_ERROR_INVAL;
261+
262+
*temp_ptr = peci_temp;
263+
264+
return EC_SUCCESS;
265+
}
266+
267+
void read_peci_over_espi_gettemp(void)
268+
{
269+
int rv;
270+
int i;
254271

255272
rv = stop_read_peci_temp();
256273

257-
if (rv != EC_SUCCESS)
258-
return rv;
274+
if (rv != EC_SUCCESS) {
275+
peci_temp = 0xfffe;
276+
} else {
277+
for (i = 0; i < 2; i++) {
278+
rv = peci_over_espi_get_cpu_temp(&peci_temp);
279+
if (!rv)
280+
break;
281+
msleep(10);
282+
}
259283

260-
/*
261-
* Retry reading PECI CPU temperature if the first sample is
262-
* invalid or failed to obtain.
263-
*/
264-
for (i = 0; i < 2; i++) {
265-
rv = peci_over_espi_get_cpu_temp(temp_ptr);
266-
if (!rv)
267-
break;
284+
if (rv != EC_SUCCESS)
285+
peci_temp = 0xffff;
268286
}
269-
270-
return rv;
271287
}
288+
DECLARE_HOOK(HOOK_SECOND, read_peci_over_espi_gettemp, HOOK_PRIO_DEFAULT);

board/hx30/peci_customization.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@ int peci_update_PL1(int watt);
6060
int peci_update_PL2(int watt);
6161
int peci_update_PL4(int watt);
6262
int peci_update_PsysPL2(int watt);
63+
64+
/**
65+
* This function return the peci gettemp value from global variant, the
66+
* actually value is read from read_peci_over_espi_gettemp();
67+
*
68+
* @param idx no used
69+
* @param temp_ptr return temp value pointer
70+
* @return int return get value status
71+
*/
6372
int peci_over_espi_temp_sensor_get_val(int idx, int *temp_ptr);

0 commit comments

Comments
 (0)