aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/oprofile/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/oprofile/common.c')
-rw-r--r--arch/sh/oprofile/common.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/arch/sh/oprofile/common.c b/arch/sh/oprofile/common.c
index e10d89376f9b..b4c2d2b946dd 100644
--- a/arch/sh/oprofile/common.c
+++ b/arch/sh/oprofile/common.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/oprofile/init.c 2 * arch/sh/oprofile/init.c
3 * 3 *
4 * Copyright (C) 2003 - 2008 Paul Mundt 4 * Copyright (C) 2003 - 2010 Paul Mundt
5 * 5 *
6 * Based on arch/mips/oprofile/common.c: 6 * Based on arch/mips/oprofile/common.c:
7 * 7 *
@@ -18,43 +18,46 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/perf_event.h> 20#include <linux/perf_event.h>
21#include <linux/slab.h>
21#include <asm/processor.h> 22#include <asm/processor.h>
22 23
23#ifdef CONFIG_HW_PERF_EVENTS
24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth); 24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
25 25
26#ifdef CONFIG_HW_PERF_EVENTS
27/*
28 * This will need to be reworked when multiple PMUs are supported.
29 */
30static char *sh_pmu_op_name;
31
26char *op_name_from_perf_id(void) 32char *op_name_from_perf_id(void)
27{ 33{
28 const char *pmu; 34 return sh_pmu_op_name;
29 char buf[20];
30 int size;
31
32 pmu = perf_pmu_name();
33 if (!pmu)
34 return NULL;
35
36 size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
37 if (size > -1 && size < sizeof(buf))
38 return buf;
39
40 return NULL;
41} 35}
42 36
43int __init oprofile_arch_init(struct oprofile_operations *ops) 37int __init oprofile_arch_init(struct oprofile_operations *ops)
44{ 38{
45 ops->backtrace = sh_backtrace; 39 ops->backtrace = sh_backtrace;
46 40
41 if (perf_num_counters() == 0)
42 return -ENODEV;
43
44 sh_pmu_op_name = kasprintf(GFP_KERNEL, "%s/%s",
45 UTS_MACHINE, perf_pmu_name());
46 if (unlikely(!sh_pmu_op_name))
47 return -ENOMEM;
48
47 return oprofile_perf_init(ops); 49 return oprofile_perf_init(ops);
48} 50}
49 51
50void __exit oprofile_arch_exit(void) 52void __exit oprofile_arch_exit(void)
51{ 53{
52 oprofile_perf_exit(); 54 oprofile_perf_exit();
55 kfree(sh_pmu_op_name);
53} 56}
54#else 57#else
55int __init oprofile_arch_init(struct oprofile_operations *ops) 58int __init oprofile_arch_init(struct oprofile_operations *ops)
56{ 59{
57 pr_info("oprofile: hardware counters not available\n"); 60 ops->backtrace = sh_backtrace;
58 return -ENODEV; 61 return -ENODEV;
59} 62}
60void __exit oprofile_arch_exit(void) {} 63void __exit oprofile_arch_exit(void) {}