SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
Power Management
           from Linux Kernel to Android
                              Matt Hsu & Jim Huang (jserv)
                                      from 0xlab

                                          June 19, 2009




                                                                 1
0xlab – connect your device to application – http://0xlab.org/
Rights to copy
                                                                       © Copyright 2009 0xlab.org
                                                                               contact@0xlab.org
                                                                 Corrections, suggestions, contributions and
                                                                                  translations are welcome!



   Attribution – ShareAlike 3.0
   You are free
      to copy, distribute, display, and perform the work
      to make derivative works
      to make commercial use of the work
   Under the following conditions
         Attribution. You must give the original author credit.
         Share Alike. If you alter, transform, or build upon this work, you may distribute the
         resulting work only under a license identical to this one.
      For any reuse or distribution, you must make clear to others the license terms of this
      work.
      Any of these conditions can be waived if you get permission from the copyright holder.
   Your fair use and other rights are in no way affected by the above.
   License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode
                                                                                                               2
0xlab – connect your device to application – http://0xlab.org/
Agenda

           Introduction to Linux Power Management
           Concepts behind Android Power Management
           Design and Implementation
           Room for Improvements




                                                                 3
0xlab – connect your device to application – http://0xlab.org/
Introduction to Linux Power Management
              Goal of Power Management
              APM vs. ACPI
              APM emulation
              No silver bullet
              Manage power in different power state
              Lighthouse in the sea
        Concepts behind Android Power Management
        Design and Implementation
        Room for Improvements



                                                                 4
0xlab – connect your device to application – http://0xlab.org/
Power Management Basics




     Prolong                                                     Life

                                                                        5
0xlab – connect your device to application – http://0xlab.org/
Advanced Power Management


                      APM-Aware             APM-Aware            APM-Aware       APM-Aware
      Applications
                      Application           Application          Device Driver   Device Driver




      Operating System                 APM Driver                                        OS dependent


                                              APM Interface                              OS independent


      BIOS                             APM BIOS




                                       APM BIOS                   Add-In            Add-In
                                       Controlled                 Device            Device
                                        Hardware


                                                                                                          6
0xlab – connect your device to application – http://0xlab.org/
APM power state

                                                            Full On
    Device                       Off Switch
    Responsiveness                        • APM Enable             • APM Disable
    Decreases                             • Enable Call            • Disable Call
                                 • Off Switch
             POWER               • Off Call
             MANAGED                                  APM Enabled

                                       • Short Inactivity        Resume
                                       • Standby Call            Event

                                                      APM Standby
                                 Off Switch

                                                                   Wakeup
                                                                   Event

                                                      APM Suspend
                                 Off Switch
                                                                       • Long Inactivity
                                                      Hibernation      • Suspend Interrupt
                                                                       • Suspend Call

                                                                            On Switch        Power
                                                             Off                             Usage
                                                                                             Increases

                                                                                                         7
0xlab – connect your device to application – http://0xlab.org/
Advanced Configuration and Power Interface




                                                                 8
0xlab – connect your device to application – http://0xlab.org/
ACPI Power State Transition




                                                                 9
0xlab – connect your device to application – http://0xlab.org/
APM vs. ACPI
     APM
         Control resides in BIOS
         Uses activity timeouts to determine when to power down a device
         BIOS rarely used in embedded systems
         Makes power-management decisions without informing OS or individual
         applications
         No knowledge of add-in cards or new devices (e.g. USB, IEEE 1394)


    ACPI
          Control divided between BIOS and OS
          Decisions managed through the OS
          Enables sophisticated power policies for general-purpose computers with
          standard usage patterns and hardware
          No knowledge of device-specific scenarios (e.g. need to provide predictable
          response times or to respond to critical events over extended period)
                                                                                        10
0xlab – connect your device to application – http://0xlab.org/
APM emulation


                          /dev/apm_bois                          user_pmd




                                                                  pm_prepare
                                                                  pm_enter      mach_pm_ops
                                         kapmd                    pm_finish




               battery_drv                         pmu_drv
                                                                         get_pm_status_drv


                                                                                              11
0xlab – connect your device to application – http://0xlab.org/
No silver bullet
       for building most power-saving
                mobile system.
                                                                 12
0xlab – connect your device to application – http://0xlab.org/
Power State Transition




                                                                 13
0xlab – connect your device to application – http://0xlab.org/
Runtime / Standby

        Application-driven power management
        Micro manage your device
              WiFi -enable PS poll mode
              Switch on/off device by demand (Android's concept)
              Gating off unused device clock
        Keep the flexibility of CPU
              Gating CPU freq dynamically
              Tickless idle
              Using DMA instead PIO




                                                                   14
0xlab – connect your device to application – http://0xlab.org/
Suspend/Sleep Mode

        STR vs STD
              Suspend to RAM
              Suspend to Disk/Hibernate


        STR: A technique by which systems preserve state in RAM
        during suspend and restore system state from RAM upon resume


        STR is suitable for mobile device if hardware supports this
        function




                                                                       15
0xlab – connect your device to application – http://0xlab.org/
Suspend/Resume Control Path


    # echo mem >/sys/power/state                                                   System running



                        Stop tasks
                                                                              Restarting tasks
        pm_registered_dev
          pm_registered_dev
                 |-> bus_suspend
                   |-> bus_suspend                               pm_registered_dev
                        | | → dev_suspend
                          → dev_suspend                                  |-> bus_resume
             | → → bus_suspend
                | bus_suspend                                                  | → dev_resume
                ............
                    ............                                      | → bus_resume
                                                                         ............

                  - keep GPIO state
         - Set SDRAM as self-refresh mode                                - restore GPIO state
               - Request CPU to sleep

                                                                 bootloader
                                                    Suspend
                                                                                                    16
0xlab – connect your device to application – http://0xlab.org/
Practical Example -S3C244x (1)




                                                                 17
0xlab – connect your device to application – http://0xlab.org/
Practical Example -S3C244x (2)




                                                                 18
0xlab – connect your device to application – http://0xlab.org/
A ship on the beach is a lighthouse to the sea

        Provide a kernel module to dump and check GPIOs
        Provide power source as independent as possible
        Don't ignore the poweroff state
        To most difficult part of debugging STR is resuming




                                                                 19
0xlab – connect your device to application – http://0xlab.org/
Introduction to Linux Power Management
           Concepts behind Android Power Management
                Basically, it is the slim wrapper for Linux
                Power Management
           Design and Implementation
           Room for Improvements




                                                                 20
0xlab – connect your device to application – http://0xlab.org/
Where is Power Manager?




    PM?
    PM?


                                                                 21
0xlab – connect your device to application – http://0xlab.org/
In fact, power ghost exists everywhere

           Let “grep -ri power” tell you about the details!
           It is layered into several components, but implementation
           involves in some hacks.
           Check: CONFIG_PM, sysfs, device drivers, libhardware_legacy,
           libril, init.rc, powerd, alarm, vold, JNI, PowerManager,
           BatteryManager, ...




                                                                          22
0xlab – connect your device to application – http://0xlab.org/
Base: Linux Kernel
                                                                              Directory: arch/arm/mach-omap2/
                                                                              Directory: arch/arm/mach-omap2/
                                                                                   board-omap3beagle.c
                                                                                    board-omap3beagle.c
                                                                                   gpmc.c
                                                                                    gpmc.c
                                                                                   pm.[ch]
                                                                                    pm.[ch]




           Android does rely on Linux Kernel 2.6 for core system services
                Memory/Process Management
                Device Driver Model
                sysfs, kobject/uevent, netlink
           Android Kernel extensions
                                                                  Key Idea: Android attempts to provide
                                                                  Key Idea: Android attempts to provide
                Binder                                                an abstraction layer between
                                                                       an abstraction layer between
                android_power                                    hardware and the related software stack.
                                                                 hardware and the related software stack.
                      /sys/android_power/, /sys/power/                                                          23
0xlab – connect your device to application – http://0xlab.org/
Android's PM Concepts

           Android PM is built on top of standard Linux Power Management.
           It can support more aggressive PM, but looks fairly simple now.
           Components make requests to keep the power on through
           “Wake Locks”.
                PM does support several types of “Wake Locks”.




    If there are no active wake locks, CPU will
    be turned off.
    If there is are partial wake locks, screen
    and keyboard will be turned off.
                                                                             24
0xlab – connect your device to application – http://0xlab.org/
25
0xlab – connect your device to application – http://0xlab.org/
Types of Wake Locks
     ACQUIRE_CAUSES_WAKEUP
           Normally wake locks don't actually wake the device, they just cause it to
           remain on once it's already on. Think of the video player app as the normal
           behavior.

     FULL_WAKE_LOCK
           Wake lock that ensures that the screen and keyboard are on at full
           brightness.

     ON_AFTER_RELEASE
           When this wake lock is released, poke the user activity timer so the screen
           stays on for a little longer.

     PARTIAL_WAKE_LOCK
           Wake lock that ensures that the CPU is running. The screen might not be on.

     SCREEN_BRIGHT_WAKE_LOCK
           Wake lock that ensures that the screen is on at full brightness; the keyboard
           backlight will be allowed to go off.

     SCREEN_DIM_WAKE_LOCK
           Wake lock that ensures that the screen is on, but the keyboard backlight will
           be allowed to go off, and the screen backlight will be allowed to go dim.       26
0xlab – connect your device to application – http://0xlab.org/
PM State Machine
            Touchscreen or keyboard user activity
            Touchscreen or keyboard user activity
              event or full wake locks acquired.
              event or full wake locks acquired.




                      All partial wake locks
                      All partial wake locks
                             released
                              released

                                     Partial wake locks acquired
                                     Partial wake locks acquired


                                                                   27
0xlab – connect your device to application – http://0xlab.org/
Introduction to Linux Power Management
           Concepts behind Android Power Management
                Basically, it is the slim wrapper for Linux Power Management

           Design and Implementation
           Room for Improvements




                                                                               28
0xlab – connect your device to application – http://0xlab.org/
Design and Implementation




                                                                 29
0xlab – connect your device to application – http://0xlab.org/
android_os_Power
                                                                frameworks/base/core/jni/android_os_Power.cpp
                                                                frameworks/base/core/jni/android_os_Power.cpp
                          ...
                          ...
                          static JNINativeMethod method_table[] = {
                          static JNINativeMethod method_table[] = {
                              { "acquireWakeLock", "(ILjava/lang/String;)V", (void*)acquireWakeLock },
                              { "acquireWakeLock", "(ILjava/lang/String;)V", (void*)acquireWakeLock },
                              { "releaseWakeLock", "(Ljava/lang/String;)V", (void*)releaseWakeLock },
                              { "releaseWakeLock", "(Ljava/lang/String;)V", (void*)releaseWakeLock },
                              { "setLastUserActivityTimeout", "(J)I", (void*)setLastUserActivityTimeout },
                              { "setLastUserActivityTimeout", "(J)I", (void*)setLastUserActivityTimeout },
                              { "setLightBrightness", "(II)I", (void*)setLightBrightness },
                              { "setLightBrightness", "(II)I", (void*)setLightBrightness },
                              { "setScreenState", "(Z)I", (void*)setScreenState },
                              { "setScreenState", "(Z)I", (void*)setScreenState },
                              { "shutdown", "()V", (void*)android_os_Power_shutdown },
                              { "shutdown", "()V", (void*)android_os_Power_shutdown },
                              { "reboot", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot },
                              { "reboot", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot },
                          };
                          };

                          int register_android_os_Power(JNIEnv *env)
                           int register_android_os_Power(JNIEnv *env)
                          {{
                               return AndroidRuntime::registerNativeMethods(
                               return AndroidRuntime::registerNativeMethods(
                                   env, "android/os/Power",
                                   env, "android/os/Power",
                                   method_table, NELEM(method_table));
                                   method_table, NELEM(method_table));
                          }}


                                                                static void
                                                                static void
                                                                acquireWakeLock(JNIEnv *env, jobject clazz,
                                                                acquireWakeLock(JNIEnv *env, jobject clazz,
                                                                                jint lock, jstring idObj)
                                                                                 jint lock, jstring idObj)
                                                                {
                                                                {
                                                                    if (idObj == NULL) {
                                                                    if (idObj == NULL) {
                                                                        throw_NullPointerException(env, "id is null");
                                                                        throw_NullPointerException(env, "id is null");
                                                                        return ;
                                                                        return ;
                                                                    }
                                                                    }

                                                                     const char *id = env->GetStringUTFChars(idObj, NULL);
                                                                     const char *id = env->GetStringUTFChars(idObj, NULL);

                                                                     acquire_wake_lock(lock, id);
                                                                     acquire_wake_lock(lock, id);

                                                                     env->ReleaseStringUTFChars(idObj, id);
                                                                     env->ReleaseStringUTFChars(idObj, id);              30
                                                                }
0xlab – connect your device to application –   http://0xlab.org/ }
Power
                                                                   hardware/libhardware_legacy/power/power.c
                                                                   hardware/libhardware_legacy/power/power.c
                                                                   ...
                                                                   ...
                                                                   int
                                                                   int
                                                                   acquire_wake_lock(int lock, const char* id)
                                                                   acquire_wake_lock(int lock, const char* id)
                                                                   {
                                                                   {
                                                                       initialize_fds();
                                                                       initialize_fds();
const char * const OLD_PATHS[] = {
const char * const OLD_PATHS[] = {                                     if (g_error) return g_error;
                                                                       if (g_error) return g_error;
    "/sys/android_power/acquire_partial_wake_lock",
    "/sys/android_power/acquire_partial_wake_lock",
    "/sys/android_power/release_wake_lock",
    "/sys/android_power/release_wake_lock",                            int fd;
                                                                       int fd;
    "/sys/android_power/request_state"
    "/sys/android_power/request_state"                                 if (lock == PARTIAL_WAKE_LOCK) {
                                                                       if (lock == PARTIAL_WAKE_LOCK) {
};
};                                                                         fd = g_fds[ACQUIRE_PARTIAL_WAKE_LOCK];
                                                                           fd = g_fds[ACQUIRE_PARTIAL_WAKE_LOCK];
                                                                       }
                                                                       }
const char * const NEW_PATHS[] = {
const char * const NEW_PATHS[] = {                                     else {
                                                                       else {
    "/sys/power/wake_lock",
    "/sys/power/wake_lock",                                                return EINVAL;
                                                                           return EINVAL;
    "/sys/power/wake_unlock",
    "/sys/power/wake_unlock",                                          }
                                                                       }
    "/sys/power/state"
    "/sys/power/state"                                                 return write(fd, id, strlen(id));
                                                                       return write(fd, id, strlen(id));
};
};                                                                 }
                                                                   }
        (Kernel interface changes in Android Cupcake)
        (Kernel interface changes in Android Cupcake)



                                                                 static inline void
                                                                 static inline void
                                                                 initialize_fds(void)
                                                                 initialize_fds(void)
                                                                 {
                                                                 {
                                                                     if (g_initialized == 0) {
                                                                     if (g_initialized == 0) {
                                                                         if(open_file_descriptors(NEW_PATHS) < 0) {
                                                                         if(open_file_descriptors(NEW_PATHS) < 0) {
                                                                             open_file_descriptors(OLD_PATHS);
                                                                             open_file_descriptors(OLD_PATHS);
                                                                             on_state = "wake";
                                                                             on_state = "wake";
                                                                             off_state = "standby";
                                                                             off_state = "standby";
                                                                         }
                                                                         }
                                                                         g_initialized = 1;
                                                                         g_initialized = 1;
                                                                     }
                                                                     }
                                                                 }
                                                                 }                                                31
0xlab – connect your device to application – http://0xlab.org/
Android PM Kernel APIs
    Source code (Cupcake, linux-2.6.27)
         kernel/kernel/power/userwake.c
         kernel/kernel/power/wakelock.c                    static long has_wake_lock_locked(int type)
                                                           static long has_wake_lock_locked(int type)
                                                           {
                                                           {
static int power_suspend_late(
static int power_suspend_late(                                  struct wake_lock *lock, *n;
                                                                struct wake_lock *lock, *n;
     struct platform_device *pdev,
     struct platform_device *pdev,                              long max_timeout = 0;
                                                                long max_timeout = 0;
     pm_message_t state)
     pm_message_t state)                                        BUG_ON(type >= WAKE_LOCK_TYPE_COUNT);
                                                                BUG_ON(type >= WAKE_LOCK_TYPE_COUNT);
{
{                                                               list_for_each_entry_safe(lock, n,
                                                                list_for_each_entry_safe(lock, n,
     int ret =
     int ret =                                                            &active_wake_locks[type], link) {
                                                                          &active_wake_locks[type], link) {
          has_wake_lock(WAKE_LOCK_SUSPEND) ?
          has_wake_lock(WAKE_LOCK_SUSPEND) ?                         if (lock->flags & WAKE_LOCK_AUTO_EXPIRE) {
                                                                     if (lock->flags & WAKE_LOCK_AUTO_EXPIRE) {
          -EAGAIN : 0;
          -EAGAIN : 0;                                                    long timeout = lock->expires - jiffies;
                                                                          long timeout = lock->expires - jiffies;
     return ret;
     return ret;                                                          if (timeout <= 0)
                                                                          if (timeout <= 0)
}
}                                                                              expire_wake_lock(lock);
                                                                               expire_wake_lock(lock);
                                                                          else if (timeout > max_timeout)
                                                                          else if (timeout > max_timeout)
static struct platform_driver power_driver = {
static struct platform_driver power_driver = {                                 max_timeout = timeout;
                                                                               max_timeout = timeout;
     .driver.name = "power",
     .driver.name = "power",                                         } else
                                                                     } else
     .suspend_late = power_suspend_late,
     .suspend_late = power_suspend_late,                                  return -1;
                                                                          return -1;
};
};                                                              }
                                                                }
static struct platform_device power_device = {
static struct platform_device power_device = {                  return max_timeout;
                                                                return max_timeout;
     .name = "power",
     .name = "power",                                      }
                                                           }
};
};
                                                           long has_wake_lock(int type)
                                                           long has_wake_lock(int type)
                                                           {
                                                           {
                                                                long ret;
                                                                long ret;
                                                                unsigned long irqflags;
                                                                unsigned long irqflags;
                                                                spin_lock_irqsave(&list_lock, irqflags);
                                                                spin_lock_irqsave(&list_lock, irqflags);
                                                                ret = has_wake_lock_locked(type);
                                                                ret = has_wake_lock_locked(type);
                                                                spin_unlock_irqrestore(&list_lock, irqflags);
                                                                spin_unlock_irqrestore(&list_lock, irqflags);
                                                                return ret;
                                                                return ret;
                                                           }
                                                           }                                                    32
0xlab – connect your device to application – http://0xlab.org/
Android PM Kernel APIs
    kernel/kernel/power/wakelock.c


                                   static int __init wakelocks_init(void)
                                   static int __init wakelocks_init(void)
                                   {
                                   {
                                        int ret;
                                        int ret;
                                        int i;
                                        int i;

                                        for (i = 0; i < ARRAY_SIZE(active_wake_locks); i++)
                                        for (i = 0; i < ARRAY_SIZE(active_wake_locks); i++)
                                             INIT_LIST_HEAD(&active_wake_locks[i]);
                                             INIT_LIST_HEAD(&active_wake_locks[i]);


                                        wake_lock_init(&main_wake_lock, WAKE_LOCK_SUSPEND, "main");
                                        wake_lock_init(&main_wake_lock, WAKE_LOCK_SUSPEND, "main");
                                        wake_lock(&main_wake_lock);
                                        wake_lock(&main_wake_lock);
                                        wake_lock_init(&unknown_wakeup, WAKE_LOCK_SUSPEND, "unknown_wakeups");
                                        wake_lock_init(&unknown_wakeup, WAKE_LOCK_SUSPEND, "unknown_wakeups");

                                        ret = platform_device_register(&power_device);
                                        ret = platform_device_register(&power_device);
                                        if (ret) {
                                        if (ret) {
                                             pr_err("wakelocks_init: platform_device_register
                                             pr_err("wakelocks_init: platform_device_register   failedn");
                                                                                                failedn");
                                             goto err_platform_device_register;
                                             goto err_platform_device_register;
                                        }
                                        }
                                        ret = platform_driver_register(&power_driver);
                                        ret = platform_driver_register(&power_driver);
                                        if (ret) {
                                        if (ret) {
                                             pr_err("wakelocks_init: platform_driver_register
                                             pr_err("wakelocks_init: platform_driver_register   failedn");
                                                                                                failedn");
                                             goto err_platform_driver_register;
                                             goto err_platform_driver_register;
                                        }
                                        }

                                        suspend_work_queue = create_singlethread_workqueue("suspend");
                                        suspend_work_queue = create_singlethread_workqueue("suspend");
                                        if (suspend_work_queue == NULL) {
                                        if (suspend_work_queue == NULL) {
                                             ret = -ENOMEM;
                                             ret = -ENOMEM;
                                             goto err_suspend_work_queue;
                                             goto err_suspend_work_queue;
                                        }
                                        }                                                                     33
0xlab – connect your device to application – http://0xlab.org/
Back to userspace

           Use “grep -r acquire_wake_lock” to discover.
                frameworks/base/libs/ui/EventHub.cpp
                      EventHub::EventHub(), EventHub::~EventHub(),
                      EventHub::getEvent()
                hardware/ril/libril/ril.cpp
                      RIL_onUnsolicitedResponse(),
                system/wlan/ti/sta_dk_4_0_4_32/CUDK/tiwlan_loader/tiwlan_loader.c
                      start_cli()




                                                                                    34
0xlab – connect your device to application – http://0xlab.org/
Back to userspace

           Use “grep -ri power” to discover.
                base/core/jni/android_net_wifi_Wifi.cpp
                       android.net.wifi.WifiNative.setPowerModeCommand
                      (android_net_wifi_setPowerModeCommand)
                base/core/java/com/android/internal/os/BatteryStats.java
                base/core/java/com/android/internal/os/BatteryStatsImpl.java
                base/core/java/com/android/os/PowerManager.java
                base/core/java/com/android/os/LocalPowerManager.java
                base/core/java/com/android/os/Power.java
                base/core/java/com/android/app/ApplicationContext.java
                base/core/java/android/bluetooth/ScoSocket.java
                base/core/java/android/bluetooth/HeadsetBase.java
                base/core/media/java/android/media/MediaPlayer.java
                base/core/media/java/android/media/AsyncPlayer.java
                                                                               35
0xlab – connect your device to application – http://0xlab.org/
Back to userspace

           Use “grep -ri power” to discover.
                base/telephony/java/com/android/internal/telephony/gsm/GSMConnection.
                java
                base/telephony/java/com/android/internal/telephony/gsm/RIL.java
                base/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
                base/services/jni/com_android_server_BatteryService.cpp
                base/services/java/com/android/server/am/ActivityManagerService.java
                base/services/java/com/android/server/SystemServer.java
                base/services/java/com/android/server/BatteryService.java
                base/services/java/com/android/server/AlarmManagerService.java
                base/services/java/com/android/server/LocationManagerService.java
                base/services/java/com/android/server/HardwareService.java
                base/services/java/com/android/server/PowerManagerService.java

                                                                                       36
0xlab – connect your device to application – http://0xlab.org/
Back to userspace

           Use “grep -ri power” to discover.
                system/core/toolbox/powerd.c
                system/core/toolbox/alarm.c
                system/core/vold/mmc.c
                system/core/vold/uevent.c




                                                                 37
0xlab – connect your device to application – http://0xlab.org/
Introduction to Linux Power Management
           Concepts behind Android Power Management
                Basically, it is the slim wrapper for Linux Power Management
           Design and Implementation
           Room for Improvements




                                                                               38
0xlab – connect your device to application – http://0xlab.org/
So, Android PM is simple

           Key concept is “Wake Locks”, which is simple and portable.
           The implementation should be introspected.




       If there are no active wake locks, CPU will be turned
       off.
       If there is are partial wake locks, screen and
       keyboard will be turned off.




           Nowadays, CPU can enter into more states for power saving and
           usability purpose! → applied in modern SoC
                                                                        39
0xlab – connect your device to application – http://0xlab.org/
Interface to Physical World

                                                                 Analog
      The Real                Signal                             Signal
                              Conditioning                       Conversion
      World
                                                                 to Digital
     Temperature

     Pressure

     Position

     Speed
                                             Power                            Digital Signal Processor
     Flow
                                             Management
     Humidity

     Sound

     Light
                                                                 Digital
                                         Signal
                                                                 Signal
                                   Conditioning                                        Interface
                                                                 Conversion
                                                                 to Analog
                                                                               Clocks & Timers
                                                                                                         40
0xlab – connect your device to application – http://0xlab.org/
Advanced Power Management
    Power management aims to improve battery life of equipment by
      minimizing power consumption while guaranteeing expected system
      performance

    Active power consumption occurs while some processing is on-going
         Dynamic power consumption (transistor switching) + Leakage
         consumption

    Static (also Standby or Idle) power consumption occurs when
      limited or no processing is on-going and the system is waiting for a
      wakeup event
         Very limited dynamic power consumption + Leakage consumption
         Managed by
            Dynamic Voltage & Frequency Scaling (DVFS)
            Adaptive Voltage Scaling (AVS)
            Dynamic Power Switching (DPS)

                 On OMAP35xx, power management is handled by the
                 On OMAP35xx, power management is handled by the
                 Power, Reset and Clock Management (PRCM) module
                 Power, Reset and Clock Management (PRCM) module
                                                                         41
0xlab – connect your device to application – http://0xlab.org/
Adaptive Voltage Scaling

     Silicon manufacturing process yields a distribution of performance
     capability
     For a given frequency requirement:
           Devices on hot/strong/fast end of distribution can meet this at a lower voltage
           Devices on cold/weak/slow end of distribution need higher voltage

     Simple system will set the higher voltage for operating all devices
     Smarter system will adapt operating voltage per device.




                                            hotter device
                                            hotter device


                                                                                             42
0xlab – connect your device to application – http://0xlab.org/
Power Block Diagram


              VDD1 DCDC                                          MPU IVA
                                  VDD2 DCDC
                                                                                      OMAP3530
                                                                 CORE
              VRTC
                                  VIO DCDC
                                                                 IOs Memory Display
                                                                 Wake-Up domains
              USB CP
                                  VDAC                           Video DAC


              USB PHY
                                  VPLL                           PLL


                                                                 VPP or
              VAUX
                                                                 Camera IF
                                  VMMC

                                                                 MMC1
                       TPS659xx
                                                                                                 43
0xlab – connect your device to application – http://0xlab.org/
Reference Software Architecture


               Applications



            GUI

            App Framework

            2D/3D APIs             Multimedia              Optional
                                   Framework               DRM

            GFX Driver
                                   Codec Engine and Link
                                                                      Codec Engine   FC      BIOS
            Linux Kernel / WinCE
                                           audio   video    image
            & Power Management                                        video image audio   video image audio


 GFX        ARM                                                       C64x+ DSP and Video Acceleration




                                                                                                              44
0xlab – connect your device to application – http://0xlab.org/
Linux PM Mechanisms

           cpuidle
                Generic framework for supporting software-controlled
                idle processor power management
                Hardware specific drivers
                Various governing for the state transition decisions


           Latency and power management
                Framework for expressing latency constraints, and make sure
                that they are taken into account for power management
                decisions


           Needs to be integrated into Android Partial Wake Locks
                                                                          45
0xlab – connect your device to application – http://0xlab.org/
Summary



         Integration is the key to the most
         power-saving system




                                                                 46
0xlab – connect your device to application – http://0xlab.org/
Reference

        PDK :: Android – Power Management
              http://www.netmite.com/android/mydroid/development/pdk/docs/power_ma
              nagement.html
        Android Cupcake source code
              http://www.netmite.com/android/mydroid/cupcake/
        BeagleBoard and its Linux support
              http://elinux.org/BeagleBoard
        class PowerManager
              http://developer.android.com/reference/android/os/PowerManager.html
        Free-Electrons
              http://free-electrons.com/training
        CELF's power management specification
              http://elinux.org/Power_Management
                                                                                     47
0xlab – connect your device to application – http://0xlab.org/

Weitere ähnliche Inhalte

Was ist angesagt?

Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveBin Chen
 
Kernel Features for Reducing Power Consumption on Embedded Devices
Kernel Features for Reducing Power Consumption on Embedded DevicesKernel Features for Reducing Power Consumption on Embedded Devices
Kernel Features for Reducing Power Consumption on Embedded DevicesRyo Jin
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Opersys inc.
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modulesdibyajyotig
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Android Automotive
Android AutomotiveAndroid Automotive
Android AutomotiveOpersys inc.
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingTushar B Kute
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Linux power management: are you doing it right?
Linux power management: are you doing it right?Linux power management: are you doing it right?
Linux power management: are you doing it right?Chris Simmonds
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 

Was ist angesagt? (20)

Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
Kernel Features for Reducing Power Consumption on Embedded Devices
Kernel Features for Reducing Power Consumption on Embedded DevicesKernel Features for Reducing Power Consumption on Embedded Devices
Kernel Features for Reducing Power Consumption on Embedded Devices
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Linux power management: are you doing it right?
Linux power management: are you doing it right?Linux power management: are you doing it right?
Linux power management: are you doing it right?
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Android 10
Android 10Android 10
Android 10
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 

Ähnlich wie Power Management from Linux Kernel to Android

SAPSM Ubicomp 2012
SAPSM Ubicomp 2012SAPSM Ubicomp 2012
SAPSM Ubicomp 2012Qi Xin
 
SpiceWorld London 2012 presentation Eaton
SpiceWorld London 2012 presentation EatonSpiceWorld London 2012 presentation Eaton
SpiceWorld London 2012 presentation EatonSpiceworks
 
SpiceWorld London 2012 Presentation Matthieu Jaeger
SpiceWorld London 2012 Presentation Matthieu JaegerSpiceWorld London 2012 Presentation Matthieu Jaeger
SpiceWorld London 2012 Presentation Matthieu JaegerSpiceworks
 
One millions users vs your web application mega testing cloud applications pr...
One millions users vs your web application mega testing cloud applications pr...One millions users vs your web application mega testing cloud applications pr...
One millions users vs your web application mega testing cloud applications pr...Justin Dorfman
 
Ip power stone data sheet 8 20-09
Ip power stone data sheet 8 20-09Ip power stone data sheet 8 20-09
Ip power stone data sheet 8 20-09Multi-Link, Inc.
 
Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...
Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...
Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...Alcatel-Lucent Cloud
 
Introduction to Cloud Data Center and Network Issues
Introduction to Cloud Data Center and Network IssuesIntroduction to Cloud Data Center and Network Issues
Introduction to Cloud Data Center and Network IssuesJason TC HOU (侯宗成)
 
Presentation exploit power vm features to maximize performance &amp; effici...
Presentation   exploit power vm features to maximize performance &amp; effici...Presentation   exploit power vm features to maximize performance &amp; effici...
Presentation exploit power vm features to maximize performance &amp; effici...solarisyougood
 
Modernize your Solaris Apps
Modernize your Solaris AppsModernize your Solaris Apps
Modernize your Solaris AppsAppZero
 
Subversion Edge Overview
Subversion Edge OverviewSubversion Edge Overview
Subversion Edge OverviewLotharSchubert
 
Apc series product overview may 2012
Apc series product overview may 2012Apc series product overview may 2012
Apc series product overview may 2012pacificnet
 
Apc series product overview may 2012
Apc series product overview may 2012Apc series product overview may 2012
Apc series product overview may 2012jdlizarraga
 
Using Storage Manager 5.1 to Manage and Optimize your Environment
Using Storage Manager 5.1 to Manage and Optimize your Environment Using Storage Manager 5.1 to Manage and Optimize your Environment
Using Storage Manager 5.1 to Manage and Optimize your Environment SolarWinds
 
Transcending Computing Environment Boundaries: Seamless Computing Environmen...
Transcending  Computing Environment Boundaries: Seamless Computing Environmen...Transcending  Computing Environment Boundaries: Seamless Computing Environmen...
Transcending Computing Environment Boundaries: Seamless Computing Environmen...HCL Infosystems
 
Improving Application Availability on Virtual Machines
Improving Application Availability on Virtual MachinesImproving Application Availability on Virtual Machines
Improving Application Availability on Virtual MachinesNeverfail Group
 
Linux Power Management Slideshare
Linux Power Management SlideshareLinux Power Management Slideshare
Linux Power Management SlidesharePatrick Bellasi
 
DataCore Software - The one and only Storage Hypervisor
DataCore Software - The one and only Storage HypervisorDataCore Software - The one and only Storage Hypervisor
DataCore Software - The one and only Storage HypervisorASBIS SK
 
CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012
CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012
CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012Amazon Web Services
 

Ähnlich wie Power Management from Linux Kernel to Android (20)

SAPSM Ubicomp 2012
SAPSM Ubicomp 2012SAPSM Ubicomp 2012
SAPSM Ubicomp 2012
 
SpiceWorld London 2012 presentation Eaton
SpiceWorld London 2012 presentation EatonSpiceWorld London 2012 presentation Eaton
SpiceWorld London 2012 presentation Eaton
 
SpiceWorld London 2012 Presentation Matthieu Jaeger
SpiceWorld London 2012 Presentation Matthieu JaegerSpiceWorld London 2012 Presentation Matthieu Jaeger
SpiceWorld London 2012 Presentation Matthieu Jaeger
 
The Guardian
The GuardianThe Guardian
The Guardian
 
One millions users vs your web application mega testing cloud applications pr...
One millions users vs your web application mega testing cloud applications pr...One millions users vs your web application mega testing cloud applications pr...
One millions users vs your web application mega testing cloud applications pr...
 
Ip power stone data sheet 8 20-09
Ip power stone data sheet 8 20-09Ip power stone data sheet 8 20-09
Ip power stone data sheet 8 20-09
 
Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...
Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...
Alcatel-Lucent Cloud: Network Functions Virtualization - The New Virtual Real...
 
Introduction to Cloud Data Center and Network Issues
Introduction to Cloud Data Center and Network IssuesIntroduction to Cloud Data Center and Network Issues
Introduction to Cloud Data Center and Network Issues
 
Presentation exploit power vm features to maximize performance &amp; effici...
Presentation   exploit power vm features to maximize performance &amp; effici...Presentation   exploit power vm features to maximize performance &amp; effici...
Presentation exploit power vm features to maximize performance &amp; effici...
 
Modernize your Solaris Apps
Modernize your Solaris AppsModernize your Solaris Apps
Modernize your Solaris Apps
 
Subversion Edge Overview
Subversion Edge OverviewSubversion Edge Overview
Subversion Edge Overview
 
Apc series product overview may 2012
Apc series product overview may 2012Apc series product overview may 2012
Apc series product overview may 2012
 
Apc series product overview may 2012
Apc series product overview may 2012Apc series product overview may 2012
Apc series product overview may 2012
 
Using Storage Manager 5.1 to Manage and Optimize your Environment
Using Storage Manager 5.1 to Manage and Optimize your Environment Using Storage Manager 5.1 to Manage and Optimize your Environment
Using Storage Manager 5.1 to Manage and Optimize your Environment
 
Transcending Computing Environment Boundaries: Seamless Computing Environmen...
Transcending  Computing Environment Boundaries: Seamless Computing Environmen...Transcending  Computing Environment Boundaries: Seamless Computing Environmen...
Transcending Computing Environment Boundaries: Seamless Computing Environmen...
 
Improving Application Availability on Virtual Machines
Improving Application Availability on Virtual MachinesImproving Application Availability on Virtual Machines
Improving Application Availability on Virtual Machines
 
Linux Power Management Slideshare
Linux Power Management SlideshareLinux Power Management Slideshare
Linux Power Management Slideshare
 
PowerHA for i
PowerHA for iPowerHA for i
PowerHA for i
 
DataCore Software - The one and only Storage Hypervisor
DataCore Software - The one and only Storage HypervisorDataCore Software - The one and only Storage Hypervisor
DataCore Software - The one and only Storage Hypervisor
 
CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012
CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012
CPN208 Failures at Scale & How to Ride Through Them - AWS re: Invent 2012
 

Mehr von National Cheng Kung University

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimeNational Cheng Kung University
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明National Cheng Kung University
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明National Cheng Kung University
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明National Cheng Kung University
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsNational Cheng Kung University
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationNational Cheng Kung University
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學National Cheng Kung University
 

Mehr von National Cheng Kung University (20)

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtimePyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoTConstruct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
 
從線上售票看作業系統設計議題
從線上售票看作業系統設計議題從線上售票看作業系統設計議題
從線上售票看作業系統設計議題
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisorXvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Implement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVMImplement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVM
 
Priority Inversion on Mars
Priority Inversion on MarsPriority Inversion on Mars
Priority Inversion on Mars
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and ImplementationLecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
 

Kürzlich hochgeladen

Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...AlexisTorres963861
 
28042024_First India Newspaper Jaipur.pdf
28042024_First India Newspaper Jaipur.pdf28042024_First India Newspaper Jaipur.pdf
28042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover BackVerified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover BackPsychicRuben LoveSpells
 
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's DevelopmentNara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Developmentnarsireddynannuri1
 
Gujarat-SEBCs.pdf pfpkoopapriorjfperjreie
Gujarat-SEBCs.pdf pfpkoopapriorjfperjreieGujarat-SEBCs.pdf pfpkoopapriorjfperjreie
Gujarat-SEBCs.pdf pfpkoopapriorjfperjreiebhavenpr
 
Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...
Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...
Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...Pooja Nehwal
 
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s LeadershipTDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadershipanjanibaddipudi1
 
Minto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptxMinto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptxAwaiskhalid96
 
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
1971 war india pakistan bangladesh liberation.ppt
1971 war india pakistan bangladesh liberation.ppt1971 war india pakistan bangladesh liberation.ppt
1971 war india pakistan bangladesh liberation.pptsammehtumblr
 
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Embed-4.pdf lkdiinlajeklhndklheduhuekjdh
Embed-4.pdf lkdiinlajeklhndklheduhuekjdhEmbed-4.pdf lkdiinlajeklhndklheduhuekjdh
Embed-4.pdf lkdiinlajeklhndklheduhuekjdhbhavenpr
 
BDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxLorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxlorenzodemidio01
 
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...Axel Bruns
 
Kishan Reddy Report To People (2019-24).pdf
Kishan Reddy Report To People (2019-24).pdfKishan Reddy Report To People (2019-24).pdf
Kishan Reddy Report To People (2019-24).pdfKISHAN REDDY OFFICE
 
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...Diya Sharma
 

Kürzlich hochgeladen (20)

Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
Defensa de JOH insiste que testimonio de analista de la DEA es falso y solici...
 
28042024_First India Newspaper Jaipur.pdf
28042024_First India Newspaper Jaipur.pdf28042024_First India Newspaper Jaipur.pdf
28042024_First India Newspaper Jaipur.pdf
 
30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf
 
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover BackVerified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
Verified Love Spells in Little Rock, AR (310) 882-6330 Get My Ex-Lover Back
 
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's DevelopmentNara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
Nara Chandrababu Naidu's Visionary Policies For Andhra Pradesh's Development
 
Gujarat-SEBCs.pdf pfpkoopapriorjfperjreie
Gujarat-SEBCs.pdf pfpkoopapriorjfperjreieGujarat-SEBCs.pdf pfpkoopapriorjfperjreie
Gujarat-SEBCs.pdf pfpkoopapriorjfperjreie
 
Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...
Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...
Call Girls in Mira Road Mumbai ( Neha 09892124323 ) College Escorts Service i...
 
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
 
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
 
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s LeadershipTDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
 
Minto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptxMinto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptx
 
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 143 Noida Escorts >༒8448380779 Escort Service
 
1971 war india pakistan bangladesh liberation.ppt
1971 war india pakistan bangladesh liberation.ppt1971 war india pakistan bangladesh liberation.ppt
1971 war india pakistan bangladesh liberation.ppt
 
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
 
Embed-4.pdf lkdiinlajeklhndklheduhuekjdh
Embed-4.pdf lkdiinlajeklhndklheduhuekjdhEmbed-4.pdf lkdiinlajeklhndklheduhuekjdh
Embed-4.pdf lkdiinlajeklhndklheduhuekjdh
 
BDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Greater Noida Escorts >༒8448380779 Escort Service
 
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxLorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
 
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
 
Kishan Reddy Report To People (2019-24).pdf
Kishan Reddy Report To People (2019-24).pdfKishan Reddy Report To People (2019-24).pdf
Kishan Reddy Report To People (2019-24).pdf
 
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
₹5.5k {Cash Payment} Independent Greater Noida Call Girls In [Delhi INAYA] 🔝|...
 

Power Management from Linux Kernel to Android

  • 1. Power Management from Linux Kernel to Android Matt Hsu & Jim Huang (jserv) from 0xlab June 19, 2009 1 0xlab – connect your device to application – http://0xlab.org/
  • 2. Rights to copy © Copyright 2009 0xlab.org contact@0xlab.org Corrections, suggestions, contributions and translations are welcome! Attribution – ShareAlike 3.0 You are free to copy, distribute, display, and perform the work to make derivative works to make commercial use of the work Under the following conditions Attribution. You must give the original author credit. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode 2 0xlab – connect your device to application – http://0xlab.org/
  • 3. Agenda Introduction to Linux Power Management Concepts behind Android Power Management Design and Implementation Room for Improvements 3 0xlab – connect your device to application – http://0xlab.org/
  • 4. Introduction to Linux Power Management Goal of Power Management APM vs. ACPI APM emulation No silver bullet Manage power in different power state Lighthouse in the sea Concepts behind Android Power Management Design and Implementation Room for Improvements 4 0xlab – connect your device to application – http://0xlab.org/
  • 5. Power Management Basics Prolong Life 5 0xlab – connect your device to application – http://0xlab.org/
  • 6. Advanced Power Management APM-Aware APM-Aware APM-Aware APM-Aware Applications Application Application Device Driver Device Driver Operating System APM Driver OS dependent APM Interface OS independent BIOS APM BIOS APM BIOS Add-In Add-In Controlled Device Device Hardware 6 0xlab – connect your device to application – http://0xlab.org/
  • 7. APM power state Full On Device Off Switch Responsiveness • APM Enable • APM Disable Decreases • Enable Call • Disable Call • Off Switch POWER • Off Call MANAGED APM Enabled • Short Inactivity Resume • Standby Call Event APM Standby Off Switch Wakeup Event APM Suspend Off Switch • Long Inactivity Hibernation • Suspend Interrupt • Suspend Call On Switch Power Off Usage Increases 7 0xlab – connect your device to application – http://0xlab.org/
  • 8. Advanced Configuration and Power Interface 8 0xlab – connect your device to application – http://0xlab.org/
  • 9. ACPI Power State Transition 9 0xlab – connect your device to application – http://0xlab.org/
  • 10. APM vs. ACPI APM Control resides in BIOS Uses activity timeouts to determine when to power down a device BIOS rarely used in embedded systems Makes power-management decisions without informing OS or individual applications No knowledge of add-in cards or new devices (e.g. USB, IEEE 1394) ACPI Control divided between BIOS and OS Decisions managed through the OS Enables sophisticated power policies for general-purpose computers with standard usage patterns and hardware No knowledge of device-specific scenarios (e.g. need to provide predictable response times or to respond to critical events over extended period) 10 0xlab – connect your device to application – http://0xlab.org/
  • 11. APM emulation /dev/apm_bois user_pmd pm_prepare pm_enter mach_pm_ops kapmd pm_finish battery_drv pmu_drv get_pm_status_drv 11 0xlab – connect your device to application – http://0xlab.org/
  • 12. No silver bullet for building most power-saving mobile system. 12 0xlab – connect your device to application – http://0xlab.org/
  • 13. Power State Transition 13 0xlab – connect your device to application – http://0xlab.org/
  • 14. Runtime / Standby Application-driven power management Micro manage your device WiFi -enable PS poll mode Switch on/off device by demand (Android's concept) Gating off unused device clock Keep the flexibility of CPU Gating CPU freq dynamically Tickless idle Using DMA instead PIO 14 0xlab – connect your device to application – http://0xlab.org/
  • 15. Suspend/Sleep Mode STR vs STD Suspend to RAM Suspend to Disk/Hibernate STR: A technique by which systems preserve state in RAM during suspend and restore system state from RAM upon resume STR is suitable for mobile device if hardware supports this function 15 0xlab – connect your device to application – http://0xlab.org/
  • 16. Suspend/Resume Control Path # echo mem >/sys/power/state System running Stop tasks Restarting tasks pm_registered_dev pm_registered_dev |-> bus_suspend |-> bus_suspend pm_registered_dev | | → dev_suspend → dev_suspend |-> bus_resume | → → bus_suspend | bus_suspend | → dev_resume ............ ............ | → bus_resume ............ - keep GPIO state - Set SDRAM as self-refresh mode - restore GPIO state - Request CPU to sleep bootloader Suspend 16 0xlab – connect your device to application – http://0xlab.org/
  • 17. Practical Example -S3C244x (1) 17 0xlab – connect your device to application – http://0xlab.org/
  • 18. Practical Example -S3C244x (2) 18 0xlab – connect your device to application – http://0xlab.org/
  • 19. A ship on the beach is a lighthouse to the sea Provide a kernel module to dump and check GPIOs Provide power source as independent as possible Don't ignore the poweroff state To most difficult part of debugging STR is resuming 19 0xlab – connect your device to application – http://0xlab.org/
  • 20. Introduction to Linux Power Management Concepts behind Android Power Management Basically, it is the slim wrapper for Linux Power Management Design and Implementation Room for Improvements 20 0xlab – connect your device to application – http://0xlab.org/
  • 21. Where is Power Manager? PM? PM? 21 0xlab – connect your device to application – http://0xlab.org/
  • 22. In fact, power ghost exists everywhere Let “grep -ri power” tell you about the details! It is layered into several components, but implementation involves in some hacks. Check: CONFIG_PM, sysfs, device drivers, libhardware_legacy, libril, init.rc, powerd, alarm, vold, JNI, PowerManager, BatteryManager, ... 22 0xlab – connect your device to application – http://0xlab.org/
  • 23. Base: Linux Kernel Directory: arch/arm/mach-omap2/ Directory: arch/arm/mach-omap2/ board-omap3beagle.c board-omap3beagle.c gpmc.c gpmc.c pm.[ch] pm.[ch] Android does rely on Linux Kernel 2.6 for core system services Memory/Process Management Device Driver Model sysfs, kobject/uevent, netlink Android Kernel extensions Key Idea: Android attempts to provide Key Idea: Android attempts to provide Binder an abstraction layer between an abstraction layer between android_power hardware and the related software stack. hardware and the related software stack. /sys/android_power/, /sys/power/ 23 0xlab – connect your device to application – http://0xlab.org/
  • 24. Android's PM Concepts Android PM is built on top of standard Linux Power Management. It can support more aggressive PM, but looks fairly simple now. Components make requests to keep the power on through “Wake Locks”. PM does support several types of “Wake Locks”. If there are no active wake locks, CPU will be turned off. If there is are partial wake locks, screen and keyboard will be turned off. 24 0xlab – connect your device to application – http://0xlab.org/
  • 25. 25 0xlab – connect your device to application – http://0xlab.org/
  • 26. Types of Wake Locks ACQUIRE_CAUSES_WAKEUP Normally wake locks don't actually wake the device, they just cause it to remain on once it's already on. Think of the video player app as the normal behavior. FULL_WAKE_LOCK Wake lock that ensures that the screen and keyboard are on at full brightness. ON_AFTER_RELEASE When this wake lock is released, poke the user activity timer so the screen stays on for a little longer. PARTIAL_WAKE_LOCK Wake lock that ensures that the CPU is running. The screen might not be on. SCREEN_BRIGHT_WAKE_LOCK Wake lock that ensures that the screen is on at full brightness; the keyboard backlight will be allowed to go off. SCREEN_DIM_WAKE_LOCK Wake lock that ensures that the screen is on, but the keyboard backlight will be allowed to go off, and the screen backlight will be allowed to go dim. 26 0xlab – connect your device to application – http://0xlab.org/
  • 27. PM State Machine Touchscreen or keyboard user activity Touchscreen or keyboard user activity event or full wake locks acquired. event or full wake locks acquired. All partial wake locks All partial wake locks released released Partial wake locks acquired Partial wake locks acquired 27 0xlab – connect your device to application – http://0xlab.org/
  • 28. Introduction to Linux Power Management Concepts behind Android Power Management Basically, it is the slim wrapper for Linux Power Management Design and Implementation Room for Improvements 28 0xlab – connect your device to application – http://0xlab.org/
  • 29. Design and Implementation 29 0xlab – connect your device to application – http://0xlab.org/
  • 30. android_os_Power frameworks/base/core/jni/android_os_Power.cpp frameworks/base/core/jni/android_os_Power.cpp ... ... static JNINativeMethod method_table[] = { static JNINativeMethod method_table[] = { { "acquireWakeLock", "(ILjava/lang/String;)V", (void*)acquireWakeLock }, { "acquireWakeLock", "(ILjava/lang/String;)V", (void*)acquireWakeLock }, { "releaseWakeLock", "(Ljava/lang/String;)V", (void*)releaseWakeLock }, { "releaseWakeLock", "(Ljava/lang/String;)V", (void*)releaseWakeLock }, { "setLastUserActivityTimeout", "(J)I", (void*)setLastUserActivityTimeout }, { "setLastUserActivityTimeout", "(J)I", (void*)setLastUserActivityTimeout }, { "setLightBrightness", "(II)I", (void*)setLightBrightness }, { "setLightBrightness", "(II)I", (void*)setLightBrightness }, { "setScreenState", "(Z)I", (void*)setScreenState }, { "setScreenState", "(Z)I", (void*)setScreenState }, { "shutdown", "()V", (void*)android_os_Power_shutdown }, { "shutdown", "()V", (void*)android_os_Power_shutdown }, { "reboot", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot }, { "reboot", "(Ljava/lang/String;)V", (void*)android_os_Power_reboot }, }; }; int register_android_os_Power(JNIEnv *env) int register_android_os_Power(JNIEnv *env) {{ return AndroidRuntime::registerNativeMethods( return AndroidRuntime::registerNativeMethods( env, "android/os/Power", env, "android/os/Power", method_table, NELEM(method_table)); method_table, NELEM(method_table)); }} static void static void acquireWakeLock(JNIEnv *env, jobject clazz, acquireWakeLock(JNIEnv *env, jobject clazz, jint lock, jstring idObj) jint lock, jstring idObj) { { if (idObj == NULL) { if (idObj == NULL) { throw_NullPointerException(env, "id is null"); throw_NullPointerException(env, "id is null"); return ; return ; } } const char *id = env->GetStringUTFChars(idObj, NULL); const char *id = env->GetStringUTFChars(idObj, NULL); acquire_wake_lock(lock, id); acquire_wake_lock(lock, id); env->ReleaseStringUTFChars(idObj, id); env->ReleaseStringUTFChars(idObj, id); 30 } 0xlab – connect your device to application – http://0xlab.org/ }
  • 31. Power hardware/libhardware_legacy/power/power.c hardware/libhardware_legacy/power/power.c ... ... int int acquire_wake_lock(int lock, const char* id) acquire_wake_lock(int lock, const char* id) { { initialize_fds(); initialize_fds(); const char * const OLD_PATHS[] = { const char * const OLD_PATHS[] = { if (g_error) return g_error; if (g_error) return g_error; "/sys/android_power/acquire_partial_wake_lock", "/sys/android_power/acquire_partial_wake_lock", "/sys/android_power/release_wake_lock", "/sys/android_power/release_wake_lock", int fd; int fd; "/sys/android_power/request_state" "/sys/android_power/request_state" if (lock == PARTIAL_WAKE_LOCK) { if (lock == PARTIAL_WAKE_LOCK) { }; }; fd = g_fds[ACQUIRE_PARTIAL_WAKE_LOCK]; fd = g_fds[ACQUIRE_PARTIAL_WAKE_LOCK]; } } const char * const NEW_PATHS[] = { const char * const NEW_PATHS[] = { else { else { "/sys/power/wake_lock", "/sys/power/wake_lock", return EINVAL; return EINVAL; "/sys/power/wake_unlock", "/sys/power/wake_unlock", } } "/sys/power/state" "/sys/power/state" return write(fd, id, strlen(id)); return write(fd, id, strlen(id)); }; }; } } (Kernel interface changes in Android Cupcake) (Kernel interface changes in Android Cupcake) static inline void static inline void initialize_fds(void) initialize_fds(void) { { if (g_initialized == 0) { if (g_initialized == 0) { if(open_file_descriptors(NEW_PATHS) < 0) { if(open_file_descriptors(NEW_PATHS) < 0) { open_file_descriptors(OLD_PATHS); open_file_descriptors(OLD_PATHS); on_state = "wake"; on_state = "wake"; off_state = "standby"; off_state = "standby"; } } g_initialized = 1; g_initialized = 1; } } } } 31 0xlab – connect your device to application – http://0xlab.org/
  • 32. Android PM Kernel APIs Source code (Cupcake, linux-2.6.27) kernel/kernel/power/userwake.c kernel/kernel/power/wakelock.c static long has_wake_lock_locked(int type) static long has_wake_lock_locked(int type) { { static int power_suspend_late( static int power_suspend_late( struct wake_lock *lock, *n; struct wake_lock *lock, *n; struct platform_device *pdev, struct platform_device *pdev, long max_timeout = 0; long max_timeout = 0; pm_message_t state) pm_message_t state) BUG_ON(type >= WAKE_LOCK_TYPE_COUNT); BUG_ON(type >= WAKE_LOCK_TYPE_COUNT); { { list_for_each_entry_safe(lock, n, list_for_each_entry_safe(lock, n, int ret = int ret = &active_wake_locks[type], link) { &active_wake_locks[type], link) { has_wake_lock(WAKE_LOCK_SUSPEND) ? has_wake_lock(WAKE_LOCK_SUSPEND) ? if (lock->flags & WAKE_LOCK_AUTO_EXPIRE) { if (lock->flags & WAKE_LOCK_AUTO_EXPIRE) { -EAGAIN : 0; -EAGAIN : 0; long timeout = lock->expires - jiffies; long timeout = lock->expires - jiffies; return ret; return ret; if (timeout <= 0) if (timeout <= 0) } } expire_wake_lock(lock); expire_wake_lock(lock); else if (timeout > max_timeout) else if (timeout > max_timeout) static struct platform_driver power_driver = { static struct platform_driver power_driver = { max_timeout = timeout; max_timeout = timeout; .driver.name = "power", .driver.name = "power", } else } else .suspend_late = power_suspend_late, .suspend_late = power_suspend_late, return -1; return -1; }; }; } } static struct platform_device power_device = { static struct platform_device power_device = { return max_timeout; return max_timeout; .name = "power", .name = "power", } } }; }; long has_wake_lock(int type) long has_wake_lock(int type) { { long ret; long ret; unsigned long irqflags; unsigned long irqflags; spin_lock_irqsave(&list_lock, irqflags); spin_lock_irqsave(&list_lock, irqflags); ret = has_wake_lock_locked(type); ret = has_wake_lock_locked(type); spin_unlock_irqrestore(&list_lock, irqflags); spin_unlock_irqrestore(&list_lock, irqflags); return ret; return ret; } } 32 0xlab – connect your device to application – http://0xlab.org/
  • 33. Android PM Kernel APIs kernel/kernel/power/wakelock.c static int __init wakelocks_init(void) static int __init wakelocks_init(void) { { int ret; int ret; int i; int i; for (i = 0; i < ARRAY_SIZE(active_wake_locks); i++) for (i = 0; i < ARRAY_SIZE(active_wake_locks); i++) INIT_LIST_HEAD(&active_wake_locks[i]); INIT_LIST_HEAD(&active_wake_locks[i]); wake_lock_init(&main_wake_lock, WAKE_LOCK_SUSPEND, "main"); wake_lock_init(&main_wake_lock, WAKE_LOCK_SUSPEND, "main"); wake_lock(&main_wake_lock); wake_lock(&main_wake_lock); wake_lock_init(&unknown_wakeup, WAKE_LOCK_SUSPEND, "unknown_wakeups"); wake_lock_init(&unknown_wakeup, WAKE_LOCK_SUSPEND, "unknown_wakeups"); ret = platform_device_register(&power_device); ret = platform_device_register(&power_device); if (ret) { if (ret) { pr_err("wakelocks_init: platform_device_register pr_err("wakelocks_init: platform_device_register failedn"); failedn"); goto err_platform_device_register; goto err_platform_device_register; } } ret = platform_driver_register(&power_driver); ret = platform_driver_register(&power_driver); if (ret) { if (ret) { pr_err("wakelocks_init: platform_driver_register pr_err("wakelocks_init: platform_driver_register failedn"); failedn"); goto err_platform_driver_register; goto err_platform_driver_register; } } suspend_work_queue = create_singlethread_workqueue("suspend"); suspend_work_queue = create_singlethread_workqueue("suspend"); if (suspend_work_queue == NULL) { if (suspend_work_queue == NULL) { ret = -ENOMEM; ret = -ENOMEM; goto err_suspend_work_queue; goto err_suspend_work_queue; } } 33 0xlab – connect your device to application – http://0xlab.org/
  • 34. Back to userspace Use “grep -r acquire_wake_lock” to discover. frameworks/base/libs/ui/EventHub.cpp EventHub::EventHub(), EventHub::~EventHub(), EventHub::getEvent() hardware/ril/libril/ril.cpp RIL_onUnsolicitedResponse(), system/wlan/ti/sta_dk_4_0_4_32/CUDK/tiwlan_loader/tiwlan_loader.c start_cli() 34 0xlab – connect your device to application – http://0xlab.org/
  • 35. Back to userspace Use “grep -ri power” to discover. base/core/jni/android_net_wifi_Wifi.cpp android.net.wifi.WifiNative.setPowerModeCommand (android_net_wifi_setPowerModeCommand) base/core/java/com/android/internal/os/BatteryStats.java base/core/java/com/android/internal/os/BatteryStatsImpl.java base/core/java/com/android/os/PowerManager.java base/core/java/com/android/os/LocalPowerManager.java base/core/java/com/android/os/Power.java base/core/java/com/android/app/ApplicationContext.java base/core/java/android/bluetooth/ScoSocket.java base/core/java/android/bluetooth/HeadsetBase.java base/core/media/java/android/media/MediaPlayer.java base/core/media/java/android/media/AsyncPlayer.java 35 0xlab – connect your device to application – http://0xlab.org/
  • 36. Back to userspace Use “grep -ri power” to discover. base/telephony/java/com/android/internal/telephony/gsm/GSMConnection. java base/telephony/java/com/android/internal/telephony/gsm/RIL.java base/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java base/services/jni/com_android_server_BatteryService.cpp base/services/java/com/android/server/am/ActivityManagerService.java base/services/java/com/android/server/SystemServer.java base/services/java/com/android/server/BatteryService.java base/services/java/com/android/server/AlarmManagerService.java base/services/java/com/android/server/LocationManagerService.java base/services/java/com/android/server/HardwareService.java base/services/java/com/android/server/PowerManagerService.java 36 0xlab – connect your device to application – http://0xlab.org/
  • 37. Back to userspace Use “grep -ri power” to discover. system/core/toolbox/powerd.c system/core/toolbox/alarm.c system/core/vold/mmc.c system/core/vold/uevent.c 37 0xlab – connect your device to application – http://0xlab.org/
  • 38. Introduction to Linux Power Management Concepts behind Android Power Management Basically, it is the slim wrapper for Linux Power Management Design and Implementation Room for Improvements 38 0xlab – connect your device to application – http://0xlab.org/
  • 39. So, Android PM is simple Key concept is “Wake Locks”, which is simple and portable. The implementation should be introspected. If there are no active wake locks, CPU will be turned off. If there is are partial wake locks, screen and keyboard will be turned off. Nowadays, CPU can enter into more states for power saving and usability purpose! → applied in modern SoC 39 0xlab – connect your device to application – http://0xlab.org/
  • 40. Interface to Physical World Analog The Real Signal Signal Conditioning Conversion World to Digital Temperature Pressure Position Speed Power Digital Signal Processor Flow Management Humidity Sound Light Digital Signal Signal Conditioning Interface Conversion to Analog Clocks & Timers 40 0xlab – connect your device to application – http://0xlab.org/
  • 41. Advanced Power Management Power management aims to improve battery life of equipment by minimizing power consumption while guaranteeing expected system performance Active power consumption occurs while some processing is on-going Dynamic power consumption (transistor switching) + Leakage consumption Static (also Standby or Idle) power consumption occurs when limited or no processing is on-going and the system is waiting for a wakeup event Very limited dynamic power consumption + Leakage consumption Managed by Dynamic Voltage & Frequency Scaling (DVFS) Adaptive Voltage Scaling (AVS) Dynamic Power Switching (DPS) On OMAP35xx, power management is handled by the On OMAP35xx, power management is handled by the Power, Reset and Clock Management (PRCM) module Power, Reset and Clock Management (PRCM) module 41 0xlab – connect your device to application – http://0xlab.org/
  • 42. Adaptive Voltage Scaling Silicon manufacturing process yields a distribution of performance capability For a given frequency requirement: Devices on hot/strong/fast end of distribution can meet this at a lower voltage Devices on cold/weak/slow end of distribution need higher voltage Simple system will set the higher voltage for operating all devices Smarter system will adapt operating voltage per device. hotter device hotter device 42 0xlab – connect your device to application – http://0xlab.org/
  • 43. Power Block Diagram VDD1 DCDC MPU IVA VDD2 DCDC OMAP3530 CORE VRTC VIO DCDC IOs Memory Display Wake-Up domains USB CP VDAC Video DAC USB PHY VPLL PLL VPP or VAUX Camera IF VMMC MMC1 TPS659xx 43 0xlab – connect your device to application – http://0xlab.org/
  • 44. Reference Software Architecture Applications GUI App Framework 2D/3D APIs Multimedia Optional Framework DRM GFX Driver Codec Engine and Link Codec Engine FC BIOS Linux Kernel / WinCE audio video image & Power Management video image audio video image audio GFX ARM C64x+ DSP and Video Acceleration 44 0xlab – connect your device to application – http://0xlab.org/
  • 45. Linux PM Mechanisms cpuidle Generic framework for supporting software-controlled idle processor power management Hardware specific drivers Various governing for the state transition decisions Latency and power management Framework for expressing latency constraints, and make sure that they are taken into account for power management decisions Needs to be integrated into Android Partial Wake Locks 45 0xlab – connect your device to application – http://0xlab.org/
  • 46. Summary Integration is the key to the most power-saving system 46 0xlab – connect your device to application – http://0xlab.org/
  • 47. Reference PDK :: Android – Power Management http://www.netmite.com/android/mydroid/development/pdk/docs/power_ma nagement.html Android Cupcake source code http://www.netmite.com/android/mydroid/cupcake/ BeagleBoard and its Linux support http://elinux.org/BeagleBoard class PowerManager http://developer.android.com/reference/android/os/PowerManager.html Free-Electrons http://free-electrons.com/training CELF's power management specification http://elinux.org/Power_Management 47 0xlab – connect your device to application – http://0xlab.org/