Skip to content

Commit

Permalink
peci: Clear status on completion
Browse files Browse the repository at this point in the history
The PECI-over-eSPI implementation, like the legacy implementation, must
acknowledge when the transaction is done by clearing the bit in the
register.

Fixes a hang during shutdown on oryp11 after unplugging a TBT display.

Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed Jun 21, 2023
1 parent c7288a5 commit dd555b9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/board/system76/common/peci.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ bool peci_get_temp(int16_t *data) {
return false;
}
}
// Clear upstream done status
ESUCTRL0 = ESUCTRL0_DONE;

// Wait for response
//TODO: do this asynchronously to avoid delays?
Expand All @@ -155,10 +157,14 @@ bool peci_get_temp(int16_t *data) {
uint8_t low = PUTOOBDB[5];
uint8_t high = PUTOOBDB[6];
*data = (((int16_t)high << 8) | (int16_t)low);
// Clear PUT_OOB status
ESOCTRL0 = ESOCTRL0_STATUS;
return true;
} else {
// Did not receive enough data
DEBUG("peci_get_temp: len %d < 7\n", len);
// Clear PUT_OOB status
ESOCTRL0 = ESOCTRL0_STATUS;
return false;
}
}
Expand Down Expand Up @@ -223,6 +229,8 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
return false;
}
}
// Clear upstream done status
ESUCTRL0 = ESUCTRL0_DONE;

// Wait for response
//TODO: do this asynchronously to avoid delays?
Expand All @@ -242,6 +250,10 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {

// Received enough data for status code
int16_t cc = (int16_t)PUTOOBDB[5];

// Clear PUT_OOB status
ESOCTRL0 = ESOCTRL0_STATUS;

if (cc & 0x80) {
return -cc;
} else {
Expand All @@ -250,6 +262,8 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
} else {
// Did not receive enough data
DEBUG("peci_wr_pkg_config: len %d < 6\n", len);
// Clear PUT_OOB status
ESOCTRL0 = ESOCTRL0_STATUS;
return -0x1000;
}
}
Expand Down

0 comments on commit dd555b9

Please sign in to comment.