Lines Matching +full:pm +full:- +full:related
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Power Management Quality of Service (PM QoS) support base.
11 * Provided here is an interface for specifying PM QoS dependencies. It allows
15 * or through a built-in notification mechanism.
50 * pm_qos_read_value - Return the current effective constraint value.
51 * @c: List of PM QoS constraint requests.
55 return READ_ONCE(c->target_value); in pm_qos_read_value()
60 if (plist_head_empty(&c->list)) in pm_qos_get_value()
61 return c->no_constraint_value; in pm_qos_get_value()
63 switch (c->type) { in pm_qos_get_value()
65 return plist_first(&c->list)->prio; in pm_qos_get_value()
68 return plist_last(&c->list)->prio; in pm_qos_get_value()
71 WARN(1, "Unknown PM QoS type in %s\n", __func__); in pm_qos_get_value()
78 WRITE_ONCE(c->target_value, value); in pm_qos_set_value()
82 * pm_qos_update_target - Update a list of PM QoS constraint requests.
83 * @c: List of PM QoS requests.
88 * Update the given list of PM QoS constraint requests, @c, by carrying an
108 new_value = c->default_value; in pm_qos_update_target()
114 plist_del(node, &c->list); in pm_qos_update_target()
121 plist_del(node, &c->list); in pm_qos_update_target()
125 plist_add(node, &c->list); in pm_qos_update_target()
142 if (c->notifiers) in pm_qos_update_target()
143 blocking_notifier_call_chain(c->notifiers, curr_value, NULL); in pm_qos_update_target()
149 * pm_qos_flags_remove_req - Remove device PM QoS flags request.
150 * @pqf: Device PM QoS flags set to remove the request from.
158 list_del(&req->node); in pm_qos_flags_remove_req()
159 list_for_each_entry(req, &pqf->list, node) in pm_qos_flags_remove_req()
160 val |= req->flags; in pm_qos_flags_remove_req()
162 pqf->effective_flags = val; in pm_qos_flags_remove_req()
166 * pm_qos_update_flags - Update a set of PM QoS flags.
167 * @pqf: Set of PM QoS flags to update.
183 prev_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags; in pm_qos_update_flags()
193 req->flags = val; in pm_qos_update_flags()
194 INIT_LIST_HEAD(&req->node); in pm_qos_update_flags()
195 list_add_tail(&req->node, &pqf->list); in pm_qos_update_flags()
196 pqf->effective_flags |= val; in pm_qos_update_flags()
203 curr_value = list_empty(&pqf->list) ? 0 : pqf->effective_flags; in pm_qos_update_flags()
213 /* Definitions related to the CPU latency QoS. */
229 * cpu_latency_qos_limit - Return current system-wide CPU latency QoS limit.
237 * cpu_latency_qos_request_active - Check the given PM QoS request.
238 * @req: PM QoS request to check.
245 return req->qos == &cpu_latency_constraints; in cpu_latency_qos_request_active()
252 int ret = pm_qos_update_target(req->qos, &req->node, action, value); in cpu_latency_qos_apply()
258 * cpu_latency_qos_add_request - Add new CPU latency QoS request.
281 req->qos = &cpu_latency_constraints; in cpu_latency_qos_add_request()
287 * cpu_latency_qos_update_request - Modify existing CPU latency QoS request.
307 if (new_value == req->node.prio) in cpu_latency_qos_update_request()
315 * cpu_latency_qos_remove_request - Remove existing CPU latency QoS request.
346 return -ENOMEM; in cpu_latency_qos_open()
349 filp->private_data = req; in cpu_latency_qos_open()
356 struct pm_qos_request *req = filp->private_data; in cpu_latency_qos_release()
358 filp->private_data = NULL; in cpu_latency_qos_release()
369 struct pm_qos_request *req = filp->private_data; in cpu_latency_qos_read()
374 return -EINVAL; in cpu_latency_qos_read()
390 return -EFAULT; in cpu_latency_qos_write()
399 cpu_latency_qos_update_request(filp->private_data, value); in cpu_latency_qos_write()
432 /* Definitions related to the frequency QoS below. */
440 * freq_constraints_init - Initialize frequency QoS constraints.
447 c = &qos->min_freq; in freq_constraints_init()
448 plist_head_init(&c->list); in freq_constraints_init()
449 c->target_value = FREQ_QOS_MIN_DEFAULT_VALUE; in freq_constraints_init()
450 c->default_value = FREQ_QOS_MIN_DEFAULT_VALUE; in freq_constraints_init()
451 c->no_constraint_value = FREQ_QOS_MIN_DEFAULT_VALUE; in freq_constraints_init()
452 c->type = PM_QOS_MAX; in freq_constraints_init()
453 c->notifiers = &qos->min_freq_notifiers; in freq_constraints_init()
454 BLOCKING_INIT_NOTIFIER_HEAD(c->notifiers); in freq_constraints_init()
456 c = &qos->max_freq; in freq_constraints_init()
457 plist_head_init(&c->list); in freq_constraints_init()
458 c->target_value = FREQ_QOS_MAX_DEFAULT_VALUE; in freq_constraints_init()
459 c->default_value = FREQ_QOS_MAX_DEFAULT_VALUE; in freq_constraints_init()
460 c->no_constraint_value = FREQ_QOS_MAX_DEFAULT_VALUE; in freq_constraints_init()
461 c->type = PM_QOS_MIN; in freq_constraints_init()
462 c->notifiers = &qos->max_freq_notifiers; in freq_constraints_init()
463 BLOCKING_INIT_NOTIFIER_HEAD(c->notifiers); in freq_constraints_init()
467 * freq_qos_read_value - Get frequency QoS constraint for a given list.
480 pm_qos_read_value(&qos->min_freq); in freq_qos_read_value()
485 pm_qos_read_value(&qos->max_freq); in freq_qos_read_value()
496 * freq_qos_apply - Add/modify/remove frequency QoS request.
508 switch(req->type) { in freq_qos_apply()
510 ret = pm_qos_update_target(&req->qos->min_freq, &req->pnode, in freq_qos_apply()
514 ret = pm_qos_update_target(&req->qos->max_freq, &req->pnode, in freq_qos_apply()
518 ret = -EINVAL; in freq_qos_apply()
525 * freq_qos_add_request - Insert new frequency QoS request into a given list.
545 return -EINVAL; in freq_qos_add_request()
549 return -EINVAL; in freq_qos_add_request()
551 req->qos = qos; in freq_qos_add_request()
552 req->type = type; in freq_qos_add_request()
555 req->qos = NULL; in freq_qos_add_request()
556 req->type = 0; in freq_qos_add_request()
564 * freq_qos_update_request - Modify existing frequency QoS request.
577 return -EINVAL; in freq_qos_update_request()
581 return -EINVAL; in freq_qos_update_request()
583 if (req->pnode.prio == new_value) in freq_qos_update_request()
591 * freq_qos_remove_request - Remove frequency QoS request from its list.
605 return -EINVAL; in freq_qos_remove_request()
609 return -EINVAL; in freq_qos_remove_request()
612 req->qos = NULL; in freq_qos_remove_request()
613 req->type = 0; in freq_qos_remove_request()
620 * freq_qos_add_notifier - Add frequency QoS change notifier.
632 return -EINVAL; in freq_qos_add_notifier()
636 ret = blocking_notifier_chain_register(qos->min_freq.notifiers, in freq_qos_add_notifier()
640 ret = blocking_notifier_chain_register(qos->max_freq.notifiers, in freq_qos_add_notifier()
645 ret = -EINVAL; in freq_qos_add_notifier()
653 * freq_qos_remove_notifier - Remove frequency QoS change notifier.
665 return -EINVAL; in freq_qos_remove_notifier()
669 ret = blocking_notifier_chain_unregister(qos->min_freq.notifiers, in freq_qos_remove_notifier()
673 ret = blocking_notifier_chain_unregister(qos->max_freq.notifiers, in freq_qos_remove_notifier()
678 ret = -EINVAL; in freq_qos_remove_notifier()