/******************** Tunable parameters: ********************/

Size: px
Start display at page:

Download "/******************** Tunable parameters: ********************/"

Transcription

1 1. Smartass2.c / drivers/cpufreq/cpufreq_smartass2.c Copyright (C) 2010 Google, Inc. This software is licensed under the terms of the GNU General Public License version 2, as published by the Free Software Foundation, and may be copied, distributed, and modified under those terms. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Author: Erasmux Based on the interactive governor By Mike Chan (mike@android.com) which was adaptated to kernel by Nadlabak (pavel@doshaska.net) SMP support based on mod by faux123 For a general overview of smartassv2 see the relavent part in Documentation/cpu-freq/governors.txt / #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/cpufreq.h> #include <linux/sched.h> #include <linux/tick.h> #include <linux/timer.h> #include <linux/workqueue.h> #include <linux/moduleparam.h> #include <asm/cputime.h> #include <linux/earlysuspend.h> / Tunable parameters: / / The "ideal" frequency to use when awake. The governor will ramp up faster towards the ideal frequency and slower after it has passed it. Similarly, lowering the frequency towards the ideal frequency is faster than below it. / #define DEFAULT_AWAKE_IDEAL_FREQ static unsigned int awake_ideal_freq; / The "ideal" frequency to use when suspended. When set to 0, the governor will not track the suspended state (meaning that practically when sleep_ideal_freq==0 the awake_ideal_freq is used also when suspended). // Scale up is high priority up_wq = create_rt_workqueue("ksmartass_up");

2 down_wq = create_workqueue("ksmartass_down"); if (!up_wq!down_wq) return -ENOMEM; INIT_WORK(&freq_scale_work, cpufreq_smartass_freq_change_time_work); register_early_suspend(&smartass_power_suspend); return cpufreq_register_governor(&cpufreq_gov_smartass2); #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_SMARTASS2 fs_initcall(cpufreq_smartass_init); #else module_init(cpufreq_smartass_init); #endif static void exit cpufreq_smartass_exit(void) cpufreq_unregister_governor(&cpufreq_gov_smartass2); destroy_workqueue(up_wq); destroy_workqueue(down_wq); module_exit(cpufreq_smartass_exit); MODULE_AUTHOR ("Erasmux"); MODULE_DESCRIPTION ("'cpufreq_smartass2' - A smart cpufreq governor"); MODULE_LICENSE ("GPL"); 2. Acpuclock-7x30.c / Copyright (C) 2007 Google, Inc. Copyright (c) , Code Aurora Forum. All rights reserved. This software is licensed under the terms of the GNU General Public License version 2, as published by the Free Software Foundation, and may be copied, distributed, and modified under those terms. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. / #include <linux/version.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/delay.h> #include <linux/clk.h> #include <linux/cpufreq.h> #include <linux/mutex.h> #include <linux/io.h>

3 #include <linux/sort.h> #include <mach/board.h> #include <mach/msm_iomap.h> #include <asm/mach-types.h> #include "smd_private.h" #include "clock.h" #include "clock-local.h" #include "clock-7x30.h" #include "acpuclock.h" #include "spm.h" #define SCSS_CLK_CTL_ADDR (MSM_ACC_BASE + 0x04) #define SCSS_CLK_SEL_ADDR (MSM_ACC_BASE + 0x08) #define PLL2_L_VAL_ADDR (MSM_CLK_CTL_BASE + 0x33C) #define dprintk(msg...) \ cpufreq_debug_printk(cpufreq_debug_driver, "cpufreq-msm", msg) #define VREF_SEL 1 / 0: 0.625V (50mV step), 1: V (25mV step). / #define V_STEP (25 (2 - VREF_SEL)) / Minimum voltage step size. / #define VREG_DATA (VREG_CONFIG (VREF_SEL << 5)) #define VREG_CONFIG (BIT(7) BIT(6)) / Enable VREG, pull-down if disabled. / / Cause a compile error if the voltage is not a multiple of the step size. / #define MV(mv) ((mv) / (!((mv) % V_STEP))) / mv = (750mV + (raw 25mV)) (2 - VREF_SEL) / #define VDD_RAW(mv) (((MV(mv) / V_STEP) - 30) VREG_DATA) #define MAX_AXI_KHZ #define SEMC_ACPU_MIN_UV_MV 750U #define SEMC_ACPU_MAX_UV_MV 1525U #define OVERCLOCK_CPU_LOW 0 / set to 0 to enable 2.0 GHz / struct clock_state struct clkctl_acpu_speed current_speed; struct mutex lock; uint32_t acpu_switch_time_us; uint32_t vdd_switch_time_us; struct clk ebi1_clk; ; struct clkctl_acpu_speed unsigned int acpu_clk_khz; int src; unsigned int acpu_src_sel; unsigned int acpu_src_div; unsigned int axi_clk_hz; unsigned int vdd_mv; unsigned int vdd_raw; unsigned long lpj; / loops_per_jiffy / ; static struct clock_state drv_state = 0 ; static struct cpufreq_frequency_table freq_table[] = 0, , 1, ,

4 2, , 3, , 4, , 5, , 6, , 7, , / 806.4MHz is updated to 1024MHz at runtime for MSM8x55. / 8, , 9, , 10, , 11, , 12, , 13, , 14, , 15, , 16, , #if OVERCLOCK_CPU_LOW 17, CPUFREQ_TABLE_END, #else 17, , 18, , 19, , 20, , 21, CPUFREQ_TABLE_END, #endif ; / Use negative numbers for sources that can't be enabled/disabled / #define SRC_LPXO (-2) #define SRC_AXI (-1) / Each ACPU frequency has a certain minimum MSMC1 voltage requirement that is implicitly met by voting for a specific minimum AXI frequency. Do NOT change the AXI frequency unless you are _absoulutely_ sure you know all the h/w requirements. / static struct clkctl_acpu_speed acpu_freq_tbl[] = // 24576, SRC_LPXO, 0, 0, , 900, VDD_RAW(900), // 61440, PLL_3, 5, 11, , 900, VDD_RAW(900), , PLL_3, 5, 5, , 900, VDD_RAW(900), , PLL_3, 5, 4, , 900, VDD_RAW(900), MAX_AXI_KHZ, SRC_AXI, 1, 0, , 900, VDD_RAW(900), , PLL_3, 5, 2, , 900, VDD_RAW(900), , PLL_3, 5, 1, , 900, VDD_RAW(900), / AXI has MSMC1 implications. See above. / , PLL_1, 2, 0, , 950, VDD_RAW(950), , PLL_1, 2, 0, , 1000, VDD_RAW(1000), , PLL_1, 2, 0, , 1050, VDD_RAW(1050), , PLL_1, 2, 0, , 1050, VDD_RAW(1050), / AXI has MSMC1 implications. See above MHz is increased to match the SoC's capabilities at runtime / , PLL_2, 3, 0, UINT_MAX, 1100, VDD_RAW(1100), , PLL_2, 3, 0, UINT_MAX, 1150, VDD_RAW(1150), , PLL_2, 3, 0, UINT_MAX, 1200, VDD_RAW(1200), , PLL_2, 3, 0, UINT_MAX, 1200, VDD_RAW(1200), , PLL_2, 3, 0, UINT_MAX, 1200, VDD_RAW(1200),

5 , PLL_2, 3, 0, UINT_MAX, 1250, VDD_RAW(1250), , PLL_2, 3, 0, UINT_MAX, 1250, VDD_RAW(1250), , PLL_2, 3, 0, UINT_MAX, 1300, VDD_RAW(1300), , PLL_2, 3, 0, UINT_MAX, 1300, VDD_RAW(1300), #if OVERCLOCK_CPU_LOW 0 #else , PLL_2, 3, 0, UINT_MAX, 1350, VDD_RAW(1350), , PLL_2, 3, 0, UINT_MAX, 1400, VDD_RAW(1400), , PLL_2, 3, 0, UINT_MAX, 1450, VDD_RAW(1450), , PLL_2, 3, 0, UINT_MAX, 1500, VDD_RAW(1500), 0 #endif ; #define POWER_COLLAPSE_KHZ MAX_AXI_KHZ 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; #define WAIT_FOR_IRQ_KHZ MAX_AXI_KHZ 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; static int acpuclk_set_acpu_vdd(struct clkctl_acpu_speed s) int ret = msm_spm_set_vdd(0, s->vdd_raw); if (ret) return ret; / Wait for voltage to stabilize. / udelay(drv_state.vdd_switch_time_us); return 0; / Set clock source and divider given a clock speed / static void acpuclk_set_src(const struct clkctl_acpu_speed s) uint32_t reg_clksel, reg_clkctl, src_sel; reg_clksel = readl(scss_clk_sel_addr); / CLK_SEL_SRC1NO / src_sel = reg_clksel & 1; / Program clock source and divider. / reg_clkctl = readl(scss_clk_ctl_addr); reg_clkctl &= ~(0xFF << (8 src_sel)); reg_clkctl = s->acpu_src_sel << (4 + 8 src_sel); reg_clkctl = s->acpu_src_div << (0 + 8 src_sel); writel(reg_clkctl, SCSS_CLK_CTL_ADDR);

6 / Program PLL2 L val for overclocked speeds. / if(s->src == PLL_2) writel(s->acpu_clk_khz/19200, PLL2_L_VAL_ADDR); / Toggle clock source. / reg_clksel ^= 1; / Program clock source selection. / writel(reg_clksel, SCSS_CLK_SEL_ADDR); int acpuclk_set_rate(int cpu, unsigned long rate, enum setrate_reason reason) struct clkctl_acpu_speed tgt_s, strt_s; int res, rc = 0; if (reason == SETRATE_CPUFREQ) mutex_lock(&drv_state.lock); strt_s = drv_state.current_speed; if (rate == strt_s->acpu_clk_khz) goto out; for (tgt_s = acpu_freq_tbl; tgt_s->acpu_clk_khz!= 0; tgt_s++) if (tgt_s->acpu_clk_khz == rate) break; if (tgt_s->acpu_clk_khz == 0) rc = -EINVAL; goto out; if (reason == SETRATE_CPUFREQ) / Increase VDD if needed. / if (tgt_s->vdd_mv > strt_s->vdd_mv) rc = acpuclk_set_acpu_vdd(tgt_s); if (rc < 0) pr_err("acpu VDD increase to %d mv failed " "(%d)\n", tgt_s->vdd_mv, rc); goto out; dprintk("switching from ACPU rate %u KHz -> %u KHz\n", strt_s->acpu_clk_khz, tgt_s->acpu_clk_khz); / Increase the AXI bus frequency if needed. This must be done before increasing the ACPU frequency, since voting for high AXI rates implicitly takes care of increasing the MSMC1 voltage, as needed. / if (tgt_s->axi_clk_hz > strt_s->axi_clk_hz) rc = clk_set_min_rate(drv_state.ebi1_clk, tgt_s->axi_clk_hz); if (rc < 0) pr_err("setting AXI min rate failed (%d)\n", rc);

7 goto out; / Make sure target PLL is on. / if (strt_s->src!= tgt_s->src && tgt_s->src >= 0) dprintk("enabling PLL %d\n", tgt_s->src); local_src_enable(tgt_s->src); 3. Kconfig config CPU_FREQ bool "CPU Frequency scaling" CPU Frequency scaling allows you to change the clock speed of CPUs on the fly. This is a nice method to save power, because the lower the CPU clock speed, the less power the CPU consumes. if CPU_FREQ Note that this driver doesn't automatically change the CPU clock speed, you need to either enable a dynamic cpufreq governor (see below) after boot, or use a userspace tool. For details, take a look at <file:documentation/cpu-freq>. If in doubt, say N. config CPU_FREQ_TABLE tristate config CPU_FREQ_DEBUG bool "Enable CPUfreq debugging" Say Y here to enable CPUfreq subsystem (including drivers) debugging. You will need to activate it via the kernel command line by passing cpufreq.debug=<value> To get <value>, add 1 to activate CPUfreq core debugging, 2 to activate CPUfreq drivers debugging, and 4 to activate CPUfreq governor debugging config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE default y This driver exports CPU frequency statistics information through sysfs file system. To compile this driver as a module, choose M here: the module will be called cpufreq_stats. If in doubt, say N.

8 config CPU_FREQ_STAT_DETAILS bool "CPU frequency translation statistics details" depends on CPU_FREQ_STAT This will show detail CPU frequency translation table in sysfs file system. If in doubt, say N. choice prompt "Default CPUFreq governor" default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 CPU_FREQ_SA1110 default CPU_FREQ_DEFAULT_GOV_PERFORMANCE This option sets which CPUFreq governor shall be loaded at startup. If in doubt, select 'performance'. config CPU_FREQ_DEFAULT_GOV_PERFORMANCE bool "performance" select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'performance' as default. This sets the frequency statically to the highest frequency supported by the CPU. config CPU_FREQ_DEFAULT_GOV_POWERSAVE bool "powersave" depends on EMBEDDED select CPU_FREQ_GOV_POWERSAVE Use the CPUFreq governor 'powersave' as default. This sets the frequency statically to the lowest frequency supported by the CPU. config CPU_FREQ_DEFAULT_GOV_USERSPACE bool "userspace" select CPU_FREQ_GOV_USERSPACE Use the CPUFreq governor 'userspace' as default. This allows you to set the CPU frequency manually or when a userspace program shall be able to set the CPU dynamically without having to enable the userspace governor manually. config CPU_FREQ_DEFAULT_GOV_ONDEMAND bool "ondemand" select CPU_FREQ_GOV_ONDEMAND select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'ondemand' as default. This allows you to get a full dynamic frequency capable system by simply loading your cpufreq low-level hardware driver. Be aware that not all cpufreq drivers support the ondemand governor. If unsure have a look at the section of the driver. Fallback governor will be the performance governor. config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE bool "conservative"

9 select CPU_FREQ_GOV_CONSERVATIVE select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'conservative' as default. This allows you to get a full dynamic frequency capable system by simply loading your cpufreq low-level hardware driver. Be aware that not all cpufreq drivers support the conservative governor. If unsure have a look at the section of the driver. Fallback governor will be the performance governor. config CPU_FREQ_DEFAULT_GOV_INTERACTIVE bool "interactive" select CPU_FREQ_GOV_INTERACTIVE Use the 'interactive' governor as default. This gets full cpu frequency scaling for workloads that are latency sensitive, typically interactive workloads.. config CPU_FREQ_DEFAULT_GOV_LAGFREE bool "lagfree" select CPU_FREQ_GOV_LAGFREE select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'lagfree' as default. This allows you to get a full dynamic frequency capable system by simply loading your cpufreq low-level hardware driver. Be aware that not all cpufreq drivers support the lagfree governor. If unsure have a look at the section of the driver. Fallback governor will be the performance governor. config CPU_FREQ_DEFAULT_GOV_SMARTASS bool "smartass" select CPU_FREQ_GOV_SMARTASS select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq Governor 'smartass' as default. config CPU_FREQ_DEFAULT_GOV_SCARY bool "scary" select CPU_FREQ_GOV_SCARY Use the CPUFreq governor 'scary' as default. config CPU_FREQ_DEFAULT_GOV_MINMAX bool "minmax" select CPU_FREQ_GOV_MINMAX select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'minmax' as default. This minimizes the frequency jumps does by the governor. This is aimed at maximizing both perfomance and battery life. config CPU_FREQ_DEFAULT_GOV_SAVAGEDZEN bool "SavagedZen" select CPU_FREQ_GOV_SAVAGEDZEN Use the CPUFreq governor 'savagedzen' as default.

10 config CPU_FREQ_DEFAULT_GOV_INTERACTIVEX bool "interactivex" select CPU_FREQ_GOV_INTERACTIVEX Use the CPUFreq governor 'interactivex' as default. This allows you to get a full dynamic cpu frequency capable system by simply loading your cpufreq low-level hardware driver, using the 'interactivex' governor for latency-sensitive workloads. config CPU_FREQ_DEFAULT_GOV_SMARTASS2 bool "smartass2" select CPU_FREQ_GOV_SMARTASS2 Use the CPUFreq governor 'smartassv2' as default. config CPU_FREQ_DEFAULT_GOV_SMOOTHASS bool "smoothass" select CPU_FREQ_GOV_SMOOTHASS select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'smoothass' as default. config CPU_FREQ_DEFAULT_GOV_BRAZILIANWAX bool "brazilianwax" select CPU_FREQ_GOV_BRAZILIANWAX select CPU_FREQ_GOV_PERFORMANCE Use the CPUFreq governor 'brazilianwax as default. endchoice config CPU_FREQ_GOV_PERFORMANCE tristate "'performance' governor" This cpufreq governor sets the frequency statically to the highest available CPU frequency. To compile this driver as a module, choose M here: the module will be called cpufreq_performance. If in doubt, say Y. config CPU_FREQ_GOV_POWERSAVE tristate "'powersave' governor" This cpufreq governor sets the frequency statically to the lowest available CPU frequency. To compile this driver as a module, choose M here: the module will be called cpufreq_powersave. If in doubt, say Y. config CPU_FREQ_GOV_USERSPACE tristate "'userspace' governor for userspace frequency scaling" Enable this cpufreq governor when you either want to set the CPU frequency manually or when a userspace program shall

11 be able to set the CPU dynamically, like on LART < To compile this driver as a module, choose M here: the module will be called cpufreq_userspace. For details, take a look at <file:documentation/cpu-freq/>. If in doubt, say Y. config CPU_FREQ_GOV_ONDEMAND tristate "'ondemand' cpufreq policy governor" select CPU_FREQ_TABLE 'ondemand' - This driver adds a dynamic cpufreq policy governor. The governor does a periodic polling and changes frequency based on the CPU utilization. The support for this governor depends on CPU capability to do fast frequency switching (i.e, very low latency frequency transitions). To compile this driver as a module, choose M here: the module will be called cpufreq_ondemand. For details, take a look at linux/documentation/cpu-freq. If in doubt, say N. config CPU_FREQ_GOV_INTERACTIVE tristate "'interactive' cpufreq policy governor" 'interactive' - This driver adds a dynamic cpufreq policy governor. Designed for low latency burst workloads. Scaling it done when coming out of idle instead of polling. config CPU_FREQ_GOV_CONSERVATIVE tristate "'conservative' cpufreq governor" depends on CPU_FREQ 'conservative' - this driver is rather similar to the 'ondemand' governor both in its source code and its purpose, the difference is its optimisation for better suitability in a battery powered environment. The frequency is gracefully increased and decreased rather than jumping to 100% when speed is required. If you have a desktop machine then you should really be considering the 'ondemand' governor instead, however if you are using a laptop, PDA or even an AMD64 based computer (due to the unacceptable step-by-step latency issues between the minimum and maximum frequency transitions in the CPU) you will probably want to use this governor. To compile this driver as a module, choose M here: the module will be called cpufreq_conservative. For details, take a look at linux/documentation/cpu-freq. If in doubt, say N.

12 config CPU_FREQ_VDD_LEVELS bool "CPU Vdd levels sysfs interface" depends on CPU_FREQ_STAT depends on ARCH_MSM7X30 default n CPU Vdd levels sysfs interface config CPU_FREQ_GOV_LAGFREE tristate "'lagfree' cpufreq governor" depends on CPU_FREQ 'lagfree' - this driver is rather similar to the 'ondemand' governor both in its source code and its purpose, the difference is its optimisation for better suitability in a battery powered environment. The frequency is gracefully increased and decreased rather than jumping to 100% when speed is required. To compile this driver as a module, choose M here: the module will be called cpufreq_lagfree. For details, take a look at linux/documentation/cpu-freq. If in doubt, say N. config CPU_FREQ_GOV_SMARTASS tristate "'smartass' cpufreq governor" depends on CPU_FREQ 'smartass' - a "smart" optimized governor config CPU_FREQ_GOV_SCARY tristate "'scary' cpufreq governor" depends on CPU_FREQ scary - a governor for cabbages If in doubt, say N. config CPU_FREQ_GOV_BRAZILIANWAX tristate "'brazilianwax' cpufreq governor" depends on CPU_FREQ 'brazilianwax' - a "slightly more agressive smart" optimized governor! config CPU_FREQ_GOV_MINMAX tristate "'minmax' cpufreq governor" depends on CPU_FREQ 'minmax' - this driver tries to minimize the frequency jumps by limiting the the selected frequencies to either the min or the max frequency of the policy. The frequency is selected according to the load. If in doubt, say N. config CPU_FREQ_GOV_INTERACTIVEX tristate "'interactivex' cpufreq policy governor"

13 'interactivex' - Modified version of interactive with sleep+wake code. config CPU_FREQ_GOV_SAVAGEDZEN tristate "'savagedzen' cpufreq governor" depends on CPU_FREQ 'Savaged-Zen' - a "smartass" based governor If in doubt, say N. config CPU_FREQ_GOV_SMARTASS2 tristate "'smartassv2' cpufreq governor" depends on CPU_FREQ 'smartassv2' - a "smart" optimized governor for the hero! If in doubt, say N. config CPU_FREQ_GOV_SMOOTHASS tristate "'smoothass' cpufreq governor" depends on CPU_FREQ smoothass' - a "slightly more agressive smartass" governor! If in doubt, say N. config CPU_FREQ_MIN_TICKS int "Ticks between governor polling interval." default 10 Minimum number of ticks between polling interval for governors. config CPU_FREQ_SAMPLING_LATENCY_MULTIPLIER int "Sampling rate multiplier for governors." default 1000 Sampling latency rate multiplied by the cpu switch latency. Affects governor polling. endif # CPU_FREQ 4. Makefile # CPUfreq core obj-$(config_cpu_freq) # CPUfreq stats obj-$(config_cpu_freq_stat) += cpufreq.o += cpufreq_stats.o # CPUfreq governors obj-$(config_cpu_freq_gov_performance) += cpufreq_performance.o obj-$(config_cpu_freq_gov_powersave) += cpufreq_powersave.o obj-$(config_cpu_freq_gov_userspace) += cpufreq_userspace.o obj-$(config_cpu_freq_gov_ondemand) += cpufreq_ondemand.o obj-$(config_cpu_freq_gov_conservative) += cpufreq_conservative.o obj-$(config_cpu_freq_gov_interactive) += cpufreq_interactive.o obj-$(config_cpu_freq_gov_smartass) += cpufreq_smartass.o obj-$(config_cpu_freq_gov_scary) += cpufreq_scary.o obj-$(config_cpu_freq_gov_minmax) += cpufreq_minmax.o obj-$(config_cpu_freq_gov_lagfree) += cpufreq_lagfree.o obj-$(config_cpu_freq_gov_interactivex) += cpufreq_interactivex.o

14 obj-$(config_cpu_freq_gov_savagedzen) += cpufreq_savagedzen.o obj-$(config_cpu_freq_gov_smartass2) += cpufreq_smartass2.o obj-$(config_cpu_freq_gov_smoothass) += cpufreq_smoothass.o obj-$(config_cpu_freq_gov_brazilianwax) += cpufreq_brazilianwax.o obj-$(config_cpu_freq_gov_screen) # CPUfreq cross-arch ers obj-$(config_cpu_freq_table) += cpufreq_screen.o += freq_table.o 5. Cpufreq.h / linux/include/linux/cpufreq.h Copyright (C) 2001 Russell King (C) Dominik Brodowski <linux@brodo.de> 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. / #ifndef _LINUX_CPUFREQ_H #define _LINUX_CPUFREQ_H #include <linux/mutex.h> #include <linux/notifier.h> #include <linux/threads.h> #include <linux/device.h> #include <linux/kobject.h> #include <linux/sysfs.h> #include <linux/completion.h> #include <linux/workqueue.h> #include <linux/cpumask.h> #include <asm/div64.h> #define CPUFREQ_NAME_LEN 16 / CPUFREQ NOTIFIER INTERFACE / #define CPUFREQ_TRANSITION_NOTIFIER (0) #define CPUFREQ_POLICY_NOTIFIER (1) #ifdef CONFIG_CPU_FREQ int cpufreq_register_notifier(struct notifier_block nb, unsigned int list); int cpufreq_unregister_notifier(struct notifier_block nb, unsigned int list); #else / CONFIG_CPU_FREQ / static inline int cpufreq_register_notifier(struct notifier_block nb, unsigned int list) return 0; static inline int cpufreq_unregister_notifier(struct notifier_block nb, unsigned int list)

15 return 0; #endif / CONFIG_CPU_FREQ / / if (cpufreq_driver->target) exists, the ->governor decides what frequency within the limits is used. If (cpufreq_driver->setpolicy> exists, these two generic policies are available: / #define CPUFREQ_POLICY_POWERSAVE (1) #define CPUFREQ_POLICY_PERFORMANCE (2) / Frequency values here are CPU khz so that hardware which doesn't run with some frequencies can complain without having to guess what per cent / per mille means. Maximum transition latency is in nanoseconds - if it's unknown, CPUFREQ_ETERNAL shall be used. / struct cpufreq_governor; / /sys/devices/system/cpu/cpufreq: entry point for global variables / extern struct kobject cpufreq_global_kobject; #define CPUFREQ_ETERNAL (-1) struct cpufreq_cpuinfo unsigned int max_freq; unsigned int min_freq; unsigned int transition_latency; / in 10^(-9) s = nanoseconds / ; struct cpufreq_real_policy unsigned int min; / in khz / unsigned int max; / in khz / unsigned int policy; / see above / struct cpufreq_governor governor; / see below / ; struct cpufreq_policy cpumask_var_t cpus; / CPUs requiring sw coordination / cpumask_var_t related_cpus; / CPUs with any coordination / unsigned int shared_type; / ANY or ALL affected CPUs should set cpufreq / unsigned int cpu; / cpu nr of registered CPU / struct cpufreq_cpuinfo cpuinfo;/ see above / unsigned int min; / in khz / unsigned int max; / in khz / unsigned int cur; / in khz, only needed if cpufreq governors are used / unsigned int policy; / see above / struct cpufreq_governor governor; / see below / struct work_struct update; / if update_policy() needs to be called, but you're in IRQ context / struct cpufreq_real_policy user_policy;

16 ; struct kobject kobj; struct completion kobj_unregister; #define CPUFREQ_ADJUST (0) #define CPUFREQ_INCOMPATIBLE (1) #define CPUFREQ_NOTIFY (2) #define CPUFREQ_START (3) #define CPUFREQ_SHARED_TYPE_NONE (0) / None / #define CPUFREQ_SHARED_TYPE_HW (1) / HW does needed coordination / #define CPUFREQ_SHARED_TYPE_ALL (2) / All dependent CPUs should set freq / #define CPUFREQ_SHARED_TYPE_ANY (3) / Freq can be set from any dependent CPU/ / cpufreq transition notifiers / #define CPUFREQ_PRECHANGE (0) #define CPUFREQ_POSTCHANGE (1) #define CPUFREQ_RESUMECHANGE (8) #define CPUFREQ_SUSPENDCHANGE (9) struct cpufreq_freqs unsigned int cpu; / cpu nr / unsigned int old; unsigned int new; u8 flags; / flags of cpufreq_driver, see below. / ; / cpufreq_scale - "old mult / div" calculation for large values (32-bit-arch old multiplier new = old mult / div / static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) #if BITS_PER_LONG == 32 u64 result = ((u64) old) ((u64) mult); do_div(result, div); return (unsigned long) result; #elif BITS_PER_LONG == 64 #endif ; unsigned long result = old ((u64) mult); result /= div; return result; /

17 CPUFREQ GOVERNORS / #define CPUFREQ_GOV_START 1 #define CPUFREQ_GOV_STOP 2 #define CPUFREQ_GOV_LIMITS 3 struct cpufreq_governor char name[cpufreq_name_len]; int (governor) (struct cpufreq_policy policy, unsigned int event); ssize_t (show_setspeed) (struct cpufreq_policy policy, char buf); int (store_setspeed)(struct cpufreq_policy policy, unsigned int freq); unsigned int max_transition_latency; / HW must be able to switch to next freq faster than this value in nano secs or we will fallback to performance governor / struct list_head governor_list; struct module owner; ; / pass a target to the cpufreq driver / extern int cpufreq_driver_target(struct cpufreq_policy policy, unsigned int target_freq, unsigned int relation); extern int cpufreq_driver_target(struct cpufreq_policy policy, unsigned int target_freq, unsigned int relation); extern int cpufreq_driver_getavg(struct cpufreq_policy policy, unsigned int cpu); int cpufreq_register_governor(struct cpufreq_governor governor); void cpufreq_unregister_governor(struct cpufreq_governor governor); int lock_policy_rwsem_read(int cpu); int lock_policy_rwsem_write(int cpu); void unlock_policy_rwsem_read(int cpu); void unlock_policy_rwsem_write(int cpu); / CPUFREQ DRIVER INTERFACE / #define CPUFREQ_RELATION_L 0 / lowest frequency at or above target / #define CPUFREQ_RELATION_H 1 / highest frequency below or at target / struct freq_attr; struct cpufreq_driver struct module char u8 owner; name[cpufreq_name_len]; flags;

18 / needed by all drivers / int (init) (struct cpufreq_policy policy); int (verify) (struct cpufreq_policy policy); / define one out of two / int (setpolicy) (struct cpufreq_policy policy); int (target) (struct cpufreq_policy policy, unsigned int target_freq, unsigned int relation); / should be defined, if possible / unsigned int (get) (unsigned int cpu); / optional / unsigned int (getavg) (struct cpufreq_policy policy, unsigned int cpu); ; int (exit) (struct cpufreq_policy policy); int (suspend) (struct cpufreq_policy policy, pm_message_t pmsg); int (resume) (struct cpufreq_policy policy); struct freq_attr attr; / flags / #define CPUFREQ_STICKY 0x01 / the driver isn't removed even if all ->init() calls failed / #define CPUFREQ_CONST_LOOPS 0x02 / loops_per_jiffy or other kernel "constants" aren't affected by frequency transitions / #define CPUFREQ_PM_NO_WARN 0x04 / don't warn on suspend/resume speed mismatches / int cpufreq_register_driver(struct cpufreq_driver driver_data); int cpufreq_unregister_driver(struct cpufreq_driver driver_data); void cpufreq_notify_transition(struct cpufreq_freqs freqs, unsigned int state); static inline void cpufreq_verify_within_limits(struct cpufreq_policy policy, unsigned int min, unsigned int max) if (policy->min < min) policy->min = min; if (policy->max < min) policy->max = min; if (policy->min > max) policy->min = max; if (policy->max > max) policy->max = max; if (policy->min > policy->max) policy->min = policy->max; return; struct freq_attr

19 ; struct attribute attr; ssize_t (show)(struct cpufreq_policy, char ); ssize_t (store)(struct cpufreq_policy, const char, size_t count); struct global_attr struct attribute attr; ssize_t (show)(struct kobject kobj, struct attribute attr, char buf); ssize_t (store)(struct kobject a, struct attribute b, const char c, size_t count); ; / CPUFREQ 2.6. INTERFACE / int cpufreq_get_policy(struct cpufreq_policy policy, unsigned int cpu); int cpufreq_update_policy(unsigned int cpu); #ifdef CONFIG_CPU_FREQ / query the current CPU frequency (in khz). If zero, cpufreq couldn't detect it / unsigned int cpufreq_get(unsigned int cpu); #else static inline unsigned int cpufreq_get(unsigned int cpu) return 0; #endif / query the last known CPU freq (in khz). If zero, cpufreq couldn't detect it / #ifdef CONFIG_CPU_FREQ unsigned int cpufreq_quick_get(unsigned int cpu); #else static inline unsigned int cpufreq_quick_get(unsigned int cpu) return 0; #endif / CPUFREQ DEFAULT GOVERNOR / / Performance governor is fallback governor if any other gov failed to auto load due latency restrictions / #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE extern struct cpufreq_governor cpufreq_gov_performance; #endif #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_performance) #elif defined(config_cpu_freq_default_gov_powersave) extern struct cpufreq_governor cpufreq_gov_powersave; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_powersave) #elif defined(config_cpu_freq_default_gov_userspace)

20 extern struct cpufreq_governor cpufreq_gov_userspace; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_userspace) #elif defined(config_cpu_freq_default_gov_ondemand) extern struct cpufreq_governor cpufreq_gov_ondemand; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_ondemand) #elif defined(config_cpu_freq_default_gov_conservative) extern struct cpufreq_governor cpufreq_gov_conservative; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) #elif defined(config_cpu_freq_default_gov_interactivex) extern struct cpufreq_governor cpufreq_gov_interactivex; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_interactivex) #elif defined(config_cpu_freq_default_gov_lagfree) extern struct cpufreq_governor cpufreq_gov_lagfree; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_lagfree) #elif defined(config_cpu_freq_default_gov_smartass) extern struct cpufreq_governor cpufreq_gov_smartass; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_smartass) #elif defined(config_cpu_freq_default_gov_scary) extern struct cpufreq_governor cpufreq_gov_scary; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_scary) #elif defined(config_cpu_freq_default_gov_smartass2) extern struct cpufreq_governor cpufreq_gov_smartass2; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_smartass2) #endif

21

22 KEMENTERIAN PENDIDIKAN NASIONAL UNIVERSITAS SUMATARA UTARA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM Jln. Bioteknologi No.1 Kampus USU Padang Bulan Medan Telp. (061) , , Fax. (061) Medan SURAT KETERANGAN Hasil Uji Program Tugas Akhir Yang bertanda tangan di bawah ini, menerangkan bahwa Mahasiswa Tugas Akhir Program Diploma 3 Teknik Informatika : Nama : Audio Prima Persada NIM : Program Studi : D3 Teknik Informatika Judul Tugas Akhir : PEMBUATAN DAN PENGEMBANGAN FITUR KERNEL ANDROID PADA SONY XPERIA RAY Telah melaksanakan test program Tugas Akhir Mahasiswa tersebut di atas pada tanggal 10 Januari 2014 Dengan Hasil : SUKSES / GAGAL Demikian diterangkan untuk digunakan melengkapi syarat pendaftaran Ujian Meja Hijau Tugas Akhir Mahasiswa bersangkutan di Departemen Matematika FMIPA USU Medan. Medan, 10 Januari 2014 Dosen Pembimbing Program Studi D3 Teknik Informatika Sajadin Sembiring S.Si, M. Comp.Sc.

- information for users and developers - Dominik Brodowski some additions and corrections by Nico Golde

- information for users and developers - Dominik Brodowski some additions and corrections by Nico Golde 1 von 5 11.10.2016 10:03 CPU frequency and voltage scaling code in the Linux(TM) kernel L i n u x C P U F r e q C P U F r e q G o v e r n o r s - information for users and developers - Dominik Brodowski

More information

LISTING PROGRAM. 1. Tampilan Awal. 2. Menu Login. Public Class Awal

LISTING PROGRAM. 1. Tampilan Awal. 2. Menu Login. Public Class Awal LISTING PROGRAM 1. Tampilan Awal Public Class Awal Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.Increment(10) If ProgressBar1.Value

More information

Operating Systems Design 25. Power Management. Paul Krzyzanowski

Operating Systems Design 25. Power Management. Paul Krzyzanowski Operating Systems Design 25. Power Management Paul Krzyzanowski pxk@cs.rutgers.edu 1 Power Management Goal: Improve the battery life of mobile devices 2 CPU Voltage & Frequency Scaling Dynamic CPU Frequency

More information

Energy Efficiency in Operating Systems

Energy Efficiency in Operating Systems Devices Timer interrupts CPU idling CPU frequency scaling Energy-aware scheduling Energy Efficiency in Operating Systems Björn Brömstrup Arbeitsbereich Wissenschaftliches Rechnen Fachbereich Informatik

More information

KARTU BIMBINGAN TUGAS AKHIR MAHASISWA PEMBAHASAN PADA ASISTENSI MENGENAI, PADA BAB

KARTU BIMBINGAN TUGAS AKHIR MAHASISWA PEMBAHASAN PADA ASISTENSI MENGENAI, PADA BAB 62 KEMENTERIAN PENDIDIKAN NASIONAL UNIVERSITAS SUMATERA UTARA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM Jl. Bioteknologi No.1 Kampus USU Padang Bulan Medan 20155 Telp. (061) 8211050, 8214290, Fax (061)

More information

Power Management for Embedded Systems

Power Management for Embedded Systems Power Management for Embedded Systems Minsoo Ryu Hanyang University Why Power Management? Battery-operated devices Smartphones, digital cameras, and laptops use batteries Power savings and battery run

More information

cpuidle Do nothing, efficiently...

cpuidle Do nothing, efficiently... cpuidle Do nothing, efficiently... Venkatesh Pallipadi Shaohua Li Intel Open Source Technology Center {venkatesh.pallipadi shaohua.li}@intel.com Adam Belay Novell, Inc. abelay@novell.com Abstract Most

More information

In object-oriented terms, kobjects can be seen as a top-level, abstract class from which other classes are derived.

In object-oriented terms, kobjects can be seen as a top-level, abstract class from which other classes are derived. KOBJECTS Why kobjects? kobjects are used to control access to a larger, domain-specific object. In object-oriented terms, kobjects can be seen as a top-level, abstract class from which other classes are

More information

QoS Handling with DVFS (CPUfreq & Devfreq)

QoS Handling with DVFS (CPUfreq & Devfreq) QoS Handling with DVFS (CPUfreq & Devfreq) MyungJoo Ham SW Center, 1 Performance Issues of DVFS Performance Sucks w/ DVFS! Battery-life Still Matters More Devices (components) w/ DVFS More Performance

More information

CHAPTER 7 IMPLEMENTATION OF DYNAMIC VOLTAGE SCALING IN LINUX SCHEDULER

CHAPTER 7 IMPLEMENTATION OF DYNAMIC VOLTAGE SCALING IN LINUX SCHEDULER 73 CHAPTER 7 IMPLEMENTATION OF DYNAMIC VOLTAGE SCALING IN LINUX SCHEDULER 7.1 INTRODUCTION The proposed DVS algorithm is implemented on DELL INSPIRON 6000 model laptop, which has Intel Pentium Mobile Processor

More information

Using kgdb and the kgdb Internals

Using kgdb and the kgdb Internals Using kgdb and the kgdb Internals Jason Wessel jason.wessel@windriver.com Tom Rini trini@kernel.crashing.org Amit S. Kale amitkale@linsyssoft.com Using kgdb and the kgdb Internals by Jason Wessel by Tom

More information

POWER MANAGEMENT AND ENERGY EFFICIENCY

POWER MANAGEMENT AND ENERGY EFFICIENCY POWER MANAGEMENT AND ENERGY EFFICIENCY * Adopted Power Management for Embedded Systems, Minsoo Ryu 2017 Operating Systems Design Euiseong Seo (euiseong@skku.edu) Need for Power Management Power consumption

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

Open Source Used In c1101 and c1109 Cisco IOS XE Fuji

Open Source Used In c1101 and c1109 Cisco IOS XE Fuji Open Source Used In c1101 and c1109 Cisco IOS XE Fuji 16.8.1 Cisco Systems, Inc. www.cisco.com Cisco has more than 200 offices worldwide. Addresses, phone numbers, and fax numbers are listed on the Cisco

More information

Realtime Linux (RTAI) Multi-Tasking

Realtime Linux (RTAI) Multi-Tasking Realtime Linux (RTAI) Multi-Tasking Introduction Modern real-time systems are based on the complementary concepts of multitasking and intertask communications. A multitasking environment allows real-time

More information

Understand Linux Components

Understand Linux Components Understand Linux Components Kill Bugs, and Fix Wasteful Code Klaas van Gend 1 Agenda Linux is not a single building block Buy, Build, Borrow Deploy vs. Debug Demo: Use GDB Lab: Kill a bug Power Management

More information

HiKey970. I2C Development Guide. Issue 01. Date

HiKey970. I2C Development Guide. Issue 01. Date Issue 01 Date 2018-03-11 2018. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means without prior written consent of HiSilicon Technologies Co., Ltd.

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 2 CISTER Framework: Laboratory 2 Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 1 Introduction The goal of the CISTER framework is to create a set of tools that help

More information

Vinod Koul, Sanyog Kale Intel Corp. MIPI SoundWire Linux Subsystem: An introduction to Protocol and Linux Subsystem

Vinod Koul, Sanyog Kale Intel Corp. MIPI SoundWire Linux Subsystem: An introduction to Protocol and Linux Subsystem Vinod Koul, Sanyog Kale MIPI SoundWire Linux Subsystem: An introduction to Protocol and Linux Subsystem Agenda MIPI SoundWire Basics Linux Subsystem SoundWire Linux Bus SoundWire Master SoundWire Slave

More information

TIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013

TIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013 The Embedded I/O Company TIP675-SW-82 Linux Device Driver 48 TTL I/O Lines with Interrupts Version 1.2.x User Manual Issue 1.2.5 November 2013 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek, Germany

More information

7.4 Simple example of Linux drivers

7.4 Simple example of Linux drivers 407 7.4 Simple example of Linux drivers In the previous section, we introduce a simple Hello module driver, it is just some information from the serial port output, the board did not correspond to the

More information

NPTEL Course Jan K. Gopinath Indian Institute of Science

NPTEL Course Jan K. Gopinath Indian Institute of Science Storage Systems NPTEL Course Jan 2012 (Lecture 17) K. Gopinath Indian Institute of Science Accessing Devices/Device Driver Many ways to access devices under linux Non-block based devices ( char ) - stream

More information

The android vulnerability discovery in SoC. Yu Pan and Yang Dai

The android vulnerability discovery in SoC. Yu Pan and Yang Dai The android vulnerability discovery in SoC Yu Pan and Yang Dai About us Security researcher of Vulpecker Team@360 Android Vulnerabilities research Focus on kernel & driver Numerous vulnerabilities,including

More information

NPTEL Course Jan K. Gopinath Indian Institute of Science

NPTEL Course Jan K. Gopinath Indian Institute of Science Storage Systems NPTEL Course Jan 2012 (Lecture 18) K. Gopinath Indian Institute of Science Spinlocks & Semaphores Shared data betw different parts of code in kernel most common: access to data structures

More information

Using DPDK with Go. Takanari Hayama Technology Consulting Company IGEL Co.,Ltd.

Using DPDK with Go. Takanari Hayama Technology Consulting Company IGEL Co.,Ltd. Using DPDK with Go Technology Consulting Company Research, Development & Global Standard Takanari Hayama taki@igel.co.jp Technology Consulting Company IGEL Co.,Ltd. 1 BACKGROUND 2017/9/26,27 DPDK Summit

More information

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC The Embedded I/O Company TIP700-SW-82 Linux Device Driver Digital Output 24V DC Version 1.2.x User Manual Issue 1.2.1 February 2009 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 Phone: +49 (0) 4101 4058 0 25469

More information

LOCKDEP, AN INSIDE OUT PERSPECTIVE. Nahim El

LOCKDEP, AN INSIDE OUT PERSPECTIVE. Nahim El LOCKDEP, AN INSIDE OUT PERSPECTIVE Nahim El Atmani @brokenpi_pe P1 R1 R1 P2 THE BIG PICTURE The need for a proof mechanism PREVIOUSLY ON LINUX SMP Synchronization needed giant-lock (a.k.a big-lock, kernel-lock

More information

/* $Id: HGSMIBase.cpp $ */ * VirtualBox Video driver, common code - HGSMI initialisation and helper * functions. */

/* $Id: HGSMIBase.cpp $ */ * VirtualBox Video driver, common code - HGSMI initialisation and helper * functions. */ HGSMIBase.c /* $Id: HGSMIBase.cpp $ /** @file * VirtualBox Video driver, common code - HGSMI initialisation and helper * functions. /* * Copyright (C) 2006-2016 Oracle Corporation * * This file is part

More information

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19)

Homework / Exam. Return and Review Exam #1 Reading. Machine Projects. Labs. S&S Extracts , PIC Data Sheet. Start on mp3 (Due Class 19) Homework / Exam Return and Review Exam #1 Reading S&S Extracts 385-393, PIC Data Sheet Machine Projects Start on mp3 (Due Class 19) Labs Continue in labs with your assigned section 1 Interrupts An interrupt

More information

Linux Power Management Experiences on Moorestown

Linux Power Management Experiences on Moorestown Linux Power Management Experiences on Moorestown Kristen Accardi Len Brown Intel Open Source Technology Center Linux Plumbers Conference Sept. 8, 2011 Santa Rosa, CA PCI on MRST Lincroft Graphics is

More information

Interrupt Handler: Bottom Half. Changwoo Min

Interrupt Handler: Bottom Half. Changwoo Min 1 Interrupt Handler: Bottom Half Changwoo Min 2 Project 3 TA Jinwoo Yom (jinwoo@vt.edu) 3 Hands-on day and office hours Hands-on day (10/09, Tue) In-class design discussion Led by the Project TA, Jinwoo

More information

Programming refresher and intro to C programming

Programming refresher and intro to C programming Applied mechatronics Programming refresher and intro to C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2018 Outline 1 C programming intro 2

More information

Kartu Bimbingan Tugas Akhir Mahasiswa

Kartu Bimbingan Tugas Akhir Mahasiswa KEMENTRIAN PENDIDIKAN DAN KEBUDAYAAN UNIVERSITAS SUMATERA UTARA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM Jln. Bioteknologi No. 1 Kampus USU Padang Bulan Medan-20155 Telp. (061) 8214290, 8211212, 8211414

More information

cs 140 project 1: threads 9 January 2015

cs 140 project 1: threads 9 January 2015 cs 140 project 1: threads 9 January 2015 git The basics: git clone git add git commit git branch git merge git stash git pull git push git rebase git Some guidelines & ideas: Write helpful commit and stash

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 2 Kernel Build System and Process Management Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 PBS LKD: S2 1 / 41 Disclaimer Material and Slides Some of the material/slides

More information

Power Management as I knew it. Jim Kardach

Power Management as I knew it. Jim Kardach Power Management as I knew it Jim Kardach 1 Agenda Philosophy of power management PM Timeline Era of OS Specific PM (OSSPM) Era of OS independent PM (OSIPM) Era of OS Assisted PM (APM) Era of OS & hardware

More information

The Power Supply Subsystem

The Power Supply Subsystem The Power Supply Subsystem Sebastian Reichel Collabora October 24, 2018 Sebastian Reichel Embedded Linux engineer at Collabora Open Source Consultancy Based in Oldenburg, Germany Open Source contributor

More information

APPLICATION NOTE 5306 Programming Baud Rates of the MAX3108 UART

APPLICATION NOTE 5306 Programming Baud Rates of the MAX3108 UART Maxim > Design Support > Technical Documents > Application Notes > Interface Circuits > APP 5306 Keywords: UART, RS232, RS485, SPI, I2C, half duplex, HDX, full duplex, FDX, WLP, wafer level package, FIFO,

More information

Macros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang

Macros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang Macros and Preprocessor CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang Previously Operations on Linked list (Create and Insert) Agenda Linked List (More insert, lookup and delete) Preprocessor Linked List

More information

Kernel Modules. Kartik Gopalan

Kernel Modules. Kartik Gopalan Kernel Modules Kartik Gopalan Kernel Modules Allow code to be added to the kernel, dynamically Only those modules that are needed are loaded. Unload when no longer required - frees up memory and other

More information

System Interconnect Software Programming Interface

System Interconnect Software Programming Interface System Interconnect Software Programming Interface Overview By Steve Shih and Alex Chang This document describes the programming interface of the system interconnect software components. Specifically,

More information

Constant-time programming in C

Constant-time programming in C Constant-time programming in C What s our goal? Goal: Write C programs that don t leak sensitive data Assumption: no explicit leaks E.g., writing secret data to public location Approach: constant-time

More information

Dongjun Shin Samsung Electronics

Dongjun Shin Samsung Electronics 2014.10.31. Dongjun Shin Samsung Electronics Contents 2 Background Understanding CPU behavior Experiments Improvement idea Revisiting Linux I/O stack Conclusion Background Definition 3 CPU bound A computer

More information

Bridging of Control Interfaces over Multimedia Serial Links

Bridging of Control Interfaces over Multimedia Serial Links Bridging of Control Interfaces over Multimedia Serial Links Vladimir Zapolskiy Open Source Senior Software Engineer June 22, 2018 Introduction Embedded Linux developer since 2006 Open Source Software contributor

More information

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to.

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. Refresher When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. i.e. char *ptr1 = malloc(1); ptr1 + 1; // adds 1 to pointer

More information

The CMXTracker Manual. The CMXTracker Manual

The CMXTracker Manual. The CMXTracker Manual The CMXTracker Manual The CMX CMXTracker TM Code Analyzer provides the ability to log chronologically in real-time, the tasks' execution flow, capturing when a task is executing, the CMX functions called

More information

CODE TIME TECHNOLOGIES. Abassi RTOS. I2C Support

CODE TIME TECHNOLOGIES. Abassi RTOS. I2C Support CODE TIME TECHNOLOGIES Abassi RTOS I2C Support Copyright Information This document is copyright Code Time Technologies Inc. 2015-2018 All rights reserved. No part of this document may be reproduced or

More information

AD916x API Specification Rev 1.0

AD916x API Specification Rev 1.0 AD916x API Specification Rev 1.0 Page 1 of 84 TABLE OF CONTENTS Introduction...5 Purpose...5 Scope...5 DISCLAIMER...5 Software Architecture...6 Folder Structure...7 API Interface...8 Overview...8 ad916x.h...8

More information

Lesson I2C. I²C (Inter-Integrated Circuit) Lab Assignment: I2C Slave Driver

Lesson I2C. I²C (Inter-Integrated Circuit) Lab Assignment: I2C Slave Driver Lesson I2C I²C (Inter-Integrated Circuit) Lab Assignment: I2C Slave Driver I²C (Inter-Integrated Circuit) What is I 2 C I2C is pronounced "eye-squared see". It is also known as "TWI" because of the initial

More information

REVISION HISTORY NUMBER DATE DESCRIPTION NAME

REVISION HISTORY NUMBER DATE DESCRIPTION NAME i ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME iii Contents 1 Walking through the Assignment 2 1 1.1 Preparing the base code from Assignment 1..................................... 1 1.2 Dummy port

More information

Embedded Linux Conference San Diego 2016

Embedded Linux Conference San Diego 2016 Embedded Linux Conference San Diego 2016 Linux Power Management Optimization on the Nvidia Jetson Platform Merlin Friesen merlin@gg-research.com About You Target Audience - The presentation is introductory

More information

Runtime Power Management Framework

Runtime Power Management Framework Runtime Power Management Framework for I/O Devices in the Linux Kernel Rafael J. Wysocki Faculty of Physics UW / SUSE Labs, Novell Inc. July 31, 2010 Rafael J. Wysocki (rjw@sisk.pl) Runtime Power Management

More information

Load Balancing. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab.

Load Balancing. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab. Load Balancing Minsoo Ryu Department of Computer Science and Engineering 2 1 Concepts of Load Balancing Page X 2 Load Balancing Algorithms Page X 3 Overhead of Load Balancing Page X 4 Load Balancing in

More information

Embedded Linux. Session 4: Introduction to the GPIO Kernel API. Martin Aebersold BFH-TI Dipl. El.-Ing. FH.

Embedded Linux. Session 4: Introduction to the GPIO Kernel API. Martin Aebersold BFH-TI Dipl. El.-Ing. FH. Embedded Linux Session 4: Introduction to the GPIO Kernel API Martin Aebersold BFH-TI Dipl. El.-Ing. FH martin.aebersold@bfh.ch Dr. Franz Meyer BFH-TI Prof. em. Franz.Meyer@bfh.ch GPIO General Purpose

More information

Unleashing D* on Android Kernel Drivers. Aravind Machiry

Unleashing D* on Android Kernel Drivers. Aravind Machiry Unleashing D* on Android Kernel Drivers Aravind Machiry (@machiry_msidc) $ whoami Fourth year P.h.D Student at University of California, Santa Barbara. Vulnerability Detection in System software. machiry.github.io

More information

Intelligent Power Allocation for Consumer & Embedded Thermal Control

Intelligent Power Allocation for Consumer & Embedded Thermal Control Intelligent Power Allocation for Consumer & Embedded Thermal Control Ian Rickards ARM Ltd, Cambridge UK ELC San Diego 5-April-2016 Existing Linux Thermal Framework Trip1 Trip0 Thermal trip mechanism using

More information

The mobile computing evolution. The Griffin architecture. Memory enhancements. Power management. Thermal management

The mobile computing evolution. The Griffin architecture. Memory enhancements. Power management. Thermal management Next-Generation Mobile Computing: Balancing Performance and Power Efficiency HOT CHIPS 19 Jonathan Owen, AMD Agenda The mobile computing evolution The Griffin architecture Memory enhancements Power management

More information

Zephyr on Beetle. Vincenzo Frascino Senior Engineer. OpenIoT, Portland, Oregon 22/02/2017 ARM 2017

Zephyr on Beetle. Vincenzo Frascino Senior Engineer. OpenIoT, Portland, Oregon 22/02/2017 ARM 2017 Zephyr on Beetle Vincenzo Frascino Senior Engineer OpenIoT, Portland, Oregon 22/02/2017 Agenda Overview Zephyr Architecture Zephyr on Beetle Contributing to Zephyr Beetle Examples and Demo 2 Overview 3

More information

User s Guide. Alexandra Yates Kristen C. Accardi

User s Guide. Alexandra Yates Kristen C. Accardi User s Guide Kristen C. Accardi kristen.c.accardi@intel.com Alexandra Yates alexandra.yates@intel.com PowerTOP is a Linux* tool used to diagnose issues related to power consumption and power management.

More information

T. Cucinotta Real-Time Systems Lab (ReTiS) Scuola Superiore Sant'Anna Pisa Italy 1. Real-Time Scheduling on Linux and SCHED_DEADLINE

T. Cucinotta Real-Time Systems Lab (ReTiS) Scuola Superiore Sant'Anna Pisa Italy 1. Real-Time Scheduling on Linux and SCHED_DEADLINE T. Cucinotta Real-Time Systems Lab (ReTiS) Scuola Superiore Sant'Anna Pisa Italy 1 Real-Time Scheduling on Linux and SCHED_DEADLINE Linux CPU Schedulers Scheduling classes and policies Classes listed in

More information

What we will learn. Threaded Systems: Threads. Threads. Threads. Bag of functions & procedures ST OS. AUCs. Threads. AUCs. Processes MT OS MP OS

What we will learn. Threaded Systems: Threads. Threads. Threads. Bag of functions & procedures ST OS. AUCs. Threads. AUCs. Processes MT OS MP OS What we will learn Threaded Systems: Threads A thread-driven approach is attractive in sensor networks for many of the same reasons that it has been adopted for PDAs, laptops, and servers. In a thread-driven

More information

ebpf-based tracing tools under 32 bit architectures

ebpf-based tracing tools under 32 bit architectures Linux Plumbers Conference 2018 ebpf-based tracing tools under 32 bit architectures Maciej Słodczyk Adrian Szyndela Samsung R&D Institute Poland

More information

Digital Input and Output

Digital Input and Output Digital Input and Output Topics: Parallel Digital I/O Simple Input (example) Parallel I/O I/O Scheduling Techniques Programmed Interrupt Driven Direct Memory Access Serial I/O Asynchronous Synchronous

More information

TPMC901-SW-95. QNX4 - Neutrino Device Driver. User Manual. The Embedded I/O Company. 6/4/2 Channel Extended CAN-Bus PMC

TPMC901-SW-95. QNX4 - Neutrino Device Driver. User Manual. The Embedded I/O Company. 6/4/2 Channel Extended CAN-Bus PMC The Embedded I/O Company TPMC901-SW-95 QNX4 - Neutrino Device Driver 6/4/2 Channel Extended CAN-Bus PMC User Manual Issue 1.0 Version 1.0.0 October 2002 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek

More information

Extending CircuitPython: An Introduction

Extending CircuitPython: An Introduction Extending CircuitPython: An Introduction Created by Dave Astels Last updated on 2018-11-15 11:08:03 PM UTC Guide Contents Guide Contents Overview How-To A Simple Example shared-module shared-bindings ports/atmel-samd

More information

Scheduling the Intel Core i7

Scheduling the Intel Core i7 Third Year Project Report University of Manchester SCHOOL OF COMPUTER SCIENCE Scheduling the Intel Core i7 Ibrahim Alsuheabani Degree Programme: BSc Software Engineering Supervisor: Prof. Alasdair Rawsthorne

More information

User s Guide. Alexandra Yates Kristen C. Accardi

User s Guide. Alexandra Yates Kristen C. Accardi User s Guide Kristen C. Accardi kristen.c.accardi@intel.com Alexandra Yates alexandra.yates@intel.com PowerTOP is a Linux* tool used to diagnose issues related to power consumption and power management.

More information

Real Time Linux patches: history and usage

Real Time Linux patches: history and usage Real Time Linux patches: history and usage Presentation first given at: FOSDEM 2006 Embedded Development Room See www.fosdem.org Klaas van Gend Field Application Engineer for Europe Why Linux in Real-Time

More information

How to get realistic C-states latency and residency? Vincent Guittot

How to get realistic C-states latency and residency? Vincent Guittot How to get realistic C-states latency and residency? Vincent Guittot Agenda Overview Exit latency Enter latency Residency Conclusion Overview Overview PMWG uses hikey960 for testing our dev on b/l system

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Computer Science 162, Fall 2014 David Culler University of California, Berkeley Midterm 1 September 29, 2014

Computer Science 162, Fall 2014 David Culler University of California, Berkeley Midterm 1 September 29, 2014 Computer Science 162, Fall 2014 David Culler University of California, Berkeley Midterm 1 September 29, 2014 Name SID Login TA Name Section Time This is a closed book exam with one 2-sided page of notes

More information

PRELIMINARY. QuickLogic ArcticLink III VX/BX CSSPs Software Integration Guide for Qualcomm Platform, MIPI Video Mode. Introduction

PRELIMINARY. QuickLogic ArcticLink III VX/BX CSSPs Software Integration Guide for Qualcomm Platform, MIPI Video Mode. Introduction QuickLogic ArcticLink III VX/BX CSSPs Software Integration Guide for Qualcomm Platform, MIPI Video Mode QuickLogic Application Note 100 Introduction This application note explains how integrate the QuickLogic

More information

AD9164 API Specification Rev 1.0

AD9164 API Specification Rev 1.0 AD9164 API Specification Rev 1.0 Page 1 of 89 ADI Confidential TABLE OF CONTENTS Introduction...5 Purpose...5 Scope...5 DISCLAIMER...5 Software Architecture...6 Folder Structure...7 API Interface...8 Overview...8

More information

Applying User-level Drivers on

Applying User-level Drivers on Applying User-level Drivers on DTV System Gunho Lee, Senior Research Engineer, ELC, April 18, 2007 Content Background Requirements of DTV Device Drivers Design of LG DTV User-level Drivers Implementation

More information

Interrupt/Timer/DMA 1

Interrupt/Timer/DMA 1 Interrupt/Timer/DMA 1 Exception An exception is any condition that needs to halt normal execution of the instructions Examples - Reset - HWI - SWI 2 Interrupt Hardware interrupt Software interrupt Trap

More information

Resource Power Manager

Resource Power Manager Qualcomm Technologies, Inc. Resource Power Manager API Reference LM80-P0436-74 Rev. A February 2, 2018 Qualcomm is a trademark of Qualcomm Incorporated, registered in the United States and other countries.

More information

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE SMART ARM-based Microcontrollers AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver APPLICATION NOTE Introduction This driver for Atmel SMART ARM -based microcontrollers provides an interface

More information

Decision Making -Branching. Class Incharge: S. Sasirekha

Decision Making -Branching. Class Incharge: S. Sasirekha Decision Making -Branching Class Incharge: S. Sasirekha Branching The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the

More information

REVISION HISTORY NUMBER DATE DESCRIPTION NAME

REVISION HISTORY NUMBER DATE DESCRIPTION NAME i ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME iii Contents 1 The structure of a Linux kernel module 1 1.1 Install XV6...................................................... 1 1.2 Compile and load a

More information

Tweaking Linux for a Green Datacenter

Tweaking Linux for a Green Datacenter Tweaking Linux for a Green Datacenter Vaidyanathan Srinivasan Jenifer Hopper Agenda Platform features and Linux exploitation Tuning scheduler and cpufreq

More information

Last One Out, Turn Off The Lights

Last One Out, Turn Off The Lights Last One Out, Turn Off The Lights Embedded Linux Conference 2015 Geert Uytterhoeven geert@linux-m68k.org Glider bvba Tuesday, March 24 c Copyright 2015 Glider bvba Table of Contents 2 / 55 About Me Introduction

More information

Programming Assignment Multi-Threading and Debugging 2

Programming Assignment Multi-Threading and Debugging 2 Programming Assignment Multi-Threading and Debugging 2 Due Date: Friday, June 1 @ 11:59 pm PAMT2 Assignment Overview The purpose of this mini-assignment is to continue your introduction to parallel programming

More information

MCUXpresso IDE FreeRTOS Debug Guide. Rev November, 2017

MCUXpresso IDE FreeRTOS Debug Guide. Rev November, 2017 MCUXpresso IDE FreeRTOS Debug Guide User guide 14 November, 2017 Copyright 2017 All rights reserved. ii 1. Introduction... 1 2. LinkServer FreeRTOS Thread Aware Debugging... 2 2.1. Behavior when thread

More information

POWER-AWARE SOFTWARE ON ARM. Paul Fox

POWER-AWARE SOFTWARE ON ARM. Paul Fox POWER-AWARE SOFTWARE ON ARM Paul Fox OUTLINE MOTIVATION LINUX POWER MANAGEMENT INTERFACES A UNIFIED POWER MANAGEMENT SYSTEM EXPERIMENTAL RESULTS AND FUTURE WORK 2 MOTIVATION MOTIVATION» ARM SoCs designed

More information

DT power domain bindings - idle states

DT power domain bindings - idle states 1 DT power domain bindings - idle states Lorenzo Pieralisi Sudeep Holla 20/8/15 - Energy Aware Scheduling II LPC microconference Outline Characterize

More information

Interrupt response times on Arduino and Raspberry Pi. Tomaž Šolc

Interrupt response times on Arduino and Raspberry Pi. Tomaž Šolc Interrupt response times on Arduino and Raspberry Pi Tomaž Šolc tomaz.solc@ijs.si Introduction Full-featured Linux-based systems are replacing microcontrollers in some embedded applications for low volumes,

More information

Asynchronous Events on Linux

Asynchronous Events on Linux Asynchronous Events on Linux Frederic.Rossi@Ericsson.CA Open System Lab Systems Research June 25, 2002 Ericsson Research Canada Introduction Linux performs well as a general purpose OS but doesn t satisfy

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE SMART ARM-based Microcontrollers AT11512: SAM L Brown Out Detector (BOD) Driver APPLICATION NOTE Introduction This driver for Atmel SMART ARM -based microcontrollers provides an interface for the configuration

More information

Linux Power Management Architecture

Linux Power Management Architecture Dipartimenti di Elettronica e Informazione Politecnico di Milano Patrick Bellasi bellasi@elet.polimi.it Linux Power Management Architecture A review on Linux PM frameworks Last update: December 9, 2010

More information

Last Time. Making correct concurrent programs. Maintaining invariants Avoiding deadlocks

Last Time. Making correct concurrent programs. Maintaining invariants Avoiding deadlocks Last Time Making correct concurrent programs Maintaining invariants Avoiding deadlocks Today Power management Hardware capabilities Software management strategies Power and Energy Review Energy is power

More information

Linux DRM Developer s Guide

Linux DRM Developer s Guide Linux DRM Developer s Guide Linux DRM Developer s Guide Copyright 2008 Intel Corporation (Jesse Barnes ) The contents of this file may be used under the terms of the GNU General

More information

AN116. Power Management Techniques and Calculation. Introduction. Key Points. Power Saving Methods. Reducing System Clock Frequency

AN116. Power Management Techniques and Calculation. Introduction. Key Points. Power Saving Methods. Reducing System Clock Frequency Power Management Techniques and Calculation 1. Relevant Devices This application note applies to the following devices: C8051F000, C8051F001, C8051F002, C8051F005, C8051F006, C8051F010, C8051F011, C8051F012,

More information

Solaris kernel thread stack usage

Solaris kernel thread stack usage Solaris kernel thread stack usage Context: this document proposes to add a new kmem_stackinfo variable to Solaris kernel for a new feature that gives informations about the kernel thread stack usage through

More information

#if ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #include "WConstants.h" #endif #include "Adafruit_Thermal.h"

#if ARDUINO >= 100 #include Arduino.h #else #include WProgram.h #include WConstants.h #endif #include Adafruit_Thermal.h /************************************************************************* This is an Arduino library for the Adafruit Thermal Printer. Pick one up at --> http://www.adafruit.com/products/597 These printers

More information

Use a semaphore to avoid the enqueue and dequeue functions from accessing and modifying count variable at the same time.

Use a semaphore to avoid the enqueue and dequeue functions from accessing and modifying count variable at the same time. Goal: In this project you will create an OS-driven multitasking device than can capture data at precise intervals, buffer the data to EEPROM, and send data over a serial interface to a computer, while

More information

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University ECEN 449 Microprocessor System Design Hardware-Software Communication 1 Objectives of this Lecture Unit Learn basics of Hardware-Software communication Memory Mapped I/O Polling/Interrupts 2 Motivation

More information