Lines Matching +full:child +full:- +full:node

1 // SPDX-License-Identifier: GPL-2.0-only
12 * parent node is a virtual description of the aggregation of the
39 return -ENOSYS; in get_time_window_us()
44 return -ENOSYS; in set_time_window_us()
52 *max_power_uw = dtpm->power_max - dtpm->power_min; in get_max_power_range_uw()
60 struct dtpm *child; in __get_power_uw() local
64 if (dtpm->ops) { in __get_power_uw()
65 *power_uw = dtpm->ops->get_power_uw(dtpm); in __get_power_uw()
71 list_for_each_entry(child, &dtpm->children, sibling) { in __get_power_uw()
72 ret = __get_power_uw(child, &power); in __get_power_uw()
95 struct dtpm *child; in __dtpm_rebalance_weight() local
97 list_for_each_entry(child, &dtpm->children, sibling) { in __dtpm_rebalance_weight()
100 child->weight, child->zone.name); in __dtpm_rebalance_weight()
102 child->weight = DIV64_U64_ROUND_CLOSEST( in __dtpm_rebalance_weight()
103 child->power_max * 1024, dtpm->power_max); in __dtpm_rebalance_weight()
105 __dtpm_rebalance_weight(child); in __dtpm_rebalance_weight()
111 struct dtpm *parent = dtpm->parent; in __dtpm_sub_power()
114 parent->power_min -= dtpm->power_min; in __dtpm_sub_power()
115 parent->power_max -= dtpm->power_max; in __dtpm_sub_power()
116 parent->power_limit -= dtpm->power_limit; in __dtpm_sub_power()
117 parent = parent->parent; in __dtpm_sub_power()
125 struct dtpm *parent = dtpm->parent; in __dtpm_add_power()
128 parent->power_min += dtpm->power_min; in __dtpm_add_power()
129 parent->power_max += dtpm->power_max; in __dtpm_add_power()
130 parent->power_limit += dtpm->power_limit; in __dtpm_add_power()
131 parent = parent->parent; in __dtpm_add_power()
138 * dtpm_update_power - Update the power on the dtpm
143 * Function to update the power values of the dtpm node specified in
146 * Return: zero on success, -EINVAL if the values are inconsistent
154 if (power_min == dtpm->power_min && power_max == dtpm->power_max) in dtpm_update_power()
158 ret = -EINVAL; in dtpm_update_power()
164 dtpm->power_min = power_min; in dtpm_update_power()
165 dtpm->power_max = power_max; in dtpm_update_power()
166 if (!test_bit(DTPM_POWER_LIMIT_FLAG, &dtpm->flags)) in dtpm_update_power()
167 dtpm->power_limit = power_max; in dtpm_update_power()
178 * dtpm_release_zone - Cleanup when the node is released
182 * release will be denied if the node has children. This function must
186 * Return: 0 on success, -EBUSY if there are children
191 struct dtpm *parent = dtpm->parent; in dtpm_release_zone()
195 if (!list_empty(&dtpm->children)) { in dtpm_release_zone()
197 return -EBUSY; in dtpm_release_zone()
201 list_del(&dtpm->sibling); in dtpm_release_zone()
207 if (dtpm->ops) in dtpm_release_zone()
208 dtpm->ops->release(dtpm); in dtpm_release_zone()
220 *power_limit = dtpm->power_limit; in __get_power_limit_uw()
241 * The dtpm node lock must be held when calling this function.
245 struct dtpm *child; in __set_power_limit_uw() local
251 * otherwise we set a constraint and flag the dtpm node. in __set_power_limit_uw()
253 if (power_limit == dtpm->power_max) { in __set_power_limit_uw()
254 clear_bit(DTPM_POWER_LIMIT_FLAG, &dtpm->flags); in __set_power_limit_uw()
256 set_bit(DTPM_POWER_LIMIT_FLAG, &dtpm->flags); in __set_power_limit_uw()
260 dtpm->zone.name, power_limit); in __set_power_limit_uw()
265 if (dtpm->ops) { in __set_power_limit_uw()
266 dtpm->power_limit = dtpm->ops->set_power_uw(dtpm, power_limit); in __set_power_limit_uw()
268 dtpm->power_limit = 0; in __set_power_limit_uw()
270 list_for_each_entry(child, &dtpm->children, sibling) { in __set_power_limit_uw()
276 * initial value, we force the child's min or in __set_power_limit_uw()
280 if (power_limit == dtpm->power_max) { in __set_power_limit_uw()
281 power = child->power_max; in __set_power_limit_uw()
282 } else if (power_limit == dtpm->power_min) { in __set_power_limit_uw()
283 power = child->power_min; in __set_power_limit_uw()
286 power_limit * child->weight, 1024); in __set_power_limit_uw()
290 child->zone.name, power); in __set_power_limit_uw()
292 ret = __set_power_limit_uw(child, cid, power); in __set_power_limit_uw()
294 ret = __get_power_limit_uw(child, cid, &power); in __set_power_limit_uw()
299 dtpm->power_limit += power; in __set_power_limit_uw()
318 power_limit = clamp_val(power_limit, dtpm->power_min, dtpm->power_max); in set_power_limit_uw()
323 dtpm->zone.name, dtpm->power_limit, dtpm->power_max); in set_power_limit_uw()
340 *max_power = dtpm->power_max; in get_max_power_uw()
362 * dtpm_alloc - Allocate and initialize a dtpm struct
363 * @name: a string specifying the name of the node
373 INIT_LIST_HEAD(&dtpm->children); in dtpm_alloc()
374 INIT_LIST_HEAD(&dtpm->sibling); in dtpm_alloc()
375 dtpm->weight = 1024; in dtpm_alloc()
376 dtpm->ops = ops; in dtpm_alloc()
383 * dtpm_unregister - Unregister a dtpm node from the hierarchy tree
384 * @dtpm: a pointer to a dtpm structure corresponding to the node to be removed
391 powercap_unregister_zone(pct, &dtpm->zone); in dtpm_unregister()
393 pr_info("Unregistered dtpm node '%s'\n", dtpm->zone.name); in dtpm_unregister()
397 * dtpm_register - Register a dtpm node in the hierarchy tree
398 * @name: a string specifying the name of the node
399 * @dtpm: a pointer to a dtpm structure corresponding to the new node
400 * @parent: a pointer to a dtpm structure corresponding to the parent node
402 * Create a dtpm node in the tree. If no parent is specified, the node
403 * is the root node of the hierarchy. If the root node already exists,
411 * -EAGAIN: the function is called before the framework is initialized.
412 * -EBUSY: the root node is already inserted
413 * -EINVAL: * there is no root node yet and @parent is specified
423 return -EAGAIN; in dtpm_register()
426 return -EBUSY; in dtpm_register()
429 return -EINVAL; in dtpm_register()
431 if (parent && parent->ops) in dtpm_register()
432 return -EINVAL; in dtpm_register()
435 return -EINVAL; in dtpm_register()
437 if (dtpm->ops && !(dtpm->ops->set_power_uw && in dtpm_register()
438 dtpm->ops->get_power_uw && in dtpm_register()
439 dtpm->ops->release)) in dtpm_register()
440 return -EINVAL; in dtpm_register()
442 pcz = powercap_register_zone(&dtpm->zone, pct, name, in dtpm_register()
443 parent ? &parent->zone : NULL, in dtpm_register()
452 list_add_tail(&dtpm->sibling, &parent->children); in dtpm_register()
453 dtpm->parent = parent; in dtpm_register()
460 pr_info("Registered dtpm node '%s' / %llu-%llu uW, \n", in dtpm_register()
461 dtpm->zone.name, dtpm->power_min, dtpm->power_max); in dtpm_register()
479 (*dtpm_descr)->init(*dtpm_descr); in dtpm_init()