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

Commit 83786094 authored by Anji Jonnala's avatar Anji Jonnala
Browse files

msm: thermal: Store temperature of tsens on kernel panic notification



Register KTM with panic notifier with a callback on boot and
on callback store all tsens temperature into static variable.
This will help rule out or confirm role of thermal for any
kernel crash.

Change-Id: Idb1315e08c82e50c31cf0aff2c4310162d33c7a2
Signed-off-by: default avatarAnji Jonnala <anjir@codeaurora.org>
parent ff447714
Loading
Loading
Loading
Loading
+42 −2
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ static struct attribute_group mx_attr_group;
static struct regulator *vdd_mx;
static struct cpufreq_frequency_table *pending_freq_table_ptr;
static int pending_cpu_freq = -1;
static long *tsens_temp_at_panic;

enum thermal_threshold {
	HOTPLUG_THRESHOLD_HIGH,
@@ -1595,6 +1596,23 @@ get_temp_exit:
	return ret;
}

static int msm_thermal_panic_callback(struct notifier_block *nfb,
			unsigned long event, void *data)
{
	int i;

	for (i = 0; i < max_tsens_num; i++)
		therm_get_temp(tsens_id_map[i],
				THERM_TSENS_ID,
				&tsens_temp_at_panic[i]);

	return NOTIFY_OK;
}

static struct notifier_block msm_thermal_panic_notifier = {
	.notifier_call = msm_thermal_panic_callback,
};

static int set_threshold(uint32_t zone_id,
	struct sensor_threshold *threshold)
{
@@ -3652,7 +3670,26 @@ done_mx_nodes:
	return ret;
}

int msm_thermal_pre_init(void)
static void msm_thermal_panic_notifier_init(struct device *dev)
{
	int i;

	tsens_temp_at_panic = devm_kzalloc(dev,
				sizeof(long) * max_tsens_num,
				GFP_KERNEL);
	if (!tsens_temp_at_panic) {
		pr_err("kzalloc failed\n");
		return;
	}

	for (i = 0; i < max_tsens_num; i++)
		tsens_temp_at_panic[i] = LONG_MIN;

	atomic_notifier_chain_register(&panic_notifier_list,
		&msm_thermal_panic_notifier);
}

int msm_thermal_pre_init(struct device *dev)
{
	int ret = 0;

@@ -3673,6 +3710,9 @@ int msm_thermal_pre_init(void)
		goto pre_init_exit;
	}

	if (!tsens_temp_at_panic)
		msm_thermal_panic_notifier_init(dev);

	if (!thresh) {
		thresh = kzalloc(
				sizeof(struct threshold_info) * MSM_LIST_MAX_NR,
@@ -4813,7 +4853,7 @@ static int msm_thermal_dev_probe(struct platform_device *pdev)
	memset(&data, 0, sizeof(struct msm_thermal_data));
	data.pdev = pdev;

	ret = msm_thermal_pre_init();
	ret = msm_thermal_pre_init(&pdev->dev);
	if (ret) {
		pr_err("thermal pre init failed. err:%d\n", ret);
		goto fail;