Richard Hughes | bf1db69 | 2008-08-05 13:01:35 -0700 | [diff] [blame] | 1 | PM Quality Of Service Interface. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 2 | |
| 3 | This interface provides a kernel and user mode interface for registering |
| 4 | performance expectations by drivers, subsystems and user space applications on |
| 5 | one of the parameters. |
| 6 | |
| 7 | Currently we have {cpu_dma_latency, network_latency, network_throughput} as the |
| 8 | initial set of pm_qos parameters. |
| 9 | |
Richard Hughes | bf1db69 | 2008-08-05 13:01:35 -0700 | [diff] [blame] | 10 | Each parameters have defined units: |
| 11 | * latency: usec |
| 12 | * timeout: usec |
| 13 | * throughput: kbs (kilo bit / sec) |
| 14 | |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 15 | The infrastructure exposes multiple misc device nodes one per implemented |
| 16 | parameter. The set of parameters implement is defined by pm_qos_power_init() |
| 17 | and pm_qos_params.h. This is done because having the available parameters |
| 18 | being runtime configurable or changeable from a driver was seen as too easy to |
| 19 | abuse. |
| 20 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 21 | For each parameter a list of performance requests is maintained along with |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 22 | an aggregated target value. The aggregated target value is updated with |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 23 | changes to the request list or elements of the list. Typically the |
| 24 | aggregated target value is simply the max or min of the request values held |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 25 | in the parameter list elements. |
| 26 | |
| 27 | From kernel mode the use of this interface is simple: |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 28 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 29 | handle = pm_qos_add_request(param_class, target_value): |
| 30 | Will insert an element into the list for that identified PM_QOS class with the |
| 31 | target value. Upon change to this list the new target is recomputed and any |
| 32 | registered notifiers are called only if the target value is now different. |
| 33 | Clients of pm_qos need to save the returned handle. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 34 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 35 | void pm_qos_update_request(handle, new_target_value): |
| 36 | Will update the list element pointed to by the handle with the new target value |
| 37 | and recompute the new aggregated target, calling the notification tree if the |
| 38 | target is changed. |
| 39 | |
| 40 | void pm_qos_remove_request(handle): |
| 41 | Will remove the element. After removal it will update the aggregate target and |
| 42 | call the notification tree if the target was changed as a result of removing |
| 43 | the request. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 44 | |
| 45 | |
| 46 | From user mode: |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 47 | Only processes can register a pm_qos request. To provide for automatic |
| 48 | cleanup of a process, the interface requires the process to register its |
| 49 | parameter requests in the following way: |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 50 | |
| 51 | To register the default pm_qos target for the specific parameter, the process |
| 52 | must open one of /dev/[cpu_dma_latency, network_latency, network_throughput] |
| 53 | |
| 54 | As long as the device node is held open that process has a registered |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 55 | request on the parameter. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 56 | |
Mark Gross | ed77134 | 2010-05-06 01:59:26 +0200 | [diff] [blame] | 57 | To change the requested target value the process needs to write an s32 value to |
| 58 | the open device node. Alternatively the user mode program could write a hex |
| 59 | string for the value using 10 char long format e.g. "0x12345678". This |
| 60 | translates to a pm_qos_update_request call. |
Mark Gross | d82b351 | 2008-02-04 22:30:08 -0800 | [diff] [blame] | 61 | |
| 62 | To remove the user mode request for a target value simply close the device |
| 63 | node. |
| 64 | |
| 65 | |
| 66 | |