summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2021-10-31 17:57:07 +0800
committerCommit Bot <commit-bot@chromium.org>2021-11-03 01:06:49 +0000
commitfc78be657fbfc913ac5cd2441b566fd7de7b9fda (patch)
treee102ef8d917c8bbab923504bc19c0415330e2a34
parentd1275d73707dd0020ac0c5dc2a6a7769cdc7b188 (diff)
downloadchrome-ec-fc78be657fbfc913ac5cd2441b566fd7de7b9fda.tar.gz
CEC: move mkbp event to the cec task
The interrupt context can't call the function which contains the mutex. In order to fix this problem, we move the send_mkbp_event to the task level and add two events TASK_EVENT_OKAY, TASK_EVENT_FAILED to indicated the okay/failed event. BUG=b:204138787 BRANCH=None TEST=`cec-ctl --playback -S -d 0` without ec crash Change-Id: Ifae592c2161e78cd2a1be4af6e0a30b615ae9f37 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3251219 Reviewed-by: Boris Mittelberg <bmbm@google.com> Commit-Queue: Boris Mittelberg <bmbm@google.com>
-rw-r--r--chip/npcx/cec.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/chip/npcx/cec.c b/chip/npcx/cec.c
index ebaefa551a..77bfacd163 100644
--- a/chip/npcx/cec.c
+++ b/chip/npcx/cec.c
@@ -35,6 +35,8 @@
/* Notification from interrupt to CEC task that data has been received */
#define TASK_EVENT_RECEIVED_DATA TASK_EVENT_CUSTOM_BIT(0)
+#define TASK_EVENT_OKAY TASK_EVENT_CUSTOM_BIT(1)
+#define TASK_EVENT_FAILED TASK_EVENT_CUSTOM_BIT(2)
/* CEC broadcast address. Also the highest possible CEC address */
#define CEC_BROADCAST_ADDR 15
@@ -592,7 +594,8 @@ static void cec_event_timeout(void)
cec_tx.len = 0;
cec_tx.resends = 0;
enter_state(CEC_STATE_IDLE);
- send_mkbp_event(EC_MKBP_CEC_SEND_OK);
+ task_set_event(TASK_ID_CEC,
+ TASK_EVENT_OKAY);
}
} else {
if (cec_tx.resends < CEC_MAX_RESENDS) {
@@ -604,7 +607,8 @@ static void cec_event_timeout(void)
cec_tx.len = 0;
cec_tx.resends = 0;
enter_state(CEC_STATE_IDLE);
- send_mkbp_event(EC_MKBP_CEC_SEND_FAILED);
+ task_set_event(TASK_ID_CEC,
+ TASK_EVENT_FAILED);
}
}
break;
@@ -1036,5 +1040,12 @@ void cec_task(void *unused)
if (rv == EC_SUCCESS)
mkbp_send_event(EC_MKBP_EVENT_CEC_MESSAGE);
}
+ if (events & TASK_EVENT_OKAY) {
+ send_mkbp_event(EC_MKBP_CEC_SEND_OK);
+ CPRINTS("SEND OKAY");
+ } else if (events & TASK_EVENT_FAILED) {
+ send_mkbp_event(EC_MKBP_CEC_SEND_FAILED);
+ CPRINTS("SEND FAILED");
+ }
}
}