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

Commit a69241d1 authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

msm: thermal: Remove alarm support in KTM



Remove the alarm support from kernel thermal monitor(KTM).
Alternatively, the userspace processes uses POSIX timer
API's for alarm in msm-3.10 kernel.

CRs-Fixed: 538952
Change-Id: Ib57ebdef22c2d9f904b98287e5cf483fd3c7531f
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent 36981829
Loading
Loading
Loading
Loading
+0 −122
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#include <linux/of.h>
#include <linux/sysfs.h>
#include <linux/types.h>
#include <linux/alarmtimer.h>
#include <linux/thermal.h>
#include <mach/rpm-regulator.h>
#include <mach/rpm-regulator-smd.h>
@@ -44,11 +43,7 @@ static struct delayed_work check_temp_work;
static bool core_control_enabled;
static uint32_t cpus_offlined;
static DEFINE_MUTEX(core_control_mutex);
static uint32_t wakeup_ms;
static struct alarm thermal_rtc;
static struct kobject *tt_kobj;
static struct kobject *cc_kobj;
static struct work_struct timer_work;
static struct task_struct *hotplug_task;
static struct task_struct *freq_mitigation_task;
static struct completion hotplug_notify_complete;
@@ -1023,36 +1018,6 @@ static int __ref msm_thermal_cpu_callback(struct notifier_block *nfb,
static struct notifier_block __refdata msm_thermal_cpu_notifier = {
	.notifier_call = msm_thermal_cpu_callback,
};

static void thermal_rtc_setup(void)
{
	ktime_t wakeup_time = { .tv64 = 0 };

	wakeup_time = ktime_add_us(wakeup_time, wakeup_ms * USEC_PER_MSEC);
	alarm_start_relative(&thermal_rtc, wakeup_time);
	pr_debug("%s: Alarm set to: %ld %ld\n",
			KBUILD_MODNAME,
			ktime_to_timeval(wakeup_time).tv_sec,
			ktime_to_timeval(wakeup_time).tv_usec);

}

static void timer_work_fn(struct work_struct *work)
{
	sysfs_notify(tt_kobj, NULL, "wakeup_ms");
}

static enum alarmtimer_restart
thermal_rtc_callback(struct alarm *al, ktime_t now)
{
	struct timeval ts;
	ts = ktime_to_timeval(now);
	schedule_work(&timer_work);
	pr_debug("%s: Time on alarm expiry: %ld %ld\n", KBUILD_MODNAME,
			ts.tv_sec, ts.tv_usec);
	return ALARMTIMER_NORESTART;
}

static int hotplug_notify(enum thermal_trip_type type, int temp, void *data)
{
	struct cpu_info *cpu_node = (struct cpu_info *)data;
@@ -1430,53 +1395,6 @@ static __refdata struct attribute *cc_attrs[] = {
static __refdata struct attribute_group cc_attr_group = {
	.attrs = cc_attrs,
};

static ssize_t show_wakeup_ms(struct kobject *kobj,
		struct kobj_attribute *attr, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n", wakeup_ms);
}

static ssize_t store_wakeup_ms(struct kobject *kobj,
		struct kobj_attribute *attr, const char *buf, size_t count)
{
	int ret;
	ret = kstrtouint(buf, 10, &wakeup_ms);

	if (ret) {
		pr_err("%s: Trying to set invalid wakeup timer\n",
				KBUILD_MODNAME);
		return ret;
	}

	if (wakeup_ms > 0) {
		thermal_rtc_setup();
		pr_debug("%s: Timer started for %ums\n", KBUILD_MODNAME,
				wakeup_ms);
	} else {
		ret = alarm_cancel(&thermal_rtc);
		if (ret)
			pr_debug("%s: Timer canceled\n", KBUILD_MODNAME);
		else
			pr_debug("%s: No active timer present to cancel\n",
					KBUILD_MODNAME);

	}
	return count;
}

static __refdata struct kobj_attribute timer_attr =
__ATTR(wakeup_ms, 0644, show_wakeup_ms, store_wakeup_ms);

static __refdata struct attribute *tt_attrs[] = {
	&timer_attr.attr,
	NULL,
};

static __refdata struct attribute_group tt_attr_group = {
	.attrs = tt_attrs,
};

static __init int msm_thermal_add_cc_nodes(void)
{
	struct kobject *module_kobj = NULL;
@@ -1511,42 +1429,6 @@ done_cc_nodes:
		kobject_del(cc_kobj);
	return ret;
}

static __init int msm_thermal_add_timer_nodes(void)
{
	struct kobject *module_kobj = NULL;
	int ret = 0;

	module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME);
	if (!module_kobj) {
		pr_err("%s: cannot find kobject for module\n",
			KBUILD_MODNAME);
		ret = -ENOENT;
		goto failed;
	}

	tt_kobj = kobject_create_and_add("thermal_timer", module_kobj);
	if (!tt_kobj) {
		pr_err("%s: cannot create timer kobj\n",
				KBUILD_MODNAME);
		ret = -ENOMEM;
		goto failed;
	}

	ret = sysfs_create_group(tt_kobj, &tt_attr_group);
	if (ret) {
		pr_err("%s: cannot create group\n", KBUILD_MODNAME);
		goto failed;
	}

	return 0;

failed:
	if (tt_kobj)
		kobject_del(tt_kobj);
	return ret;
}

int msm_thermal_init(struct msm_thermal_data *pdata)
{
	int ret = 0;
@@ -2214,10 +2096,6 @@ int __init msm_thermal_late_init(void)
		msm_thermal_add_cc_nodes();
	msm_thermal_add_psm_nodes();
	msm_thermal_add_vdd_rstr_nodes();
	alarm_init(&thermal_rtc, ALARM_REALTIME, thermal_rtc_callback);
	INIT_WORK(&timer_work, timer_work_fn);
	msm_thermal_add_timer_nodes();

	return 0;
}
late_initcall(msm_thermal_late_init);