Skip to content

Commit 1858a37

Browse files
Josh-TsaiJohnAZoidberg
authored andcommitted
fwk: ucsi: don't resend the ucsi command if not enable the notification
EC will crash if the user plugs or unplugs a type-c device in the standby mode. The root cause is that EC will point to the wrong address if the first PD chip state is not powered. This change disables resend_ucsi_connector_change_event() function to avoid the wrong ucsi event being processed with the pure OS (no UCSI driver) I don't fix the wrong pointer issue with this change. This condition only for a workaround; the UCSI driver will be yellow bang if one PD chip is not powered on. So this issue does not happen on PD0 and PD1 are ready. BRANCH=fwk-main BUG=wrong pointer causes the EC crash TEST=plug or unplug a device in standby mode with pure OS, the EC does not crash. Signed-off-by: Josh Tsai <Josh_Tsai@compal.com> (cherry picked from commit fc05c40bf55b9caa5dd2c02bcf90c5bb73c0cc02)
1 parent e167e0d commit 1858a37

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • zephyr/program/framework/src

zephyr/program/framework/src/ucsi.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static bool read_complete;
3838
static int pd_ucsi_port_map[PD_PORT_COUNT];
3939
static int active_pd_chip_count;
4040
static int valid_ucsi_port_count;
41+
static bool ucsi_has_enabled_notification;
4142

4243
void ucsi_set_debug(bool enable)
4344
{
@@ -117,6 +118,7 @@ int ucsi_write_tunnel(void)
117118

118119
if (*command == UCSI_CMD_PPM_RESET) {
119120
cypd_usci_ppm_reset();
121+
ucsi_has_enabled_notification = false;
120122
CPRINTS("UCSI PPM_RESET");
121123
}
122124

@@ -132,8 +134,12 @@ int ucsi_write_tunnel(void)
132134
connector_number_offset) & 0x7f;
133135

134136
/* This command does not have a connector number field; it needs to broadcast. */
135-
if (*command == UCSI_CMD_SET_NOTIFICATION_ENABLE || *command == UCSI_CMD_ACK_CC_CI)
137+
if (*command == UCSI_CMD_SET_NOTIFICATION_ENABLE || *command == UCSI_CMD_ACK_CC_CI) {
138+
139+
if (*command == UCSI_CMD_SET_NOTIFICATION_ENABLE)
140+
ucsi_has_enabled_notification = true;
136141
change_connector_indicator = 0;
142+
}
137143

138144
/* Print the invalid port for debugging */
139145
if (change_connector_indicator > valid_ucsi_port_count) {
@@ -247,8 +253,8 @@ static void resend_ucsi_connector_change_event(void)
247253
static int process_port = 1;
248254
static int resume_flag;
249255

250-
/* If no active pd chip, don't process the UCSI data */
251-
if (active_pd_chip_count == 0)
256+
/* If no active pd chip or no enable notification, don't process the UCSI data */
257+
if (active_pd_chip_count == 0 || !ucsi_has_enabled_notification)
252258
return;
253259

254260
if (s0ix_connector_change_indicator == 0) {

0 commit comments

Comments
 (0)