Skip to content

Commit e9b421b

Browse files
Josh-TsaiJohnAZoidberg
authored andcommitted
fwk: ucsi: do not process the ucsi if no active pd chip
If there is no active pd chip exist, the *cci and *message_in will not point to the correct address and cause the EC panic. This change adds the condition to avoid the data point to the wrong address. BRANCH=fwk-main BUG=EC panic when process the ucsi data TEST=EC will not process the ucsi data if no active pd chip. Signed-off-by: Josh Tsai <Josh_Tsai@compal.com> (cherry picked from commit de061e56e2ac5224c1b63a77197d49e7be34ae79)
1 parent 4571be8 commit e9b421b

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

  • zephyr/program/framework/src

zephyr/program/framework/src/ucsi.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ static void resend_ucsi_connector_change_event(void)
243243
static int process_port = 1;
244244
static int resume_flag;
245245

246+
/* If no active pd chip, don't process the UCSI data */
247+
if (active_pd_chip_count == 0)
248+
return;
249+
246250
if (s0ix_connector_change_indicator == 0) {
247251
process_port = 1;
248252
resume_flag = 0;
@@ -491,6 +495,10 @@ void check_ucsi_event_from_host(void)
491495
int i;
492496
int rv;
493497

498+
/* If no active pd chip, don't process the UCSI data */
499+
if (active_pd_chip_count == 0)
500+
return;
501+
494502
if (read_complete == 0 && !timestamp_expired(ucsi_wait_time, NULL)) {
495503
if (ucsi_debug_enable)
496504
CPRINTS("UCSI waiting for time expired");
@@ -667,13 +675,25 @@ void ucsi_pd_port_mapping(void)
667675
}
668676
}
669677

678+
/**
679+
* CHIPSET_RESET for warmboot/coldboot
680+
* CHIPSET_INIT for first power on
681+
*/
670682
void setup_ucsi_pd_mapping(void)
671683
{
672-
active_pd_chip_count = cypd_get_active_pd_chip_count();
673-
ucsi_pd_port_mapping();
674-
if (ucsi_debug_enable) {
675-
CPRINTS("PD mapping setup: active_chips=%d, valid_ports=%d",
676-
active_pd_chip_count, valid_ucsi_port_count);
684+
int pd_chip_count = cypd_get_active_pd_chip_count();
685+
686+
if (pd_chip_count == 0)
687+
CPRINTS("WARNNING: No active PD chip");
688+
689+
if (active_pd_chip_count != pd_chip_count) {
690+
active_pd_chip_count = pd_chip_count;
691+
ucsi_pd_port_mapping();
692+
if (ucsi_debug_enable) {
693+
CPRINTS("PD mapping setup: active_chips=%d, valid_ports=%d",
694+
active_pd_chip_count, valid_ucsi_port_count);
695+
}
677696
}
678697
}
679698
DECLARE_HOOK(HOOK_CHIPSET_RESET, setup_ucsi_pd_mapping, HOOK_PRIO_DEFAULT);
699+
DECLARE_HOOK(HOOK_INIT, setup_ucsi_pd_mapping, HOOK_PRIO_DEFAULT);

0 commit comments

Comments
 (0)