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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Apr 2020 07:04:51 +0000 (09:04 +0200)
commit8078d3af4af79828a228243b734a499d78986cc6
treeddbf5c88b7983e5ff6b24c3cefb6d8dc318b9c1c
parent777c8c9f11a829ee8de93df285fad9e28d3b8835
platform/chrome: cros_ec_rpmsg: Fix race with host event

commit f775ac78fcfc6bdc96bdda07029d11f2a5e84869 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/platform/chrome/cros_ec_rpmsg.c