Commit b879d6d2 authored by Zwane Mwaikambo's avatar Zwane Mwaikambo Committed by Linus Torvalds

[PATCH] OProfile: ARM/XScale1 PMU support fix

Richard Purdie provided a patch to fix support for XScale1 processors (this
is the PMU version i never had access to initially), we weren't clearing
the overflow flags after an overflow interrupt had triggered resulting in
no additional interrupts occuring.  Additionally i've added basic power
management support.
Signed-off-by: default avatarZwane Mwaikambo <zwane@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a3cc2546
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/oprofile.h> #include <linux/oprofile.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <linux/sysdev.h>
#include "op_counter.h" #include "op_counter.h"
#include "op_arm_model.h" #include "op_arm_model.h"
...@@ -25,6 +26,26 @@ static void pmu_stop(void); ...@@ -25,6 +26,26 @@ static void pmu_stop(void);
static int pmu_create_files(struct super_block *, struct dentry *); static int pmu_create_files(struct super_block *, struct dentry *);
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int pmu_suspend(struct sys_device *dev, u32 state)
{
if (pmu_enabled)
pmu_stop();
return 0;
}
static int pmu_resume(struct sys_device *dev)
{
if (pmu_enabled)
pmu_start();
return 0;
}
static struct sysdev_class oprofile_sysclass = {
set_kset_name("oprofile"),
.resume = pmu_resume,
.suspend = pmu_suspend,
};
static struct sys_device device_oprofile = { static struct sys_device device_oprofile = {
.id = 0, .id = 0,
.cls = &oprofile_sysclass, .cls = &oprofile_sysclass,
...@@ -35,14 +56,14 @@ static int __init init_driverfs(void) ...@@ -35,14 +56,14 @@ static int __init init_driverfs(void)
int ret; int ret;
if (!(ret = sysdev_class_register(&oprofile_sysclass))) if (!(ret = sysdev_class_register(&oprofile_sysclass)))
ret = sys_device_register(&device_oprofile); ret = sysdev_register(&device_oprofile);
return ret; return ret;
} }
static void __exit exit_driverfs(void) static void exit_driverfs(void)
{ {
sys_device_unregister(&device_oprofile); sysdev_unregister(&device_oprofile);
sysdev_class_unregister(&oprofile_sysclass); sysdev_class_unregister(&oprofile_sysclass);
} }
#else #else
...@@ -105,8 +126,7 @@ static void pmu_stop(void) ...@@ -105,8 +126,7 @@ static void pmu_stop(void)
up(&pmu_sem); up(&pmu_sem);
} }
int __init int __init pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec)
pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec)
{ {
init_MUTEX(&pmu_sem); init_MUTEX(&pmu_sem);
......
...@@ -24,6 +24,6 @@ struct op_arm_model_spec { ...@@ -24,6 +24,6 @@ struct op_arm_model_spec {
extern struct op_arm_model_spec op_xscale_spec; extern struct op_arm_model_spec op_xscale_spec;
#endif #endif
extern int pmu_init(struct oprofile_operations **ops, struct op_arm_model_spec *spec); extern int __init pmu_init(struct oprofile_operations *ops, struct op_arm_model_spec *spec);
extern void pmu_exit(void); extern void pmu_exit(void);
#endif /* OP_ARM_MODEL_H */ #endif /* OP_ARM_MODEL_H */
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
#ifdef CONFIG_ARCH_IOP331 #ifdef CONFIG_ARCH_IOP331
#define XSCALE_PMU_IRQ IRQ_IOP331_CORE_PMU #define XSCALE_PMU_IRQ IRQ_IOP331_CORE_PMU
#endif #endif
#ifdef CONFIG_ARCH_PXA
#define XSCALE_PMU_IRQ IRQ_PMU
#endif
/* /*
* Different types of events that can be counted by the XScale PMU * Different types of events that can be counted by the XScale PMU
...@@ -305,9 +308,9 @@ static void inline __xsc1_check_ctrs(void) ...@@ -305,9 +308,9 @@ static void inline __xsc1_check_ctrs(void)
/* Overflow bit gets cleared. There's no workaround. */ /* Overflow bit gets cleared. There's no workaround. */
/* Fixed in B stepping or later */ /* Fixed in B stepping or later */
pmnc &= ~(PMU_ENABLE | pmu->cnt_ovf[PMN0] | pmu->cnt_ovf[PMN1] | /* Write the value back to clear the overflow flags. Overflow */
pmu->cnt_ovf[CCNT]); /* flags remain in pmnc for use below */
write_pmnc(pmnc); write_pmnc(pmnc & ~PMU_ENABLE);
for (i = CCNT; i <= PMN1; i++) { for (i = CCNT; i <= PMN1; i++) {
if (!(pmu->int_mask[i] & pmu->int_enable)) if (!(pmu->int_mask[i] & pmu->int_enable))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment