2008-12-16 08:33:53 +08:00
|
|
|
/*
|
|
|
|
* arch/sh/oprofile/init.c
|
|
|
|
*
|
2010-10-13 02:46:25 +08:00
|
|
|
* Copyright (C) 2003 - 2010 Paul Mundt
|
2008-12-16 08:33:53 +08:00
|
|
|
*
|
|
|
|
* Based on arch/mips/oprofile/common.c:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004, 2005 Ralf Baechle
|
|
|
|
* Copyright (C) 2005 MIPS Technologies, Inc.
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/oprofile.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/smp.h>
|
2010-09-11 03:36:23 +08:00
|
|
|
#include <linux/perf_event.h>
|
2010-10-13 02:46:25 +08:00
|
|
|
#include <linux/slab.h>
|
2008-12-16 08:33:53 +08:00
|
|
|
#include <asm/processor.h>
|
|
|
|
|
2010-09-11 03:36:23 +08:00
|
|
|
#ifdef CONFIG_HW_PERF_EVENTS
|
2008-12-16 08:35:40 +08:00
|
|
|
extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
|
|
|
|
|
2010-10-13 02:46:25 +08:00
|
|
|
/*
|
|
|
|
* This will need to be reworked when multiple PMUs are supported.
|
|
|
|
*/
|
|
|
|
static char *sh_pmu_op_name;
|
|
|
|
|
2010-09-11 03:36:23 +08:00
|
|
|
char *op_name_from_perf_id(void)
|
2008-12-16 08:33:53 +08:00
|
|
|
{
|
2010-10-13 02:46:25 +08:00
|
|
|
return sh_pmu_op_name;
|
2008-12-16 08:33:53 +08:00
|
|
|
}
|
|
|
|
|
2010-09-11 03:36:23 +08:00
|
|
|
int __init oprofile_arch_init(struct oprofile_operations *ops)
|
2008-12-16 08:33:53 +08:00
|
|
|
{
|
2010-09-11 03:36:23 +08:00
|
|
|
ops->backtrace = sh_backtrace;
|
2008-12-16 08:33:53 +08:00
|
|
|
|
2010-10-13 02:46:25 +08:00
|
|
|
if (perf_num_counters() == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
sh_pmu_op_name = kasprintf(GFP_KERNEL, "%s/%s",
|
|
|
|
UTS_MACHINE, perf_pmu_name());
|
|
|
|
if (unlikely(!sh_pmu_op_name))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-09-11 03:36:23 +08:00
|
|
|
return oprofile_perf_init(ops);
|
2008-12-16 08:33:53 +08:00
|
|
|
}
|
|
|
|
|
2010-09-11 03:36:23 +08:00
|
|
|
void __exit oprofile_arch_exit(void)
|
2008-12-16 08:33:53 +08:00
|
|
|
{
|
2010-09-11 03:36:23 +08:00
|
|
|
oprofile_perf_exit();
|
2010-10-13 02:46:25 +08:00
|
|
|
kfree(sh_pmu_op_name);
|
2008-12-16 08:33:53 +08:00
|
|
|
}
|
2010-09-11 03:36:23 +08:00
|
|
|
#else
|
2008-12-16 08:33:53 +08:00
|
|
|
int __init oprofile_arch_init(struct oprofile_operations *ops)
|
|
|
|
{
|
2010-09-11 03:36:23 +08:00
|
|
|
pr_info("oprofile: hardware counters not available\n");
|
|
|
|
return -ENODEV;
|
2008-12-16 08:33:53 +08:00
|
|
|
}
|
2010-09-11 03:36:23 +08:00
|
|
|
void __exit oprofile_arch_exit(void) {}
|
|
|
|
#endif /* CONFIG_HW_PERF_EVENTS */
|