Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eef9514c authored by jiangjia's avatar jiangjia Committed by Gerrit - the friendly Code Review server
Browse files

soc: qcom: ssr: Add keep alive mechanism for subsystems



On some platforms like drones, subsystem should be alive
and running even though CPU panics or crashes. Add keep
alive support for subsystems to handle the special use case.

Change-Id: I1e59dc9bdc170db94195629420546d9f96485e0c
CRs-Fixed: 2005766
Signed-off-by: default avatarjiangjia <jiangjia@codeaurora.org>
parent 940f66df
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ struct restart_log {
 * @count: reference count of subsystem_get()/subsystem_put()
 * @id: ida
 * @restart_level: restart level (0 - panic, 1 - related, 2 - independent, etc.)
 * @keep_alive: whether keep alive during AP's panic
 * @restart_order: order of other devices this devices restarts with
 * @crash_count: number of times the device has crashed
 * @dentry: debugfs directory for this device
@@ -170,6 +171,7 @@ struct subsys_device {
	int count;
	int id;
	int restart_level;
	bool keep_alive;
	int crash_count;
	struct subsys_soc_restart_order *restart_order;
#ifdef CONFIG_DEBUG_FS
@@ -308,6 +310,31 @@ static ssize_t system_debug_store(struct device *dev,
	return orig_count;
}

static ssize_t keep_alive_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct subsys_device *subsys = to_subsys(dev);

	return snprintf(buf, PAGE_SIZE, "%d\n", subsys->keep_alive);
}

static ssize_t keep_alive_store(struct device *dev,
				struct device_attribute *attr, const char *buf,
				size_t count)
{
	struct subsys_device *subsys = to_subsys(dev);
	unsigned long value;

	if (kstrtoul(buf, 0, &value) != 0)
		return -EINVAL;
	if (value > 1)
		return -EINVAL;

	subsys->keep_alive = (bool)value;

	return count;
}

int subsys_get_restart_level(struct subsys_device *dev)
{
	return dev->restart_level;
@@ -350,6 +377,7 @@ static struct device_attribute subsys_attrs[] = {
	__ATTR(restart_level, 0644, restart_level_show, restart_level_store),
	__ATTR(firmware_name, 0644, firmware_name_show, firmware_name_store),
	__ATTR(system_debug, 0644, system_debug_show, system_debug_store),
	__ATTR(keep_alive, 0644, keep_alive_show, keep_alive_store),
	__ATTR_NULL,
};

@@ -1779,6 +1807,12 @@ static int subsys_panic(struct device *dev, void *data)
{
	struct subsys_device *subsys = to_subsys(dev);

	/* Keeping the subsys alive during panic */
	if (!panic_timeout && subsys->keep_alive) {
		dev_warn(dev, "keeping %s alive\n", subsys->desc->name);
		return 0;
	}

	if (subsys->desc->crash_shutdown)
		subsys->desc->crash_shutdown(subsys->desc);
	return 0;