platform/chrome: cros_ec_rpmsg: Fix race with host event
authorPi-Hsun Shih <pihsun@chromium.org>
Fri, 14 Feb 2020 08:26:38 +0000 (16:26 +0800)
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>
Mon, 2 Mar 2020 10:04:04 +0000 (11:04 +0100)
commitf775ac78fcfc6bdc96bdda07029d11f2a5e84869
tree7cce4a5be5e5b40d43071d069b34527143904014
parent42cd0ab476e2daffc23982c37822a78f9a53cdd5
platform/chrome: cros_ec_rpmsg: Fix race with host event

Host event can be sent by remoteproc by any time, and
cros_ec_rpmsg_callback would be called after cros_ec_rpmsg_create_ept.
But the cros_ec_device is initialized after that, which cause host event
handler to use cros_ec_device that are not initialized properly yet.

Fix this by don't schedule host event handler before cros_ec_register
returns. Instead, remember that we have a pending host event, and
schedule host event handler after cros_ec_register.

Fixes: 71cddb7097e2 ("platform/chrome: cros_ec_rpmsg: Fix race with host command when probe failed.")
Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
drivers/platform/chrome/cros_ec_rpmsg.c