linux - Linux 中的电源管理框架

标签 linux linux-device-driver power-management

我观察到整个设备拓扑是基于Buses --> Device + Driver。 linux (suspend + resume) 提供的电源管理存在于总线中。设备驱动程序中也有类似的功能。

struct bus_type { ***

    int (*suspend)(struct device *dev, pm_message_t state);

    int (*resume)(struct device *dev);

    *** }


    struct device_driver { ***

    int (*suspend) (struct device *dev, pm_message_t state);

    int (*resume) (struct device *dev);

    *** }

那么这是如何实现的呢?

最佳答案

我搜索了很多,终于在文档中找到了我的答案:

To ensure that bridges and similar links needing to talk to a device are available when the device is suspended or resumed, the device tree is walked in a bottom-up order to suspend devices. A top-down order is used to resume those devices.

The ordering of the device tree is defined by the order in which devices get registered: a child can never be registered, probed or resumed before its parent; and can't be removed or suspended after that parent.

The policy is that the device tree should match hardware bus topology.

关于总线和设备挂起和恢复回调:

All phases use bus, type, or class callbacks (that is, methods defined in dev->bus->pm, dev->type->pm, or dev->class->pm).
These callbacks are mutually exclusive, so if the device type provides a struct dev_pm_ops object pointed to by its pm field (i.e. both dev->type and dev->type->pm are defined), the callbacks included in that object (i.e. dev->type->pm) will be used. Otherwise, if the class provides a struct dev_pm_ops object pointed to by its pm field (i.e. both dev->class and dev->class->pm are defined), the PM core will use the callbacks from that object (i.e. dev->class->pm).
Finally, if the pm fields of both the device type and class objects are NULL (or those objects do not exist), the callbacks provided by the bus (that is, the callbacks from dev->bus->pm) will be used (this allows device types to override callbacks provided by bus types or classes if necessary).

关于linux - Linux 中的电源管理框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12967573/

相关文章:

c++ - 为 Linux 开发 C++ MySQL 应用程序的资源

linux - 什么是 ITER_IOVEC、ITER_KVEC 和 ITER_BVEC?

compact-framework - 紧凑框架-System.Threading.Timer在用户关闭屏幕时停止

android - android 中的电池使用情况分析

linux - 检查字符串是否包含星号 (*)

linux:在 apache 中运行 cgi-bin 模块时出现错误 500,而不是从 ssh

c - Shellscript和C程序之间的同步

linux - 我如何确定安装了哪个 MTD 闪存设备(例如获取 ID 或序列号)?

对 ioctl() 和内核头文件的混淆

ios - 控制 iPad 电源状态的应用程序