add idl4k kernel firmware version 1.13.0.105

This commit is contained in:
Jaroslav Kysela
2015-03-26 17:22:37 +01:00
parent 5194d2792e
commit e9070cdc77
31064 changed files with 12769984 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
obj-$(CONFIG_OPROFILE) += oprofile.o
DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
oprof.o cpu_buffer.o buffer_sync.o \
event_buffer.o oprofile_files.o \
oprofilefs.o oprofile_stats.o \
timer_int.o )
oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
oprofile-$(CONFIG_CPU_SUBTYPE_SH7750S) += op_model_sh7750.o
oprofile-$(CONFIG_CPU_SUBTYPE_SH7750) += op_model_sh7750.o
oprofile-$(CONFIG_CPU_SUBTYPE_SH7091) += op_model_sh7750.o
oprofile-$(CONFIG_OP_SH_USE_TMU) += op_model_sh_tmu.o

View File

@@ -0,0 +1,104 @@
/*
* SH specific backtracing code for oprofile
*
* Copyright 2007 STMicroelectronics Ltd.
*
* Author: Dave Peverley <dpeverley@mpc-data.co.uk>
*
* Based on ARM oprofile backtrace code by Richard Purdie and in turn, i386
* oprofile backtrace code by John Levon, David Smith
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/oprofile.h>
#include <linux/sched.h>
#include <linux/kallsyms.h>
#include <linux/mm.h>
#include <asm/unwinder.h>
#include <asm/ptrace.h>
#include <asm/uaccess.h>
#include <asm/sections.h>
#include <asm/stacktrace.h>
static void backtrace_warning_symbol(void *data, char *msg,
unsigned long symbol)
{
/* Ignore warnings */
}
static void backtrace_warning(void *data, char *msg)
{
/* Ignore warnings */
}
static int backtrace_stack(void *data, char *name)
{
/* Yes, we want all stacks */
return 0;
}
static void backtrace_address(void *data, unsigned long addr, int reliable)
{
unsigned int *depth = data;
if ((*depth)--)
oprofile_add_trace(addr);
}
static struct stacktrace_ops backtrace_ops = {
.warning = backtrace_warning,
.warning_symbol = backtrace_warning_symbol,
.stack = backtrace_stack,
.address = backtrace_address,
};
/* Limit to stop backtracing too far. */
static int backtrace_limit = 20;
static unsigned long *
user_backtrace(unsigned long *stackaddr, struct pt_regs *regs)
{
unsigned long buf_stack;
/* Also check accessibility of address */
if (!access_ok(VERIFY_READ, stackaddr, sizeof(unsigned long)))
return NULL;
if (__copy_from_user_inatomic(&buf_stack, stackaddr, sizeof(unsigned long)))
return NULL;
/* Quick paranoia check */
if (buf_stack & 3)
return NULL;
oprofile_add_trace(buf_stack);
stackaddr++;
return stackaddr;
}
void sh_backtrace(struct pt_regs * const regs, unsigned int depth)
{
unsigned long *stackaddr;
/*
* Paranoia - clip max depth as we could get lost in the weeds.
*/
if (depth > backtrace_limit)
depth = backtrace_limit;
stackaddr = (unsigned long *)regs->regs[15];
if (!user_mode(regs)) {
if (depth)
unwind_stack(NULL, regs, stackaddr,
&backtrace_ops, &depth);
return;
}
while (depth-- && (stackaddr != NULL))
stackaddr = user_backtrace(stackaddr, regs);
}

View File

@@ -0,0 +1,165 @@
/*
* arch/sh/oprofile/init.c
*
* Copyright (C) 2003 - 2008 Paul Mundt
*
* 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>
#include <asm/processor.h>
#include "op_impl.h"
extern struct op_sh_model op_model_sh7750_ops __weak;
extern struct op_sh_model op_model_sh4a_ops __weak;
extern struct op_sh_model op_sh_tmu_ops __weak ;
static struct op_sh_model *model;
static struct op_counter_config ctr[20];
extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
static int op_sh_setup(void)
{
/* Pre-compute the values to stuff in the hardware registers. */
model->reg_setup(ctr);
/* Configure the registers on all cpus. */
on_each_cpu(model->cpu_setup, NULL, 1);
return 0;
}
static int op_sh_create_files(struct super_block *sb, struct dentry *root)
{
int i, ret = 0;
for (i = 0; i < model->num_counters; i++) {
struct dentry *dir;
char buf[4];
snprintf(buf, sizeof(buf), "%d", i);
dir = oprofilefs_mkdir(sb, root, buf);
#ifdef CONFIG_OP_SH_USE_TMU
if (model->create_files)
ret |= model->create_files(sb, root);
#else
ret |= oprofilefs_create_ulong(sb, dir, "enabled",
&ctr[i].enabled);
ret |= oprofilefs_create_ulong(sb, dir, "event",
&ctr[i].event);
if (model->create_files)
ret |= model->create_files(sb, dir);
else
ret |= oprofilefs_create_ulong(sb, dir, "count",
&ctr[i].count);
#endif
/* Dummy entries */
ret |= oprofilefs_create_ulong(sb, dir, "kernel",
&ctr[i].kernel);
ret |= oprofilefs_create_ulong(sb, dir, "user",
&ctr[i].user);
ret |= oprofilefs_create_ulong(sb, dir, "unit_mask",
&ctr[i].unit_mask);
}
return ret;
}
static int op_sh_start(void)
{
/* Enable performance monitoring for all counters. */
on_each_cpu(model->cpu_start, NULL, 1);
return 0;
}
static void op_sh_stop(void)
{
/* Disable performance monitoring for all counters. */
on_each_cpu(model->cpu_stop, NULL, 1);
}
int __init oprofile_arch_init(struct oprofile_operations *ops)
{
struct op_sh_model *lmodel = NULL;
int ret;
/*
* Always assign the backtrace op. If the counter initialization
* fails, we fall back to the timer which will still make use of
* this.
*/
ops->backtrace = sh_backtrace;
#ifdef CONFIG_OP_SH_USE_TMU
lmodel = &op_sh_tmu_ops;
#else
switch (current_cpu_data.type) {
/* SH-4 types */
case CPU_SH7750:
case CPU_SH7750S:
lmodel = &op_model_sh7750_ops;
break;
/* SH-4A types */
case CPU_SH7763:
case CPU_SH7770:
case CPU_SH7780:
case CPU_SH7781:
case CPU_SH7785:
case CPU_SH7786:
case CPU_SH7723:
case CPU_SH7724:
case CPU_SHX3:
lmodel = &op_model_sh4a_ops;
break;
/* SH4AL-DSP types */
case CPU_SH7343:
case CPU_SH7722:
case CPU_SH7366:
lmodel = &op_model_sh4a_ops;
break;
}
if (!lmodel)
return -ENODEV;
#endif
ret = lmodel->init();
if (unlikely(ret != 0))
return ret;
model = lmodel;
ops->setup = op_sh_setup;
ops->create_files = op_sh_create_files;
ops->start = op_sh_start;
ops->stop = op_sh_stop;
ops->cpu_type = lmodel->cpu_type;
printk(KERN_INFO "oprofile: using %s performance monitoring.\n",
lmodel->cpu_type);
return 0;
}
void oprofile_arch_exit(void)
{
if (model && model->exit)
model->exit();
}

View File

@@ -0,0 +1,38 @@
#ifndef __OP_IMPL_H
#define __OP_IMPL_H
/* Per-counter configuration as set via oprofilefs. */
struct op_counter_config {
#ifdef CONFIG_OP_SH_USE_TMU
unsigned long rate; /* set/get sampling rate.*/
#else
unsigned long enabled;
unsigned long long count;
unsigned long event;
#endif
/* Dummy values for userspace tool compliance */
unsigned long kernel;
unsigned long user;
unsigned long unit_mask;
};
/* Per-architecture configury and hooks. */
struct op_sh_model {
void (*reg_setup)(struct op_counter_config *);
int (*create_files)(struct super_block *sb, struct dentry *dir);
void (*cpu_setup)(void *dummy);
int (*init)(void);
void (*exit)(void);
void (*cpu_start)(void *args);
void (*cpu_stop)(void *args);
char *cpu_type;
unsigned char num_counters;
};
/* arch/sh/oprofile/common.c */
extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
#endif /* __OP_IMPL_H */

View File

@@ -0,0 +1,255 @@
/*
* arch/sh/oprofile/op_model_sh7750.c
*
* OProfile support for SH7750/SH7750S Performance Counters
*
* Copyright (C) 2003 - 2008 Paul Mundt
*
* 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/profile.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/fs.h>
#include "op_impl.h"
#define PM_CR_BASE 0xff000084 /* 16-bit */
#define PM_CTR_BASE 0xff100004 /* 32-bit */
#define PMCR(n) (PM_CR_BASE + ((n) * 0x04))
#define PMCTRH(n) (PM_CTR_BASE + 0x00 + ((n) * 0x08))
#define PMCTRL(n) (PM_CTR_BASE + 0x04 + ((n) * 0x08))
#define PMCR_PMM_MASK 0x0000003f
#define PMCR_CLKF 0x00000100
#define PMCR_PMCLR 0x00002000
#define PMCR_PMST 0x00004000
#define PMCR_PMEN 0x00008000
struct op_sh_model op_model_sh7750_ops;
#define NR_CNTRS 2
static struct sh7750_ppc_register_config {
unsigned int ctrl;
unsigned long cnt_hi;
unsigned long cnt_lo;
} regcache[NR_CNTRS];
/*
* There are a number of events supported by each counter (33 in total).
* Since we have 2 counters, each counter will take the event code as it
* corresponds to the PMCR PMM setting. Each counter can be configured
* independently.
*
* Event Code Description
* ---------- -----------
*
* 0x01 Operand read access
* 0x02 Operand write access
* 0x03 UTLB miss
* 0x04 Operand cache read miss
* 0x05 Operand cache write miss
* 0x06 Instruction fetch (w/ cache)
* 0x07 Instruction TLB miss
* 0x08 Instruction cache miss
* 0x09 All operand accesses
* 0x0a All instruction accesses
* 0x0b OC RAM operand access
* 0x0d On-chip I/O space access
* 0x0e Operand access (r/w)
* 0x0f Operand cache miss (r/w)
* 0x10 Branch instruction
* 0x11 Branch taken
* 0x12 BSR/BSRF/JSR
* 0x13 Instruction execution
* 0x14 Instruction execution in parallel
* 0x15 FPU Instruction execution
* 0x16 Interrupt
* 0x17 NMI
* 0x18 trapa instruction execution
* 0x19 UBCA match
* 0x1a UBCB match
* 0x21 Instruction cache fill
* 0x22 Operand cache fill
* 0x23 Elapsed time
* 0x24 Pipeline freeze by I-cache miss
* 0x25 Pipeline freeze by D-cache miss
* 0x27 Pipeline freeze by branch instruction
* 0x28 Pipeline freeze by CPU register
* 0x29 Pipeline freeze by FPU
*
* Unfortunately we don't have a native exception or interrupt for counter
* overflow (although since these counters can run for 16.3 days without
* overflowing, it's not really necessary).
*
* OProfile on the other hand likes to have samples taken periodically, so
* for now we just piggyback the timer interrupt to get the expected
* behavior.
*/
static int sh7750_timer_notify(struct pt_regs *regs)
{
oprofile_add_sample(regs, 0);
return 0;
}
static u64 sh7750_read_counter(int counter)
{
return (u64)((u64)(__raw_readl(PMCTRH(counter)) & 0xffff) << 32) |
__raw_readl(PMCTRL(counter));
}
/*
* Files will be in a path like:
*
* /<oprofilefs mount point>/<counter number>/<file>
*
* So when dealing with <file>, we look to the parent dentry for the counter
* number.
*/
static inline int to_counter(struct file *file)
{
const unsigned char *name = file->f_path.dentry->d_parent->d_name.name;
return (int)simple_strtol(name, NULL, 10);
}
/*
* XXX: We have 48-bit counters, so we're probably going to want something
* more along the lines of oprofilefs_ullong_to_user().. Truncating to
* unsigned long works fine for now though, as long as we don't attempt to
* profile for too horribly long.
*/
static ssize_t sh7750_read_count(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
int counter = to_counter(file);
u64 val = sh7750_read_counter(counter);
return oprofilefs_ulong_to_user((unsigned long)val, buf, count, ppos);
}
static ssize_t sh7750_write_count(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
int counter = to_counter(file);
unsigned long val;
if (oprofilefs_ulong_from_user(&val, buf, count))
return -EFAULT;
/*
* Any write will clear the counter, although only 0 should be
* written for this purpose, as we do not support setting the
* counter to an arbitrary value.
*/
WARN_ON(val != 0);
__raw_writew(__raw_readw(PMCR(counter)) | PMCR_PMCLR, PMCR(counter));
return count;
}
static const struct file_operations count_fops = {
.read = sh7750_read_count,
.write = sh7750_write_count,
};
static int sh7750_ppc_create_files(struct super_block *sb, struct dentry *dir)
{
return oprofilefs_create_file(sb, dir, "count", &count_fops);
}
static void sh7750_ppc_reg_setup(struct op_counter_config *ctr)
{
unsigned int counters = op_model_sh7750_ops.num_counters;
int i;
for (i = 0; i < counters; i++) {
regcache[i].ctrl = 0;
regcache[i].cnt_hi = 0;
regcache[i].cnt_lo = 0;
if (!ctr[i].enabled)
continue;
regcache[i].ctrl |= ctr[i].event | PMCR_PMEN | PMCR_PMST;
regcache[i].cnt_hi = (unsigned long)((ctr->count >> 32) & 0xffff);
regcache[i].cnt_lo = (unsigned long)(ctr->count & 0xffffffff);
}
}
static void sh7750_ppc_cpu_setup(void *args)
{
unsigned int counters = op_model_sh7750_ops.num_counters;
int i;
for (i = 0; i < counters; i++) {
__raw_writew(0, PMCR(i));
__raw_writel(regcache[i].cnt_hi, PMCTRH(i));
__raw_writel(regcache[i].cnt_lo, PMCTRL(i));
}
}
static void sh7750_ppc_cpu_start(void *args)
{
unsigned int counters = op_model_sh7750_ops.num_counters;
int i;
for (i = 0; i < counters; i++)
__raw_writew(regcache[i].ctrl, PMCR(i));
}
static void sh7750_ppc_cpu_stop(void *args)
{
unsigned int counters = op_model_sh7750_ops.num_counters;
int i;
/* Disable the counters */
for (i = 0; i < counters; i++)
__raw_writew(__raw_readw(PMCR(i)) & ~PMCR_PMEN, PMCR(i));
}
static inline void sh7750_ppc_reset(void)
{
unsigned int counters = op_model_sh7750_ops.num_counters;
int i;
/* Clear the counters */
for (i = 0; i < counters; i++)
__raw_writew(__raw_readw(PMCR(i)) | PMCR_PMCLR, PMCR(i));
}
static int sh7750_ppc_init(void)
{
sh7750_ppc_reset();
return register_timer_hook(sh7750_timer_notify);
}
static void sh7750_ppc_exit(void)
{
unregister_timer_hook(sh7750_timer_notify);
sh7750_ppc_reset();
}
struct op_sh_model op_model_sh7750_ops = {
.cpu_type = "sh/sh7750",
.num_counters = NR_CNTRS,
.reg_setup = sh7750_ppc_reg_setup,
.cpu_setup = sh7750_ppc_cpu_setup,
.cpu_start = sh7750_ppc_cpu_start,
.cpu_stop = sh7750_ppc_cpu_stop,
.init = sh7750_ppc_init,
.exit = sh7750_ppc_exit,
.create_files = sh7750_ppc_create_files,
};

View File

@@ -0,0 +1,167 @@
/*
* arch/sh/oprofile/op_model_sh_tmu.c
*
* Copyright (C) 2010 STMicroelectronics
* Author : Marc Titinger <marc.titinger-amesys@st.com>
*
* oprofile sh model using the "generic timer" API
* from Stuart Menefy for interrupt trigger.
*
* 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/module.h>
#include <linux/notifier.h>
#include <linux/smp.h>
#include <linux/oprofile.h>
#include <linux/signal.h>
#include <linux/interrupt.h>
#include <linux/profile.h>
#include <linux/init.h>
#include <linux/ptrace.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/stm/platform.h>
#include <linux/io.h>
#include <linux/fs.h>
#include <linux/sh_timer.h>
#include "op_impl.h"
#define DEFAULT_SAMPLE_RATE 987 /*Hz*/
static struct sh_timer_callb *timer;
static unsigned long sampling_rate;
/***********************************************************************
* sh_op_tmu_setrate()
*
*
*/
static void sh_op_tmu_setrate(struct op_counter_config *unused)
{
return;
}
static ssize_t sh_op_tmu_read_rate(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
return oprofilefs_ulong_to_user(sampling_rate, buf, count, ppos);
}
static ssize_t sh_op_tmu_write_rate(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
unsigned long val;
if (oprofilefs_ulong_from_user(&val, buf, count))
return -EFAULT;
if (val > 10000)
sampling_rate = 10000;
if (val < 250)
sampling_rate = 250;
else
sampling_rate = val;
printk(KERN_NOTICE
"please restart the profiler to apply new rate %ld Hz.\n",sampling_rate);
printk(KERN_NOTICE
"You may need to run \"opcontrol --reset\" for data coherence.\n");
return count;
}
static const struct file_operations rate_fops = {
.read = sh_op_tmu_read_rate,
.write = sh_op_tmu_write_rate,
};
static int sh_op_tmu_create_files(struct super_block *sb, struct dentry *dir)
{
return oprofilefs_create_file(sb, dir, "rate", &rate_fops);
}
/***********************************************************************
* sh_op_tmu_irq()
*
*/
static void sh_op_tmu_irq(void *data)
{
struct pt_regs *regs = get_irq_regs();
/* Give the sample to oprofile. */
oprofile_add_sample(regs, 0);
return;
}
/***********************************************************************
* sh_op_tmu_stop()
*
*
*/
static void sh_op_tmu_stop(void *args)
{
if (timer == NULL)
return;
timer->timer_stop(timer->tmu_priv);
sh_timer_unregister(timer->tmu_priv);
timer = NULL;
}
/***********************************************************************
* sh_op_tmu_start()
*
*
*/
static void sh_op_tmu_start(void *args)
{
if (timer == NULL)
timer = sh_timer_register(sh_op_tmu_irq, (void *)0);
if (timer == NULL) {
printk(KERN_ERR "sh_op_tmu_start: no available TMU timer, start failed!\n");
return;
}
printk(KERN_NOTICE "sh_op_tmu_setrate: settings TMU timer at %ld Hz\n",
sampling_rate);
timer->set_rate(timer->tmu_priv, sampling_rate);
timer->timer_start(timer->tmu_priv);
}
int sh_op_tmu_init(void)
{
timer = NULL ;
sampling_rate = DEFAULT_SAMPLE_RATE;
return 0;
}
void sh_op_tmu_exit(void)
{
sh_op_tmu_stop(NULL);
}
static void sh_op_tmu_setup(void *dummy)
{
}
struct op_sh_model op_sh_tmu_ops = {
.cpu_type = "timer", /*for compat with the usermode app*/
.num_counters = 1, /*dir "0"*/
.reg_setup = sh_op_tmu_setrate,
.cpu_setup = sh_op_tmu_setup,
.cpu_start = sh_op_tmu_start,
.cpu_stop = sh_op_tmu_stop,
.init = sh_op_tmu_init,
.exit = sh_op_tmu_exit,
.create_files = sh_op_tmu_create_files,
};