`
javasee
  • 浏览: 977347 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Testing Suspend and Resume for Driver Developers.

阅读更多

Please refer to http://blogs.sun.com/randyf/entry/testing_suspend_and_resume_for for original post.

Testing Suspend and Resume for Driver Developers.

Happy New Year!

But in the new year, you are a driver developer and need to support DDI_SUSPEND and DDI_RESUME. How do you do this, and then test if it is working?

First, go to my weblog describing the Power Management Interfaces and the docs.sun.com Ch. 12 "Writing Device Drivers: Power Management pages, and understand, first, how to use the Solaris Power Managment API's.

OK, so you probably have done this already, but it is always nice to have these references to go back and check. And you already know how to get this driver added and loaded/unloaded into your test machine (add_drv(1m) , modload(1m) , and modunload(1m) also for reference). But how do you go about testing the driver?

In How to Suspend and Resume , I described about modifying power.conf(4) to enable S3 support on your machine. I even described about using sys-suspend to suspend your machine. However, in the course of driver development, there will be the need to do some partial testing, or in the case of suspend and resume, other drivers might not be compliant and suspend might never get to your driver to test it.

No problem! There are test points to help you out. To start, we need to understand the primary entry point to the cpr module (where most of the work is done). Note that these commands require privilege to use, so you will have to become root, or otherwise get root privileges (see the RBAC related guides). The main command is: uadmin(1m) . This utility takes two and an optional third argument. The first is the primary command, the second is the function within that command, and the third is a string that is dependent on the first two.

For Suspend and Resume, the command will always be 3 (actually defined as A_FREEZE in the uadmin(2) man page). This is the same for all Suspend and Resume functions, including for S3 (Suspend to RAM, or sleep) and S4 (Suspend to Disk, or hibernate). Note here, that as of this blog writing, S3 is supported only on x86 systems, and S4 is supported only on Sparc systems. The second argument instructs the cpr module what it should do: sleep, hibernate, or do a test entry. The third is only used in one specific test point, but it will be described at that time.

So let's start with the first four common functions: 0, 1, 20, and 21.

0 Suspend to Disk
1 Check Suspend to Disk
20 Suspend to RAM
21 Check Suspend to RAM

The "Check" functions simply verify that the feature is supported and enabled for your platform. This is useful for various applications that only desire information about the ability to perform an operation. It returns 0 if supported, and non-0 if unsupported (the system call also returns an ENOTSUP error code). And the "Suspend" commands actually perform the operation. They will return 0 if successful, and non-0 if unsuccessful. So if a "Suspend to RAM" operation is performed on a Sparc machine, it will return non-0 and not do a suspend (in this case, the system call also returns an ENOTSUP, though other failures will return different error codes).

OK, we already know these, as this is what happens when the sys-suspend command is executed, but we also know that if there are non-compliant drivers, then the uadmin command may not get to your specific driver, or may well fail in other ways, and it makes it hard to test a driver. This is where some other functions come to play. As this blog is more specific to the x86 Suspend to RAM, I will only describe the Suspend to RAM test points.

22 Suspend to RAM, but don't power off and resume normally
23 Suspend to RAM, but don't power off and resume as a failure
24 Suspend to RAM, but don't power off and skip drivers that fail suspend
25 Suspend only a single driver - this takes the optional 'mdep' argument

The first two test points should be fairly descriptive. Go through the process of suspending, but instead of powering off, just resume (the second sets a "failure" error that is mostly only useful for framework testing, as errors are not provided to the drivers on resume). This is a good way to verify the code paths of your driver. If your driver doesn't properly execute DDI_SUSPEND or DDI_RESUME, it will be easily checked. And just as importantly, the hardware state remains intact, as the hardware wasn't actually powered off. This is also useful, if you are working on a system without a compliant framebuffer, and had to bypass it's suspend processing. Note, though, that this is an incomplete test as the hardware is not actually powered off. But it is a good way to test that code paths execute correctly.

The "25" function, though, can be used to only suspend your driver. It takes an optional 3rd (or mdep ) argument that is the major number of your driver. This can be found by searching /etc/name_to_major for your driver name, and using that number. It will only suspend your driver, and isn't useful for nexus drivers, as it doesn't walk the device tree to suspend leaf drivers (and can have adverse effects to those drivers). This may change in the future, however. But it is very useful for test suspending hardware drivers. The syntax is:

uadmin 3 25 14 , where 14 is the driver major number.

The last function, 24 should be used very cautiously! It walks the device tree as expected for a regular suspend and resume, but if it encounters a driver that returns DDI_FAILURE, instead of stopping and resuming, it will continue to the next driver, ultimately walking through the entire device tree. But use caution with this function, as it has no way of knowing if a driver returned a failure because it actually failed, or if the driver doesn't support suspend and resume. In either case, the machine could be left in an undesirable state, and a reboot might be needed (or worse, a hang, and you don't know what failed). The /var/adm/messages, as in all the other functions, will contain information as to what drivers failed, or what other failures might have occured.

This leads us to a good way to test your driver: first try uadmin 3 25 [major_number] , and see how your driver responds to a simple driver suspend. Then try a suspend without power off by uadmin 3 22 . If still successful, it is now time to try the real thing, and execute uadmin 3 20 , or /usr/openwin/bin/sys-suspend . If all goes well, your machine will suspend, and a simple case of pressing a key (or power button), the machine will resume to it's original state.

This is a great time to have a "Chimay Blue Lable"! A 'powerful' Belgian Trappist style ale with complex Belgian malt character, and hop bitterness to compliment the malt body. A light fruitiness due to the hops and Trappist yeast, and a good warming level of alcohol, makes for a strong and very enjoyable ale to celebrate the success of your driver!

分享到:
评论

相关推荐

    线程外部挂起恢复控制(不使用Suspend与Resume中止线程)

    自.NET 2.0以来,Thread.Suspend()与Thread.Resume()方法已过时,VS提示可以使用如Monitor等技术,但是对于刚接触同步控制的人来说理解起来太复杂。本人利用Thread.Abort()与Thread.Interrupt()可以引起目标线程异常...

    resume_suspend.txt

    ### 一、Suspend 和 Resume 概念 在嵌入式系统及移动设备(如Android设备)中,Suspend 和 Resume 是两个非常重要的概念。当设备进入 Suspend 状态时,它会暂时停止所有非必要的功能以节省电力,而在 Resume 状态下...

    Android-suspend-and-resume.rar_android_android 唤醒_linux suspend

    休眠/唤醒在嵌入式Linux中是非常重要的部分,嵌入式设备尽可能的进入休眠状 态来延长电池的续航时间.这篇文章就详细介绍一下Linux中休眠/唤醒是如何工作 的, 还有Android中如何把这部分和Linux的机制联系起来的.

    Andriod PM suspend-resume 电源管理

    Android PM(电源管理)的suspend-resume机制是优化电池寿命的重要组成部分,它涉及到低功耗模式、动态电压和频率调整以及时钟与电源开关控制。 1. 低功耗模式:嵌入式芯片通常具有多种低功耗状态,如STOP、WAIT和...

    PCHunter64-电脑安全类底层全面的安全漏洞查看工具-供大家学习研究参考

    Terminate, suspend and resume processes and threads. View and manipulate process handles,windows and memory regions. *Kernel Module Viewer Display kernel module information including ImageBase,Size,...

    hal库 FreeRTOS-Task-suspend&resume

    hal库 FreeRTOS-Task-suspend&resume

    ACER_SUSPEND & REBOOT V1.1.RAR

    标题中的"ACER_SUSPEND & REBOOT V1.1.RAR"显然指的是一个针对ACER品牌计算机的系统挂起和重启工具的软件包。这个工具可能是由ACER官方或者第三方开发者设计,用于优化ACER电脑的休眠和重启功能,以提供更高效、稳定...

    LINUXSuspend流程[文].pdf

    - 这个函数位于`kernel/power/suspend.c`,负责正式进入Suspend状态。 - **代码示例**: ```c pm_suspend() { enter_state(SUSPEND_STATE); } ``` 7. **`enter_state()`** - 此函数执行具体的Suspend操作,...

    r8168-8.008

    5. Fix the issue that RTL8168B and RTL8168C cannot link at 1000Mbps full after waken up from suspend and hibernate. 6. Fix the jumbo frame issue -- cannot receive packet size more than 8145 bytes 7. ...

    Enhanced Host Controller Interface Specification for Universal Serial Bus

    - **Suspend/Resume:** Explains the procedures for suspending and resuming USB operations. - **Schedule Traversal Rules:** Outlines the rules for traversing the periodic and asynchronous schedules. - *...

    CA-100CUSB充电线改装为移动电源

    • Fixed error condition state in suspend. • Revised co-installer. • Support for COM port disabled in device manager (as opposed to disabled though property page). • Fixed synchronization issue if ...

    NWH Vehicle Physics 1.7.2

    • Suspend option for inactive vehicles which minimizes impact on performance while keeping basic functionality. • Character vehicle changer that works with any character controller / game object, ...

    Open Host Controller Interface Specification

    - **USB States:** Managing the different states of the USB system, such as reset, operational, suspend, and resume. - **Frame Management:** Ensuring correct timing and synchronization of USB frames. -...

    cc2530_user_guide

    1.1.1 CPU and Memory ................................................................................................. 21 1.1.2 Clocks and Power Management ...............................................

    ARM amba总线驱动

    - **.suspend** 和 **.resume**: 分别用于处理总线上的设备在进入和退出睡眠状态时的操作。 #### 三、AMBA总线注册细节 在 AMBA 总线的初始化过程中,可以看到 `bus_register` 被用来注册这个总线类型。这个函数...

    R13_IOT_rev3

    标题《R13_IOT_rev3》和描述《RAN approved REL-13 NB_IOT; NB_IoT标准索引全集,3GPP Release 13》揭示了文档内容与NB-IoT(Narrowband Internet of Things)技术的标准化过程有关,特别是涉及到3GPP(第三代合作...

    Suspend--terminate--continue.rar_terminate

    "Suspend--terminate--continue.rar_terminate"这个压缩包文件似乎专注于讨论如何在编程环境中实现这些功能,特别是关于终止(terminate)的机制。 首先,我们要理解“暂停”(Suspend)的概念。在程序运行过程中,...

    CIS_Solaris_10_Benchmark_v5.0.0

    Assumptions and Recommendations .................................................................................................... 11 OS Platform .......................................................

    戴尔蓝牙365黑苹果驱动lion,10.7,10.6,10.5均可以使用

    There are no suspend/resume scripts ala sleepwatcher required. Driver reloads right away upon resume Handles reloading when you turn off/on of the wireless card via the laptop's hotkey. Driver is ...

    Source code for "µC/OS-II 2.52"

    µC/OS-II, The Real-Time Kernel is a highly portable, ROMable, very scalable, preemptive real-time, multitasking kernel (RTOS) for microprocessors and microcontrollers. µC/OS-II can manage up to 255 ...

Global site tag (gtag.js) - Google Analytics