[PATCH] platform/chrome: cros_ec_lpc: Sync filesystem on EC panic

From: Rob Barnes
Date: Wed Jul 26 2023 - 14:18:05 EST


Perform a filesystem sync when an EC panic is reported. The
sync is performed twice in case some inodes or pages are
temporarily locked. Testing showed syncing twice significantly
improved reliability.

hw_protection_shutdown is replaced for a couple reasons. It is
unnecessary because the EC will force reset either way.
hw_protection_shutdown does not reliably sync filesystem
before shutting down.

Signed-off-by: Rob Barnes <robbarnes@xxxxxxxxxx>
---

drivers/platform/chrome/cros_ec_lpc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c
index 500a61b093e47..44b7637e745c2 100644
--- a/drivers/platform/chrome/cros_ec_lpc.c
+++ b/drivers/platform/chrome/cros_ec_lpc.c
@@ -327,8 +327,10 @@ static void cros_ec_lpc_acpi_notify(acpi_handle device, u32 value, void *data)
dev_emerg(ec_dev->dev, "CrOS EC Panic Reported. Shutdown is imminent!");
blocking_notifier_call_chain(&ec_dev->panic_notifier, 0, ec_dev);
kobject_uevent_env(&ec_dev->dev->kobj, KOBJ_CHANGE, (char **)env);
- /* Begin orderly shutdown. Force shutdown after 1 second. */
- hw_protection_shutdown("CrOS EC Panic", 1000);
+ /* Sync filesystem before EC resets */
+ ksys_sync_helper();
+ /* Sync again just in case some inodes were temporarily locked */
+ ksys_sync_helper();
/* Do not query for other events after a panic is reported */
return;
}
--
2.41.0.487.g6d72f3e995-goog