[PATCH] powerpc: Quiet rtasd output at boot
[deliverable/linux.git] / arch / powerpc / oprofile / common.c
CommitLineData
1da177e4 1/*
86a5cddb 2 * PPC 64 oprofile support:
1da177e4 3 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
86a5cddb
SR
4 * PPC 32 oprofile support: (based on PPC 64 support)
5 * Copyright (C) Freescale Semiconductor, Inc 2004
6 * Author: Andy Fleming
1da177e4
LT
7 *
8 * Based on alpha version.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <linux/oprofile.h>
17#include <linux/init.h>
18#include <linux/smp.h>
19#include <linux/errno.h>
20#include <asm/ptrace.h>
21#include <asm/system.h>
22#include <asm/pmc.h>
a6908cd0 23#include <asm/cputable.h>
dca85932 24#include <asm/oprofile_impl.h>
1da177e4 25
a3e48c10 26static struct op_powerpc_model *model;
1da177e4
LT
27
28static struct op_counter_config ctr[OP_MAX_COUNTER];
29static struct op_system_config sys;
30
31static void op_handle_interrupt(struct pt_regs *regs)
32{
33 model->handle_interrupt(regs, ctr);
34}
35
86a5cddb 36static int op_powerpc_setup(void)
1da177e4
LT
37{
38 int err;
39
40 /* Grab the hardware */
41 err = reserve_pmc_hardware(op_handle_interrupt);
42 if (err)
43 return err;
44
45 /* Pre-compute the values to stuff in the hardware registers. */
46 model->reg_setup(ctr, &sys, model->num_counters);
47
48 /* Configure the registers on all cpus. */
49 on_each_cpu(model->cpu_setup, NULL, 0, 1);
50
51 return 0;
52}
53
86a5cddb 54static void op_powerpc_shutdown(void)
1da177e4
LT
55{
56 release_pmc_hardware();
57}
58
86a5cddb 59static void op_powerpc_cpu_start(void *dummy)
1da177e4
LT
60{
61 model->start(ctr);
62}
63
86a5cddb 64static int op_powerpc_start(void)
1da177e4 65{
86a5cddb 66 on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1);
1da177e4
LT
67 return 0;
68}
69
86a5cddb 70static inline void op_powerpc_cpu_stop(void *dummy)
1da177e4
LT
71{
72 model->stop();
73}
74
86a5cddb 75static void op_powerpc_stop(void)
1da177e4 76{
86a5cddb 77 on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1);
1da177e4
LT
78}
79
86a5cddb 80static int op_powerpc_create_files(struct super_block *sb, struct dentry *root)
1da177e4
LT
81{
82 int i;
83
555d97ac 84#ifdef CONFIG_PPC64
1da177e4
LT
85 /*
86 * There is one mmcr0, mmcr1 and mmcra for setting the events for
87 * all of the counters.
88 */
89 oprofilefs_create_ulong(sb, root, "mmcr0", &sys.mmcr0);
90 oprofilefs_create_ulong(sb, root, "mmcr1", &sys.mmcr1);
91 oprofilefs_create_ulong(sb, root, "mmcra", &sys.mmcra);
555d97ac 92#endif
1da177e4
LT
93
94 for (i = 0; i < model->num_counters; ++i) {
95 struct dentry *dir;
96 char buf[3];
97
98 snprintf(buf, sizeof buf, "%d", i);
99 dir = oprofilefs_mkdir(sb, root, buf);
100
101 oprofilefs_create_ulong(sb, dir, "enabled", &ctr[i].enabled);
102 oprofilefs_create_ulong(sb, dir, "event", &ctr[i].event);
103 oprofilefs_create_ulong(sb, dir, "count", &ctr[i].count);
555d97ac 104
1da177e4 105 /*
555d97ac
AF
106 * Classic PowerPC doesn't support per-counter
107 * control like this, but the options are
108 * expected, so they remain. For Freescale
109 * Book-E style performance monitors, we do
110 * support them.
1da177e4
LT
111 */
112 oprofilefs_create_ulong(sb, dir, "kernel", &ctr[i].kernel);
113 oprofilefs_create_ulong(sb, dir, "user", &ctr[i].user);
86a5cddb 114
1da177e4
LT
115 oprofilefs_create_ulong(sb, dir, "unit_mask", &ctr[i].unit_mask);
116 }
117
118 oprofilefs_create_ulong(sb, root, "enable_kernel", &sys.enable_kernel);
119 oprofilefs_create_ulong(sb, root, "enable_user", &sys.enable_user);
1da177e4
LT
120
121 /* Default to tracing both kernel and user */
122 sys.enable_kernel = 1;
123 sys.enable_user = 1;
1da177e4
LT
124
125 return 0;
126}
127
128int __init oprofile_arch_init(struct oprofile_operations *ops)
129{
32a33994 130 if (!cur_cpu_spec->oprofile_cpu_type)
8fef0306 131 return -ENODEV;
32a33994
AB
132
133 switch (cur_cpu_spec->oprofile_type) {
134#ifdef CONFIG_PPC64
7a45fb19 135 case PPC_OPROFILE_RS64:
32a33994
AB
136 model = &op_model_rs64;
137 break;
7a45fb19 138 case PPC_OPROFILE_POWER4:
32a33994
AB
139 model = &op_model_power4;
140 break;
141#else
7a45fb19 142 case PPC_OPROFILE_G4:
32a33994
AB
143 model = &op_model_7450;
144 break;
145#endif
146#ifdef CONFIG_FSL_BOOKE
7a45fb19 147 case PPC_OPROFILE_BOOKE:
32a33994
AB
148 model = &op_model_fsl_booke;
149 break;
150#endif
151 default:
152 return -ENODEV;
153 }
154
a6908cd0 155 model->num_counters = cur_cpu_spec->num_pmcs;
8fef0306
AB
156
157 ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
86a5cddb
SR
158 ops->create_files = op_powerpc_create_files;
159 ops->setup = op_powerpc_setup;
160 ops->shutdown = op_powerpc_shutdown;
161 ops->start = op_powerpc_start;
162 ops->stop = op_powerpc_stop;
6c6bd754 163 ops->backtrace = op_powerpc_backtrace;
1da177e4
LT
164
165 printk(KERN_INFO "oprofile: using %s performance monitoring.\n",
166 ops->cpu_type);
167
168 return 0;
169}
170
171void oprofile_arch_exit(void)
172{
173}
This page took 0.118946 seconds and 5 git commands to generate.