msm:rq_stats: Add hotplug disable attribute
Register for suspend and resume notifications from kernel. This should
be done as part of core_initcall so as to receive notification as close
as possible to the actual event. Add hotplug_disable attribute to
rq-stats node. Set/clear this attribute based on the suspend/resume events.
CRS-fixed: 452456
Change-Id: I76fee349b57f47df40785e9c2503e2e1cc6e064e
Signed-off-by: Archana Sathyakumar <asathyak@codeaurora.org>
diff --git a/arch/arm/mach-msm/msm_rq_stats.c b/arch/arm/mach-msm/msm_rq_stats.c
index d1538dd..1589623 100644
--- a/arch/arm/mach-msm/msm_rq_stats.c
+++ b/arch/arm/mach-msm/msm_rq_stats.c
@@ -31,6 +31,7 @@
#include <linux/tick.h>
#include <asm/smp_plat.h>
#include "acpuclock.h"
+#include <linux/suspend.h>
#define MAX_LONG_SIZE 24
#define DEFAULT_RQ_POLL_JIFFIES 1
@@ -206,6 +207,34 @@
return NOTIFY_OK;
}
+static int system_suspend_handler(struct notifier_block *nb,
+ unsigned long val, void *data)
+{
+ switch (val) {
+ case PM_POST_HIBERNATION:
+ case PM_POST_SUSPEND:
+ rq_info.hotplug_disabled = 0;
+ case PM_HIBERNATION_PREPARE:
+ case PM_SUSPEND_PREPARE:
+ rq_info.hotplug_disabled = 1;
+ break;
+ default:
+ return NOTIFY_DONE;
+ }
+ return NOTIFY_OK;
+}
+
+
+static ssize_t hotplug_disable_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ unsigned int val = 0;
+ val = rq_info.hotplug_disabled;
+ return snprintf(buf, MAX_LONG_SIZE, "%d\n", val);
+}
+
+static struct kobj_attribute hotplug_disabled_attr = __ATTR_RO(hotplug_disable);
+
static void def_work_fn(struct work_struct *work)
{
int64_t diff;
@@ -310,6 +339,7 @@
&def_timer_ms_attr.attr,
&run_queue_avg_attr.attr,
&run_queue_poll_ms_attr.attr,
+ &hotplug_disabled_attr.attr,
NULL,
};
@@ -358,6 +388,7 @@
rq_info.def_timer_jiffies = DEFAULT_DEF_TIMER_JIFFIES;
rq_info.rq_poll_last_jiffy = 0;
rq_info.def_timer_last_jiffy = 0;
+ rq_info.hotplug_disabled = 0;
ret = init_rq_attribs();
rq_info.init = 1;
@@ -380,3 +411,16 @@
return ret;
}
late_initcall(msm_rq_stats_init);
+
+static int __init msm_rq_stats_early_init(void)
+{
+ /* Bail out if this is not an SMP Target */
+ if (!is_smp()) {
+ rq_info.init = 0;
+ return -ENOSYS;
+ }
+
+ pm_notifier(system_suspend_handler, 0);
+ return 0;
+}
+core_initcall(msm_rq_stats_early_init);
diff --git a/include/linux/rq_stats.h b/include/linux/rq_stats.h
index 65d8e8f..0accf38 100644
--- a/include/linux/rq_stats.h
+++ b/include/linux/rq_stats.h
@@ -19,6 +19,7 @@
unsigned long rq_poll_total_jiffies;
unsigned long def_timer_last_jiffy;
unsigned int def_interval;
+ unsigned int hotplug_disabled;
int64_t def_start_time;
struct attribute_group *attr_group;
struct kobject *kobj;