示例#1
0
unsigned long acpuclk_wait_for_irq(void)
{
	unsigned long rate = acpuclk_get_rate(smp_processor_id());
	acpuclk_set_rate(smp_processor_id(), acpuclk_data->wait_for_irq_khz,
			 SETRATE_SWFI);
	return rate;
}
static ssize_t pm_status_show(struct kobject *kobj, struct kobj_attribute *attr,
			char *buf)
{
	char *s = buf;
	unsigned long rate; // khz
	int cpu;

	// show CPU clocks
	for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
		s += sprintf(s, "APPS[%d]:", cpu);
		if (cpu_online(cpu)) {
#if 0
			//acpuclk_get_rate doesn't work because acpuclk_data is no longer available in krait
			rate = acpuclk_get_rate(cpu); // khz
			s += sprintf(s, "(%3lu MHz); \n", rate / 1000);
#else
			//Call acpu_clk_get_rate added in clock-krait-8974.c
			rate = acpu_clk_get_rate(cpu); // hz
			s += sprintf(s, "(%3lu MHz); \n", rate / 1000000);
#endif
		} else {
			s += sprintf(s, "sleep; \n");
		}
	}

	s += wakelock_dump_info(s);
	
	return (s - buf);
}
示例#3
0
unsigned long acpuclk_power_collapse(void)
{
	unsigned long rate = acpuclk_get_rate(smp_processor_id());
	acpuclk_set_rate(smp_processor_id(), acpuclk_data->power_collapse_khz,
			 SETRATE_PC);
	return rate;
}
示例#4
0
unsigned int report_load_at_max_freq(int cpu)
{
	struct cpu_load_data *pcpu;
	unsigned int total_load = 0;
	pcpu = &per_cpu(cpuload, cpu);
	update_average_load(acpuclk_get_rate(cpu), cpu);
	total_load = pcpu->avg_load_maxfreq;
	pcpu->prev_avg_load_maxfreq = pcpu->avg_load_maxfreq;
	pcpu->avg_load_maxfreq = 0;

	return total_load;
}
/*
* cpu_info_msg: output message
* msg_len: the size of output message.
* output message is included cpu's usage, real cpu frequecy and cpu governor's current cpu frequency.
*/
void show_cpu_usage_and_freq(char * cpu_info_msg, int msg_len)
{	
	unsigned long cpu_freq = 0;
	unsigned long cpu_curr_freq = 0;
	long cpu_usage = 0;

	long iowait_usage = 0;

	int cpu;

	int len = msg_len; 
	int str_len = 0;
	int tmp_len = 0;

	if(!cpu_info_msg || msg_len <= 0)
	{
		return;
	}
	
	for_each_present_cpu(cpu)
	{
		cpu_freq = acpuclk_get_rate(cpu); /*real cpu frequency*/
		cpu_curr_freq = (unsigned long) cpufreq_quick_get(cpu); /*cpu governor's current cpu frequency*/
		cpu_usage = get_cpu_usage(cpu, &iowait_usage); /*get cpu usage*/

//CORE-DL-ExportCpuInfo-00 +[
		if (cpu == 0) {
			cpu0_usage = cpu_usage;
			iowait0_usage = iowait_usage;
		} else if (cpu == 1) {
			cpu1_usage = cpu_usage;
			iowait1_usage = iowait_usage;
		}
//CORE-DL-ExportCpuInfo-00 +]

		tmp_len = snprintf((cpu_info_msg + str_len), len, "[C%d%s:%3ld%% IOW=%3ld%% F=%lu crF=%lu]", cpu, (cpu_is_offline(cpu) ? " off" : ""), cpu_usage, iowait_usage, cpu_freq, cpu_curr_freq);	
		
		str_len += tmp_len;
		len -= tmp_len;
		
		if(len <= 0 || str_len >= msg_len)
		{
			break;
		}
	}

	if(len > 0 && str_len < msg_len)
	{
		snprintf((cpu_info_msg + str_len), len, "C%d:", smp_processor_id()); /*this cpu is handling this timer interrupt*/
	}
	
}
示例#6
0
static void msm_pm_restart(char str, const char *cmd)
{
	int rc;
	unsigned size;

#if defined(CONFIG_MACH_ARUBASLIM_OPEN)
	unsigned int freq = 600000;

	rc = acpuclk_set_rate(0, freq, SETRATE_CPUFREQ);
	if (rc) {
		printk(KERN_ERR "%s(): failed to restore clock rate(%lu)\n",
			__func__, freq);
	}
	pr_info("%s: Current ACPU frequency %ld\n", __func__, acpuclk_get_rate(0));
#endif

	samsung_vendor1_id *smem_vendor1 = \
		(samsung_vendor1_id *)smem_get_entry(SMEM_ID_VENDOR1, &size);

	if (smem_vendor1) {
		smem_vendor1->silent_reset = 0xAEAEAEAE;
		smem_vendor1->reboot_reason = restart_reason;
        smem_vendor1->AP_reserved[0] = 0;
	} else {
		printk(KERN_EMERG "smem_flag is NULL\n");
	}

	pr_debug("The reset reason is %x\n", restart_reason);

	rc = ncp6335d_restart_config();
	if (rc)
		pr_err("Unable to configure NCP6335D for restart\n");

	/* Disable interrupts */
	local_irq_disable();
	local_fiq_disable();

	/*
	 * Take out a flat memory mapping  and will
	 * insert a 1:1 mapping in place of
	 * the user-mode pages to ensure predictable results
	 * This function takes care of flushing the caches
	 * and flushing the TLB.
	 */
	setup_mm_for_reboot();

	msm_proc_comm(PCOM_RESET_CHIP, &restart_reason, 0);

	for (;;)
		;
}
static int __init msm_rq_stats_init(void)
{
	int cpu = 0;
	struct cpufreq_policy cpu_policy;
	struct cpu_load_data *pcpu = &per_cpu(cpuload, cpu);

	cpufreq_get_policy(&cpu_policy, cpu);

	pcpu->policy_max = cpu_policy.max;
	pcpu->cur_freq = acpuclk_get_rate(cpu);

	cpumask_copy(pcpu->related_cpus, cpu_policy.cpus);

	return 0;
}
示例#8
0
int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason reason)
{
	int ret;

	if (!acpuclk_data->set_rate)
		return 0;

	trace_cpu_frequency_switch_start(acpuclk_get_rate(cpu), rate, cpu);
	ret = acpuclk_data->set_rate(cpu, rate, reason);
	if (!ret) {
		trace_cpu_frequency_switch_end(cpu);
		trace_cpu_frequency(rate, cpu);
	}

	return ret;
}
static ssize_t pm_status_show(struct kobject *kobj, struct kobj_attribute *attr,
			char *buf)
{
	char *s = buf;
	unsigned long rate; // khz
	int cpu;

	// show CPU clocks
	for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
		s += sprintf(s, "APPS[%d]:", cpu);
		if (cpu_online(cpu)) {
			rate = acpuclk_get_rate(cpu); // khz
			s += sprintf(s, "(%3lu MHz); \n", rate / 1000);
		} else {
			s += sprintf(s, "sleep; \n");
		}
	}

	s += wakelock_dump_info(s);
	
	return (s - buf);
}
unsigned long acpuclk_wait_for_irq(void)
{
	int ret = acpuclk_get_rate(smp_processor_id());
	acpuclk_set_rate(smp_processor_id(), WAIT_FOR_IRQ_KHZ, SETRATE_SWFI);
	return ret;
}
unsigned long acpuclk_power_collapse(void)
{
	int ret = acpuclk_get_rate(smp_processor_id());
	acpuclk_set_rate(smp_processor_id(), POWER_COLLAPSE_KHZ, SETRATE_PC);
	return ret;
}
示例#12
0
void count_cpu_time(void){
	if (unlikely(debug_cpu_usage_enable == 1 && (1000*(jiffies_64 - Last_checked_jiffies)/HZ >= CPU_USAGE_CHECK_INTERVAL_MS)))
	{
		struct task_struct * p = current;
		struct pt_regs *regs = get_irq_regs();

		/*Kernel-SC-add-cpuFreq-info-01+[*/
		unsigned long cpu_freq = acpuclk_get_rate(smp_processor_id());
		unsigned long cpu_curr_freq = (unsigned long) cpufreq_quick_get(smp_processor_id());
		/*Kernel-SC-add-cpuFreq-info-01+]*/

		if (likely(p != 0))
		{
			if (regs != 0)
			{
				if (regs->ARM_pc <= TASK_SIZE)  /* User space */
				{
					struct mm_struct *mm = p->mm;
					struct vm_area_struct *vma;
					struct file *map_file = NULL;

					/* Parse vma information */
					vma = find_vma(mm, regs->ARM_pc);

					if (vma != NULL)
					{
						map_file = vma->vm_file;
					
						if (map_file)  /* memory-mapped file */
						{
							printk(KERN_INFO "[CPU] %3ld%% LR=0x%08lx PC=0x%08lx [U][%4d][%s][%s+0x%lx] CPUFreq=%lu CurrFreq=%lu\r\n",
								get_cpu_usage(),
								regs->ARM_lr, 
								regs->ARM_pc, 
								(unsigned int) p->pid,
								p->comm,
								map_file->f_path.dentry->d_iname, 
								regs->ARM_pc - vma->vm_start,
								cpu_freq,
								cpu_curr_freq);/*Kernel-SC-add-cpuFreq-info-01**/
						}
						else 
						{
							const char *name = arch_vma_name(vma);
							if (!name) 
							{
								if (mm) 
								{
									if (vma->vm_start <= mm->start_brk &&
										vma->vm_end >= mm->brk) 
									{
										name = "heap";
									} 
									else if (vma->vm_start <= mm->start_stack &&
										vma->vm_end >= mm->start_stack) 
									{
										name = "stack";
									}
								}
								else 
								{
									name = "vdso";
								}
							}
							printk(KERN_INFO "[CPU] %3ld%% LR=0x%08lx PC=0x%08lx [U][%4d][%s][%s] CPUFreq=%lu CurrFreq=%lu\r\n",
								get_cpu_usage(),
								regs->ARM_lr, 
								regs->ARM_pc, 
								(unsigned int) p->pid,
								p->comm, 
								name,
								cpu_freq,
								cpu_curr_freq);/*Kernel-SC-add-cpuFreq-info-01**/
						}
					}
				}
				else /* Kernel space */
				{
					printk(KERN_INFO "[CPU] %3ld%% LR=0x%08lx PC=0x%08lx [K][%4d][%s] CPUFreq=%lu CurrFreq=%lu", 
						get_cpu_usage(),
						regs->ARM_lr, 
						regs->ARM_pc, 
						(unsigned int) p->pid,
						p->comm,
						cpu_freq,
						cpu_curr_freq);/*Kernel-SC-add-cpuFreq-info-01**/
					
					#ifdef CONFIG_KALLSYMS
					print_symbol("[%s]\r\n", regs->ARM_pc);
					#else
					printk("\r\n");
					#endif
				}
			}
			else  /* Can't get PC & RA address */
			{
				printk(KERN_INFO "[CPU] %3ld%% [%s] CPUFreq=%lu CurrFreq=%lu\r\n", get_cpu_usage(), p->comm, cpu_freq, cpu_curr_freq);/*Kernel-SC-add-cpuFreq-info-01**/
			}
		}
		else  /* Can't get process information */
		{
			printk(KERN_INFO "[CPU] %3ld%% ERROR: p=0x%08lx, regs=0x%08lx CPUFreq=%lu CurrFreq=%lu\r\n", get_cpu_usage(), (long)p, (long)regs, cpu_freq, cpu_curr_freq);/*Kernel-SC-add-cpuFreq-info-01**/
		}
	}
}