14 #include <linux/errno.h>
16 #include <linux/module.h>
17 #include <asm/processor.h>
19 #include "../../../drivers/oprofile/oprof.h"
26 #include "op_counter.h"
28 #define DEFAULT_INTERVAL 4127518
30 #define DEFAULT_SDBT_BLOCKS 1
31 #define DEFAULT_SDB_BLOCKS 511
33 static unsigned long oprofile_hw_interval = DEFAULT_INTERVAL;
34 static unsigned long oprofile_min_interval;
35 static unsigned long oprofile_max_interval;
37 static unsigned long oprofile_sdbt_blocks = DEFAULT_SDBT_BLOCKS;
38 static unsigned long oprofile_sdb_blocks = DEFAULT_SDB_BLOCKS;
40 static int hwsampler_enabled;
41 static int hwsampler_running;
42 static int hwsampler_available;
52 static int force_cpu_type;
56 if (!
strcmp(str,
"timer")) {
57 force_cpu_type =
timer;
68 "(report cpu_type \"timer\"");
70 static int oprofile_hwsampler_start(
void)
74 hwsampler_running = hwsampler_enabled;
76 if (!hwsampler_running)
77 return timer_ops.start();
90 static void oprofile_hwsampler_stop(
void)
92 if (!hwsampler_running) {
127 if (val != 0 && val != 1)
138 hwsampler_enabled =
val;
144 .
read = hwsampler_read,
145 .write = hwsampler_write,
156 static ssize_t hw_interval_read(
struct file *file,
char __user *buf,
157 size_t count, loff_t *offset)
163 static ssize_t hw_interval_write(
struct file *file,
char const __user *buf,
164 size_t count, loff_t *offset)
174 if (val < oprofile_min_interval)
175 oprofile_hw_interval = oprofile_min_interval;
176 else if (val > oprofile_max_interval)
177 oprofile_hw_interval = oprofile_max_interval;
179 oprofile_hw_interval =
val;
185 .
read = hw_interval_read,
186 .write = hw_interval_write,
199 static ssize_t hwsampler_zero_read(
struct file *file,
char __user *buf,
200 size_t count, loff_t *offset)
205 static ssize_t hwsampler_zero_write(
struct file *file,
char const __user *buf,
206 size_t count, loff_t *offset)
223 .
read = hwsampler_zero_read,
224 .write = hwsampler_zero_write,
229 static ssize_t hwsampler_kernel_read(
struct file *file,
char __user *buf,
230 size_t count, loff_t *offset)
236 static ssize_t hwsampler_kernel_write(
struct file *file,
char const __user *buf,
237 size_t count, loff_t *offset)
249 if (val != 0 && val != 1)
258 .
read = hwsampler_kernel_read,
259 .write = hwsampler_kernel_write,
264 static ssize_t hwsampler_user_read(
struct file *file,
char __user *buf,
265 size_t count, loff_t *offset)
271 static ssize_t hwsampler_user_write(
struct file *file,
char const __user *buf,
272 size_t count, loff_t *offset)
284 if (val != 0 && val != 1)
293 .
read = hwsampler_user_read,
294 .write = hwsampler_user_write,
304 static ssize_t timer_enabled_read(
struct file *file,
char __user *buf,
305 size_t count, loff_t *offset)
310 static ssize_t timer_enabled_write(
struct file *file,
char const __user *buf,
311 size_t count, loff_t *offset)
323 if (val != 0 && val != 1)
327 if (val == 0 && !hwsampler_available)
338 hwsampler_enabled = !
val;
344 .
read = timer_enabled_read,
345 .write = timer_enabled_write,
349 static int oprofile_create_hwsampling_files(
struct super_block *
sb,
360 if (!hwsampler_available)
364 hwsampler_enabled = 1;
368 if (!force_cpu_type) {
390 &oprofile_sdbt_blocks);
408 &oprofile_min_interval);
410 &oprofile_max_interval);
412 &oprofile_sdbt_blocks);
427 memcpy(&timer_ops, ops,
sizeof(timer_ops));
435 if (force_cpu_type !=
timer) {
441 case 0x2097:
case 0x2098: ops->
cpu_type =
"s390/z10";
break;
442 case 0x2817:
case 0x2818: ops->
cpu_type =
"s390/z196";
break;
455 if (oprofile_min_interval == 0)
458 if (oprofile_max_interval == 0)
462 if (oprofile_hw_interval < oprofile_min_interval)
463 oprofile_hw_interval = oprofile_min_interval;
464 if (oprofile_hw_interval > oprofile_max_interval)
465 oprofile_hw_interval = oprofile_max_interval;
468 "facility found.\n");
470 ops->
start = oprofile_hwsampler_start;
471 ops->
stop = oprofile_hwsampler_stop;
476 static void oprofile_hwsampler_exit(
void)
494 hwsampler_available = oprofile_hwsampler_init(ops) == 0;
505 oprofile_hwsampler_exit();