pm_qos_interface.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. PM Quality Of Service Interface.
  2. This interface provides a kernel and user mode interface for registering
  3. performance expectations by drivers, subsystems and user space applications on
  4. one of the parameters.
  5. Two different PM QoS frameworks are available:
  6. 1. PM QoS classes for cpu_dma_latency, network_latency, network_throughput.
  7. 2. the per-device PM QoS framework provides the API to manage the per-device latency
  8. constraints.
  9. Each parameters have defined units:
  10. * latency: usec
  11. * timeout: usec
  12. * throughput: kbs (kilo bit / sec)
  13. 1. PM QoS framework
  14. The infrastructure exposes multiple misc device nodes one per implemented
  15. parameter. The set of parameters implement is defined by pm_qos_power_init()
  16. and pm_qos.h. This is done because having the available parameters
  17. being runtime configurable or changeable from a driver was seen as too easy to
  18. abuse.
  19. For each parameter a list of performance requests is maintained along with
  20. an aggregated target value. The aggregated target value is updated with
  21. changes to the request list or elements of the list. Typically the
  22. aggregated target value is simply the max or min of the request values held
  23. in the parameter list elements.
  24. Note: the aggregated target value is implemented as an atomic variable so that
  25. reading the aggregated value does not require any locking mechanism.
  26. From kernel mode the use of this interface is simple:
  27. void pm_qos_add_request(handle, param_class, target_value):
  28. Will insert an element into the list for that identified PM QoS class with the
  29. target value. Upon change to this list the new target is recomputed and any
  30. registered notifiers are called only if the target value is now different.
  31. Clients of pm_qos need to save the returned handle for future use in other
  32. pm_qos API functions.
  33. void pm_qos_update_request(handle, new_target_value):
  34. Will update the list element pointed to by the handle with the new target value
  35. and recompute the new aggregated target, calling the notification tree if the
  36. target is changed.
  37. void pm_qos_remove_request(handle):
  38. Will remove the element. After removal it will update the aggregate target and
  39. call the notification tree if the target was changed as a result of removing
  40. the request.
  41. int pm_qos_request(param_class):
  42. Returns the aggregated value for a given PM QoS class.
  43. int pm_qos_request_active(handle):
  44. Returns if the request is still active, i.e. it has not been removed from a
  45. PM QoS class constraints list.
  46. int pm_qos_add_notifier(param_class, notifier):
  47. Adds a notification callback function to the PM QoS class. The callback is
  48. called when the aggregated value for the PM QoS class is changed.
  49. int pm_qos_remove_notifier(int param_class, notifier):
  50. Removes the notification callback function for the PM QoS class.
  51. From user mode:
  52. Only processes can register a pm_qos request. To provide for automatic
  53. cleanup of a process, the interface requires the process to register its
  54. parameter requests in the following way:
  55. To register the default pm_qos target for the specific parameter, the process
  56. must open one of /dev/[cpu_dma_latency, network_latency, network_throughput]
  57. As long as the device node is held open that process has a registered
  58. request on the parameter.
  59. To change the requested target value the process needs to write an s32 value to
  60. the open device node. Alternatively the user mode program could write a hex
  61. string for the value using 10 char long format e.g. "0x12345678". This
  62. translates to a pm_qos_update_request call.
  63. To remove the user mode request for a target value simply close the device
  64. node.
  65. 2. PM QoS per-device latency framework
  66. For each device a list of performance requests is maintained along with
  67. an aggregated target value. The aggregated target value is updated with
  68. changes to the request list or elements of the list. Typically the
  69. aggregated target value is simply the max or min of the request values held
  70. in the parameter list elements.
  71. Note: the aggregated target value is implemented as an atomic variable so that
  72. reading the aggregated value does not require any locking mechanism.
  73. From kernel mode the use of this interface is the following:
  74. int dev_pm_qos_add_request(device, handle, type, value):
  75. Will insert an element into the list for that identified device with the
  76. target value. Upon change to this list the new target is recomputed and any
  77. registered notifiers are called only if the target value is now different.
  78. Clients of dev_pm_qos need to save the handle for future use in other
  79. dev_pm_qos API functions.
  80. int dev_pm_qos_update_request(handle, new_value):
  81. Will update the list element pointed to by the handle with the new target value
  82. and recompute the new aggregated target, calling the notification trees if the
  83. target is changed.
  84. int dev_pm_qos_remove_request(handle):
  85. Will remove the element. After removal it will update the aggregate target and
  86. call the notification trees if the target was changed as a result of removing
  87. the request.
  88. s32 dev_pm_qos_read_value(device):
  89. Returns the aggregated value for a given device's constraints list.
  90. Notification mechanisms:
  91. The per-device PM QoS framework has 2 different and distinct notification trees:
  92. a per-device notification tree and a global notification tree.
  93. int dev_pm_qos_add_notifier(device, notifier):
  94. Adds a notification callback function for the device.
  95. The callback is called when the aggregated value of the device constraints list
  96. is changed.
  97. int dev_pm_qos_remove_notifier(device, notifier):
  98. Removes the notification callback function for the device.
  99. int dev_pm_qos_add_global_notifier(notifier):
  100. Adds a notification callback function in the global notification tree of the
  101. framework.
  102. The callback is called when the aggregated value for any device is changed.
  103. int dev_pm_qos_remove_global_notifier(notifier):
  104. Removes the notification callback function from the global notification tree
  105. of the framework.
  106. From user mode:
  107. No API for user space access to the per-device latency constraints is provided
  108. yet - still under discussion.