⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 devices.txt

📁 linux 内核源代码
💻 TXT
📖 第 1 页 / 共 2 页
字号:
In contrast, integrated system-on-chip processors often use irqs as thewakeup event sources (so drivers would call enable_irq_wake) and mightbe able to treat DMA completion as a wakeup event (sometimes DMA can stayactive too, it'd only be the CPU and some peripherals that sleep).Some details here may be platform-specific.  Systems may have devices thatcan be fully active in certain sleep states, such as an LCD display that'srefreshed using DMA while most of the system is sleeping lightly ... andits frame buffer might even be updated by a DSP or other non-Linux CPU whilethe Linux control processor stays idle.Moreover, the specific actions taken may depend on the target system state.One target system state might allow a given device to be very operational;another might require a hard shut down with re-initialization on resume.And two different target systems might use the same device in differentways; the aforementioned LCD might be active in one product's "standby",but a different product using the same SOC might work differently.Meaning of pm_message_t.event-----------------------------Parameters to suspend calls include the device affected and a message oftype pm_message_t, which has one field:  the event.  If driver does notrecognize the event code, suspend calls may abort the request and returna negative errno.  However, most drivers will be fine if they implementPM_EVENT_SUSPEND semantics for all messages.The event codes are used to refine the goal of suspending the device, andmostly matter when creating or resuming system memory image snapshots, asused with suspend-to-disk:    PM_EVENT_SUSPEND -- quiesce the driver and put hardware into a low-power	state.  When used with system sleep states like "suspend-to-RAM" or	"standby", the upcoming resume() call will often be able to rely on	state kept in hardware, or issue system wakeup events.  When used	instead with suspend-to-disk, few devices support this capability;	most are completely powered off.    PM_EVENT_FREEZE -- quiesce the driver, but don't necessarily change into	any low power mode.  A system snapshot is about to be taken, often	followed by a call to the driver's resume() method.  Neither wakeup	events nor DMA are allowed.    PM_EVENT_PRETHAW -- quiesce the driver, knowing that the upcoming resume()	will restore a suspend-to-disk snapshot from a different kernel image.	Drivers that are smart enough to look at their hardware state during	resume() processing need that state to be correct ... a PRETHAW could	be used to invalidate that state (by resetting the device), like a	shutdown() invocation would before a kexec() or system halt.  Other	drivers might handle this the same way as PM_EVENT_FREEZE.  Neither	wakeup events nor DMA are allowed.To enter "standby" (ACPI S1) or "Suspend to RAM" (STR, ACPI S3) states, orthe similarly named APM states, only PM_EVENT_SUSPEND is used; for "Suspendto Disk" (STD, hibernate, ACPI S4), all of those event codes are used.There's also PM_EVENT_ON, a value which never appears as a suspend eventbut is sometimes used to record the "not suspended" device state.Resuming Devices----------------Resuming is done in multiple phases, much like suspending, with alldevices processing each phase's calls before the next phase begins.The phases are seen by driver notifications issued in this order:   1	bus.resume_early(dev) is called with IRQs disabled, and with   	only one CPU active.  As with bus.suspend_late(), this method	won't be supported on busses that require IRQs in order to	interact with devices.	This reverses the effects of bus.suspend_late().   2	bus.resume(dev) is called next.  This may be morphed into a device   	driver call with bus-specific parameters; implementations may sleep.	This reverses the effects of bus.suspend().   3	class.resume(dev) is called for devices associated with a class	that has such a method.  Implementations may sleep.	This reverses the effects of class.suspend(), and would usually	reactivate the device's I/O queue.At the end of those phases, drivers should normally be as functional asthey were before suspending:  I/O can be performed using DMA and IRQs, andthe relevant clocks are gated on.  The device need not be "fully on"; itmight be in a runtime lowpower/suspend state that acts as if it were.However, the details here may again be platform-specific.  For example,some systems support multiple "run" states, and the mode in effect atthe end of resume() might not be the one which preceded suspension.That means availability of certain clocks or power supplies changed,which could easily affect how a driver works.Drivers need to be able to handle hardware which has been reset since thesuspend methods were called, for example by complete reinitialization.This may be the hardest part, and the one most protected by NDA'd documentsand chip errata.  It's simplest if the hardware state hasn't changed sincethe suspend() was called, but that can't always be guaranteed.Drivers must also be prepared to notice that the device has been removedwhile the system was powered off, whenever that's physically possible.PCMCIA, MMC, USB, Firewire, SCSI, and even IDE are common examples of busseswhere common Linux platforms will see such removal.  Details of how driverswill notice and handle such removals are currently bus-specific, and ofteninvolve a separate thread.Note that the bus-specific runtime PM wakeup mechanism can exist, and mightbe defined to share some of the same driver code as for system wakeup.  Forexample, a bus-specific device driver's resume() method might be used there,so it wouldn't only be called from bus.resume() during system-wide wakeup.See bus-specific information about how runtime wakeup events are handled.System Devices--------------System devices follow a slightly different API, which can be found in	include/linux/sysdev.h	drivers/base/sys.cSystem devices will only be suspended with interrupts disabled, and afterall other devices have been suspended.  On resume, they will be resumedbefore any other devices, and also with interrupts disabled.That is, IRQs are disabled, the suspend_late() phase begins, then thesysdev_driver.suspend() phase, and the system enters a sleep state.  Thenthe sysdev_driver.resume() phase begins, followed by the resume_early()phase, after which IRQs are enabled.Code to actually enter and exit the system-wide low power state sometimesinvolves hardware details that are only known to the boot firmware, andmay leave a CPU running software (from SRAM or flash memory) that monitorsthe system and manages its wakeup sequence.Runtime Power Management========================Many devices are able to dynamically power down while the system is stillrunning. This feature is useful for devices that are not being used, andcan offer significant power savings on a running system.  These devicesoften support a range of runtime power states, which might use names suchas "off", "sleep", "idle", "active", and so on.  Those states will in somecases (like PCI) be partially constrained by a bus the device uses, and willusually include hardware states that are also used in system sleep states.However, note that if a driver puts a device into a runtime low power stateand the system then goes into a system-wide sleep state, it normally oughtto resume into that runtime low power state rather than "full on".  Suchdistinctions would be part of the driver-internal state machine for thathardware; the whole point of runtime power management is to be sure thatdrivers are decoupled in that way from the state machine governing phasesof the system-wide power/sleep state transitions.Power Saving Techniques-----------------------Normally runtime power management is handled by the drivers without specificuserspace or kernel intervention, by device-aware use of techniques like:    Using information provided by other system layers	- stay deeply "off" except between open() and close()	- if transceiver/PHY indicates "nobody connected", stay "off"	- application protocols may include power commands or hints    Using fewer CPU cycles	- using DMA instead of PIO	- removing timers, or making them lower frequency	- shortening "hot" code paths	- eliminating cache misses	- (sometimes) offloading work to device firmware    Reducing other resource costs	- gating off unused clocks in software (or hardware)	- switching off unused power supplies	- eliminating (or delaying/merging) IRQs	- tuning DMA to use word and/or burst modes    Using device-specific low power states	- using lower voltages	- avoiding needless DMA transfersRead your hardware documentation carefully to see the opportunities thatmay be available.  If you can, measure the actual power usage and checkit against the budget established for your project.Examples:  USB hosts, system timer, system CPU----------------------------------------------USB host controllers make interesting, if complex, examples.  In many casesthese have no work to do:  no USB devices are connected, or all of them arein the USB "suspend" state.  Linux host controller drivers can then disableperiodic DMA transfers that would otherwise be a constant power drain on thememory subsystem, and enter a suspend state.  In power-aware controllers,entering that suspend state may disable the clock used with USB signaling,saving a certain amount of power.The controller will be woken from that state (with an IRQ) by changes to thesignal state on the data lines of a given port, for example by an existingperipheral requesting "remote wakeup" or by plugging a new peripheral.  Thesame wakeup mechanism usually works from "standby" sleep states, and on somesystems also from "suspend to RAM" (or even "suspend to disk") states.(Except that ACPI may be involved instead of normal IRQs, on some hardware.)System devices like timers and CPUs may have special roles in the platformpower management scheme.  For example, system timers using a "dynamic tick"approach don't just save CPU cycles (by eliminating needless timer IRQs),but they may also open the door to using lower power CPU "idle" states thatcost more than a jiffie to enter and exit.  On x86 systems these are stateslike "C3"; note that periodic DMA transfers from a USB host controller willalso prevent entry to a C3 state, much like a periodic timer IRQ.That kind of runtime mechanism interaction is common.  "System On Chip" (SOC)processors often have low power idle modes that can't be entered unlesscertain medium-speed clocks (often 12 or 48 MHz) are gated off.  When thedrivers gate those clocks effectively, then the system idle task may be ableto use the lower power idle modes and thereby increase battery life.If the CPU can have a "cpufreq" driver, there also may be opportunitiesto shift to lower voltage settings and reduce the power cost of executinga given number of instructions.  (Without voltage adjustment, it's rarefor cpufreq to save much power; the cost-per-instruction must go down.)/sys/devices/.../power/state files==================================For now you can also test some of this functionality using sysfs.	DEPRECATED:  USE "power/state" ONLY FOR DRIVER TESTING, AND	AVOID USING dev->power.power_state IN DRIVERS.	THESE WILL BE REMOVED.  IF THE "power/state" FILE GETS REPLACED,	IT WILL BECOME SOMETHING COUPLED TO THE BUS OR DRIVER.In each device's directory, there is a 'power' directory, which containsat least a 'state' file.  The value of this field is effectively boolean,PM_EVENT_ON or PM_EVENT_SUSPEND.   *	Reading from this file displays a value corresponding to	the power.power_state.event field.  All nonzero values are	displayed as "2", corresponding to a low power state; zero	is displayed as "0", corresponding to normal operation.   *	Writing to this file initiates a transition using the   	specified event code number; only '0', '2', and '3' are	accepted (without a newline); '2' and '3' are both	mapped to PM_EVENT_SUSPEND.On writes, the PM core relies on that recorded event code and the device/buscapabilities to determine whether it uses a partial suspend() or resume()sequence to change things so that the recorded event corresponds to thenumeric parameter.   -	If the bus requires the irqs-disabled suspend_late()/resume_early()	phases, writes fail because those operations are not supported here.   -	If the recorded value is the expected value, nothing is done.   -	If the recorded value is nonzero, the device is partially resumed,	using the bus.resume() and/or class.resume() methods.   -	If the target value is nonzero, the device is partially suspended,	using the class.suspend() and/or bus.suspend() methods and the	PM_EVENT_SUSPEND message.Drivers have no way to tell whether their suspend() and resume() callshave come through the sysfs power/state file or as part of entering asystem sleep state, except that when accessed through sysfs the normalparent/child sequencing rules are ignored.  Drivers (such as bus, bridge,or hub drivers) which expose child devices may need to enforce those ruleson their own.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -