1 // SPDX-License-Identifier: GPL-2.0
3 * Interconnect framework core driver
5 * Copyright (c) 2017-2019, Linaro Ltd.
6 * Author: Georgi Djakov <georgi.djakov@linaro.org>
9 #include <linux/debugfs.h>
10 #include <linux/device.h>
11 #include <linux/idr.h>
12 #include <linux/init.h>
13 #include <linux/interconnect.h>
14 #include <linux/interconnect-provider.h>
15 #include <linux/list.h>
16 #include <linux/mutex.h>
17 #include <linux/slab.h>
19 #include <linux/overflow.h>
23 #define CREATE_TRACE_POINTS
26 static DEFINE_IDR(icc_idr);
27 static LIST_HEAD(icc_providers);
28 static int providers_count;
29 static bool synced_state;
30 static DEFINE_MUTEX(icc_lock);
31 static DEFINE_MUTEX(icc_bw_lock);
32 static struct dentry *icc_debugfs_dir;
34 static void icc_summary_show_one(struct seq_file *s, struct icc_node *n)
39 seq_printf(s, "%-42s %12u %12u\n",
40 n->name, n->avg_bw, n->peak_bw);
43 static int icc_summary_show(struct seq_file *s, void *data)
45 struct icc_provider *provider;
47 seq_puts(s, " node tag avg peak\n");
48 seq_puts(s, "--------------------------------------------------------------------\n");
50 mutex_lock(&icc_lock);
52 list_for_each_entry(provider, &icc_providers, provider_list) {
55 list_for_each_entry(n, &provider->nodes, node_list) {
58 icc_summary_show_one(s, n);
59 hlist_for_each_entry(r, &n->req_list, req_node) {
60 u32 avg_bw = 0, peak_bw = 0;
70 seq_printf(s, " %-27s %12u %12u %12u\n",
71 dev_name(r->dev), r->tag, avg_bw, peak_bw);
76 mutex_unlock(&icc_lock);
80 DEFINE_SHOW_ATTRIBUTE(icc_summary);
82 static void icc_graph_show_link(struct seq_file *s, int level,
83 struct icc_node *n, struct icc_node *m)
85 seq_printf(s, "%s\"%d:%s\" -> \"%d:%s\"\n",
86 level == 2 ? "\t\t" : "\t",
87 n->id, n->name, m->id, m->name);
90 static void icc_graph_show_node(struct seq_file *s, struct icc_node *n)
92 seq_printf(s, "\t\t\"%d:%s\" [label=\"%d:%s",
93 n->id, n->name, n->id, n->name);
94 seq_printf(s, "\n\t\t\t|avg_bw=%ukBps", n->avg_bw);
95 seq_printf(s, "\n\t\t\t|peak_bw=%ukBps", n->peak_bw);
99 static int icc_graph_show(struct seq_file *s, void *data)
101 struct icc_provider *provider;
103 int cluster_index = 0;
106 seq_puts(s, "digraph {\n\trankdir = LR\n\tnode [shape = record]\n");
107 mutex_lock(&icc_lock);
109 /* draw providers as cluster subgraphs */
111 list_for_each_entry(provider, &icc_providers, provider_list) {
112 seq_printf(s, "\tsubgraph cluster_%d {\n", ++cluster_index);
114 seq_printf(s, "\t\tlabel = \"%s\"\n",
115 dev_name(provider->dev));
118 list_for_each_entry(n, &provider->nodes, node_list)
119 icc_graph_show_node(s, n);
121 /* draw internal links */
122 list_for_each_entry(n, &provider->nodes, node_list)
123 for (i = 0; i < n->num_links; ++i)
124 if (n->provider == n->links[i]->provider)
125 icc_graph_show_link(s, 2, n,
128 seq_puts(s, "\t}\n");
131 /* draw external links */
132 list_for_each_entry(provider, &icc_providers, provider_list)
133 list_for_each_entry(n, &provider->nodes, node_list)
134 for (i = 0; i < n->num_links; ++i)
135 if (n->provider != n->links[i]->provider)
136 icc_graph_show_link(s, 1, n,
139 mutex_unlock(&icc_lock);
144 DEFINE_SHOW_ATTRIBUTE(icc_graph);
146 static struct icc_node *node_find(const int id)
148 return idr_find(&icc_idr, id);
151 static struct icc_path *path_init(struct device *dev, struct icc_node *dst,
154 struct icc_node *node = dst;
155 struct icc_path *path;
158 path = kzalloc(struct_size(path, reqs, num_nodes), GFP_KERNEL);
160 return ERR_PTR(-ENOMEM);
162 path->num_nodes = num_nodes;
164 for (i = num_nodes - 1; i >= 0; i--) {
165 node->provider->users++;
166 hlist_add_head(&path->reqs[i].req_node, &node->req_list);
167 path->reqs[i].node = node;
168 path->reqs[i].dev = dev;
169 path->reqs[i].enabled = true;
170 /* reference to previous node was saved during path traversal */
171 node = node->reverse;
177 static struct icc_path *path_find(struct device *dev, struct icc_node *src,
178 struct icc_node *dst)
180 struct icc_path *path = ERR_PTR(-EPROBE_DEFER);
181 struct icc_node *n, *node = NULL;
182 struct list_head traverse_list;
183 struct list_head edge_list;
184 struct list_head visited_list;
188 INIT_LIST_HEAD(&traverse_list);
189 INIT_LIST_HEAD(&edge_list);
190 INIT_LIST_HEAD(&visited_list);
192 list_add(&src->search_list, &traverse_list);
196 list_for_each_entry_safe(node, n, &traverse_list, search_list) {
199 list_splice_init(&edge_list, &visited_list);
200 list_splice_init(&traverse_list, &visited_list);
203 for (i = 0; i < node->num_links; i++) {
204 struct icc_node *tmp = node->links[i];
207 path = ERR_PTR(-ENOENT);
211 if (tmp->is_traversed)
214 tmp->is_traversed = true;
216 list_add_tail(&tmp->search_list, &edge_list);
223 list_splice_init(&traverse_list, &visited_list);
224 list_splice_init(&edge_list, &traverse_list);
226 /* count the hops including the source */
229 } while (!list_empty(&traverse_list));
233 /* reset the traversed state */
234 list_for_each_entry_reverse(n, &visited_list, search_list)
235 n->is_traversed = false;
238 path = path_init(dev, dst, depth);
244 * We want the path to honor all bandwidth requests, so the average and peak
245 * bandwidth requirements from each consumer are aggregated at each node.
246 * The aggregation is platform specific, so each platform can customize it by
247 * implementing its own aggregate() function.
250 static int aggregate_requests(struct icc_node *node)
252 struct icc_provider *p = node->provider;
259 if (p->pre_aggregate)
260 p->pre_aggregate(node);
262 hlist_for_each_entry(r, &node->req_list, req_node) {
265 peak_bw = r->peak_bw;
270 p->aggregate(node, r->tag, avg_bw, peak_bw,
271 &node->avg_bw, &node->peak_bw);
273 /* during boot use the initial bandwidth as a floor value */
275 node->avg_bw = max(node->avg_bw, node->init_avg);
276 node->peak_bw = max(node->peak_bw, node->init_peak);
283 static int apply_constraints(struct icc_path *path)
285 struct icc_node *next, *prev = NULL;
286 struct icc_provider *p;
290 for (i = 0; i < path->num_nodes; i++) {
291 next = path->reqs[i].node;
294 /* both endpoints should be valid master-slave pairs */
295 if (!prev || (p != prev->provider && !p->inter_set)) {
300 /* set the constraints */
301 ret = p->set(prev, next);
311 int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
312 u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
315 *agg_peak = max(*agg_peak, peak_bw);
319 EXPORT_SYMBOL_GPL(icc_std_aggregate);
321 /* of_icc_xlate_onecell() - Translate function using a single index.
322 * @spec: OF phandle args to map into an interconnect node.
323 * @data: private data (pointer to struct icc_onecell_data)
325 * This is a generic translate function that can be used to model simple
326 * interconnect providers that have one device tree node and provide
327 * multiple interconnect nodes. A single cell is used as an index into
328 * an array of icc nodes specified in the icc_onecell_data struct when
329 * registering the provider.
331 struct icc_node *of_icc_xlate_onecell(struct of_phandle_args *spec,
334 struct icc_onecell_data *icc_data = data;
335 unsigned int idx = spec->args[0];
337 if (idx >= icc_data->num_nodes) {
338 pr_err("%s: invalid index %u\n", __func__, idx);
339 return ERR_PTR(-EINVAL);
342 return icc_data->nodes[idx];
344 EXPORT_SYMBOL_GPL(of_icc_xlate_onecell);
347 * of_icc_get_from_provider() - Look-up interconnect node
348 * @spec: OF phandle args to use for look-up
350 * Looks for interconnect provider under the node specified by @spec and if
351 * found, uses xlate function of the provider to map phandle args to node.
353 * Returns a valid pointer to struct icc_node_data on success or ERR_PTR()
356 struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec)
358 struct icc_node *node = ERR_PTR(-EPROBE_DEFER);
359 struct icc_node_data *data = NULL;
360 struct icc_provider *provider;
363 return ERR_PTR(-EINVAL);
365 mutex_lock(&icc_lock);
366 list_for_each_entry(provider, &icc_providers, provider_list) {
367 if (provider->dev->of_node == spec->np) {
368 if (provider->xlate_extended) {
369 data = provider->xlate_extended(spec, provider->data);
375 node = provider->xlate(spec, provider->data);
381 mutex_unlock(&icc_lock);
384 return ERR_CAST(node);
387 data = kzalloc(sizeof(*data), GFP_KERNEL);
389 return ERR_PTR(-ENOMEM);
395 EXPORT_SYMBOL_GPL(of_icc_get_from_provider);
397 static void devm_icc_release(struct device *dev, void *res)
399 icc_put(*(struct icc_path **)res);
402 struct icc_path *devm_of_icc_get(struct device *dev, const char *name)
404 struct icc_path **ptr, *path;
406 ptr = devres_alloc(devm_icc_release, sizeof(*ptr), GFP_KERNEL);
408 return ERR_PTR(-ENOMEM);
410 path = of_icc_get(dev, name);
413 devres_add(dev, ptr);
420 EXPORT_SYMBOL_GPL(devm_of_icc_get);
423 * of_icc_get_by_index() - get a path handle from a DT node based on index
424 * @dev: device pointer for the consumer device
425 * @idx: interconnect path index
427 * This function will search for a path between two endpoints and return an
428 * icc_path handle on success. Use icc_put() to release constraints when they
429 * are not needed anymore.
430 * If the interconnect API is disabled, NULL is returned and the consumer
431 * drivers will still build. Drivers are free to handle this specifically,
432 * but they don't have to.
434 * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
435 * when the API is disabled or the "interconnects" DT property is missing.
437 struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
439 struct icc_path *path;
440 struct icc_node_data *src_data, *dst_data;
441 struct device_node *np;
442 struct of_phandle_args src_args, dst_args;
445 if (!dev || !dev->of_node)
446 return ERR_PTR(-ENODEV);
451 * When the consumer DT node do not have "interconnects" property
452 * return a NULL path to skip setting constraints.
454 if (!of_property_present(np, "interconnects"))
458 * We use a combination of phandle and specifier for endpoint. For now
459 * lets support only global ids and extend this in the future if needed
460 * without breaking DT compatibility.
462 ret = of_parse_phandle_with_args(np, "interconnects",
463 "#interconnect-cells", idx * 2,
468 of_node_put(src_args.np);
470 ret = of_parse_phandle_with_args(np, "interconnects",
471 "#interconnect-cells", idx * 2 + 1,
476 of_node_put(dst_args.np);
478 src_data = of_icc_get_from_provider(&src_args);
480 if (IS_ERR(src_data)) {
481 dev_err_probe(dev, PTR_ERR(src_data), "error finding src node\n");
482 return ERR_CAST(src_data);
485 dst_data = of_icc_get_from_provider(&dst_args);
487 if (IS_ERR(dst_data)) {
488 dev_err_probe(dev, PTR_ERR(dst_data), "error finding dst node\n");
490 return ERR_CAST(dst_data);
493 mutex_lock(&icc_lock);
494 path = path_find(dev, src_data->node, dst_data->node);
495 mutex_unlock(&icc_lock);
497 dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path));
501 if (src_data->tag && src_data->tag == dst_data->tag)
502 icc_set_tag(path, src_data->tag);
504 path->name = kasprintf(GFP_KERNEL, "%s-%s",
505 src_data->node->name, dst_data->node->name);
508 path = ERR_PTR(-ENOMEM);
516 EXPORT_SYMBOL_GPL(of_icc_get_by_index);
519 * of_icc_get() - get a path handle from a DT node based on name
520 * @dev: device pointer for the consumer device
521 * @name: interconnect path name
523 * This function will search for a path between two endpoints and return an
524 * icc_path handle on success. Use icc_put() to release constraints when they
525 * are not needed anymore.
526 * If the interconnect API is disabled, NULL is returned and the consumer
527 * drivers will still build. Drivers are free to handle this specifically,
528 * but they don't have to.
530 * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
531 * when the API is disabled or the "interconnects" DT property is missing.
533 struct icc_path *of_icc_get(struct device *dev, const char *name)
535 struct device_node *np;
538 if (!dev || !dev->of_node)
539 return ERR_PTR(-ENODEV);
544 * When the consumer DT node do not have "interconnects" property
545 * return a NULL path to skip setting constraints.
547 if (!of_property_present(np, "interconnects"))
551 * We use a combination of phandle and specifier for endpoint. For now
552 * lets support only global ids and extend this in the future if needed
553 * without breaking DT compatibility.
556 idx = of_property_match_string(np, "interconnect-names", name);
561 return of_icc_get_by_index(dev, idx);
563 EXPORT_SYMBOL_GPL(of_icc_get);
566 * icc_set_tag() - set an optional tag on a path
567 * @path: the path we want to tag
568 * @tag: the tag value
570 * This function allows consumers to append a tag to the requests associated
571 * with a path, so that a different aggregation could be done based on this tag.
573 void icc_set_tag(struct icc_path *path, u32 tag)
580 mutex_lock(&icc_lock);
582 for (i = 0; i < path->num_nodes; i++)
583 path->reqs[i].tag = tag;
585 mutex_unlock(&icc_lock);
587 EXPORT_SYMBOL_GPL(icc_set_tag);
590 * icc_get_name() - Get name of the icc path
591 * @path: interconnect path
593 * This function is used by an interconnect consumer to get the name of the icc
596 * Returns a valid pointer on success, or NULL otherwise.
598 const char *icc_get_name(struct icc_path *path)
605 EXPORT_SYMBOL_GPL(icc_get_name);
608 * icc_set_bw() - set bandwidth constraints on an interconnect path
609 * @path: interconnect path
610 * @avg_bw: average bandwidth in kilobytes per second
611 * @peak_bw: peak bandwidth in kilobytes per second
613 * This function is used by an interconnect consumer to express its own needs
614 * in terms of bandwidth for a previously requested path between two endpoints.
615 * The requests are aggregated and each node is updated accordingly. The entire
616 * path is locked by a mutex to ensure that the set() is completed.
617 * The @path can be NULL when the "interconnects" DT properties is missing,
618 * which will mean that no constraints will be set.
620 * Returns 0 on success, or an appropriate error code otherwise.
622 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
624 struct icc_node *node;
625 u32 old_avg, old_peak;
632 if (WARN_ON(IS_ERR(path) || !path->num_nodes))
635 mutex_lock(&icc_bw_lock);
637 old_avg = path->reqs[0].avg_bw;
638 old_peak = path->reqs[0].peak_bw;
640 for (i = 0; i < path->num_nodes; i++) {
641 node = path->reqs[i].node;
643 /* update the consumer request for this path */
644 path->reqs[i].avg_bw = avg_bw;
645 path->reqs[i].peak_bw = peak_bw;
647 /* aggregate requests for this node */
648 aggregate_requests(node);
650 trace_icc_set_bw(path, node, i, avg_bw, peak_bw);
653 ret = apply_constraints(path);
655 pr_debug("interconnect: error applying constraints (%d)\n",
658 for (i = 0; i < path->num_nodes; i++) {
659 node = path->reqs[i].node;
660 path->reqs[i].avg_bw = old_avg;
661 path->reqs[i].peak_bw = old_peak;
662 aggregate_requests(node);
664 apply_constraints(path);
667 mutex_unlock(&icc_bw_lock);
669 trace_icc_set_bw_end(path, ret);
673 EXPORT_SYMBOL_GPL(icc_set_bw);
675 static int __icc_enable(struct icc_path *path, bool enable)
682 if (WARN_ON(IS_ERR(path) || !path->num_nodes))
685 mutex_lock(&icc_lock);
687 for (i = 0; i < path->num_nodes; i++)
688 path->reqs[i].enabled = enable;
690 mutex_unlock(&icc_lock);
692 return icc_set_bw(path, path->reqs[0].avg_bw,
693 path->reqs[0].peak_bw);
696 int icc_enable(struct icc_path *path)
698 return __icc_enable(path, true);
700 EXPORT_SYMBOL_GPL(icc_enable);
702 int icc_disable(struct icc_path *path)
704 return __icc_enable(path, false);
706 EXPORT_SYMBOL_GPL(icc_disable);
709 * icc_put() - release the reference to the icc_path
710 * @path: interconnect path
712 * Use this function to release the constraints on a path when the path is
713 * no longer needed. The constraints will be re-aggregated.
715 void icc_put(struct icc_path *path)
717 struct icc_node *node;
721 if (!path || WARN_ON(IS_ERR(path)))
724 ret = icc_set_bw(path, 0, 0);
726 pr_err("%s: error (%d)\n", __func__, ret);
728 mutex_lock(&icc_lock);
729 for (i = 0; i < path->num_nodes; i++) {
730 node = path->reqs[i].node;
731 hlist_del(&path->reqs[i].req_node);
732 if (!WARN_ON(!node->provider->users))
733 node->provider->users--;
735 mutex_unlock(&icc_lock);
737 kfree_const(path->name);
740 EXPORT_SYMBOL_GPL(icc_put);
742 static struct icc_node *icc_node_create_nolock(int id)
744 struct icc_node *node;
746 /* check if node already exists */
747 node = node_find(id);
751 node = kzalloc(sizeof(*node), GFP_KERNEL);
753 return ERR_PTR(-ENOMEM);
755 id = idr_alloc(&icc_idr, node, id, id + 1, GFP_KERNEL);
757 WARN(1, "%s: couldn't get idr\n", __func__);
768 * icc_node_create() - create a node
771 * Return: icc_node pointer on success, or ERR_PTR() on error
773 struct icc_node *icc_node_create(int id)
775 struct icc_node *node;
777 mutex_lock(&icc_lock);
779 node = icc_node_create_nolock(id);
781 mutex_unlock(&icc_lock);
785 EXPORT_SYMBOL_GPL(icc_node_create);
788 * icc_node_destroy() - destroy a node
791 void icc_node_destroy(int id)
793 struct icc_node *node;
795 mutex_lock(&icc_lock);
797 node = node_find(id);
799 idr_remove(&icc_idr, node->id);
800 WARN_ON(!hlist_empty(&node->req_list));
803 mutex_unlock(&icc_lock);
811 EXPORT_SYMBOL_GPL(icc_node_destroy);
814 * icc_link_create() - create a link between two nodes
815 * @node: source node id
816 * @dst_id: destination node id
818 * Create a link between two nodes. The nodes might belong to different
819 * interconnect providers and the @dst_id node might not exist (if the
820 * provider driver has not probed yet). So just create the @dst_id node
821 * and when the actual provider driver is probed, the rest of the node
824 * Return: 0 on success, or an error code otherwise
826 int icc_link_create(struct icc_node *node, const int dst_id)
828 struct icc_node *dst;
829 struct icc_node **new;
835 mutex_lock(&icc_lock);
837 dst = node_find(dst_id);
839 dst = icc_node_create_nolock(dst_id);
847 new = krealloc(node->links,
848 (node->num_links + 1) * sizeof(*node->links),
856 node->links[node->num_links++] = dst;
859 mutex_unlock(&icc_lock);
863 EXPORT_SYMBOL_GPL(icc_link_create);
866 * icc_node_add() - add interconnect node to interconnect provider
867 * @node: pointer to the interconnect node
868 * @provider: pointer to the interconnect provider
870 void icc_node_add(struct icc_node *node, struct icc_provider *provider)
872 if (WARN_ON(node->provider))
875 mutex_lock(&icc_lock);
876 mutex_lock(&icc_bw_lock);
878 node->provider = provider;
879 list_add_tail(&node->node_list, &provider->nodes);
881 /* get the initial bandwidth values and sync them with hardware */
882 if (provider->get_bw) {
883 provider->get_bw(node, &node->init_avg, &node->init_peak);
885 node->init_avg = INT_MAX;
886 node->init_peak = INT_MAX;
888 node->avg_bw = node->init_avg;
889 node->peak_bw = node->init_peak;
891 if (node->avg_bw || node->peak_bw) {
892 if (provider->pre_aggregate)
893 provider->pre_aggregate(node);
895 if (provider->aggregate)
896 provider->aggregate(node, 0, node->init_avg, node->init_peak,
897 &node->avg_bw, &node->peak_bw);
899 provider->set(node, node);
905 mutex_unlock(&icc_bw_lock);
906 mutex_unlock(&icc_lock);
908 EXPORT_SYMBOL_GPL(icc_node_add);
911 * icc_node_del() - delete interconnect node from interconnect provider
912 * @node: pointer to the interconnect node
914 void icc_node_del(struct icc_node *node)
916 mutex_lock(&icc_lock);
918 list_del(&node->node_list);
920 mutex_unlock(&icc_lock);
922 EXPORT_SYMBOL_GPL(icc_node_del);
925 * icc_nodes_remove() - remove all previously added nodes from provider
926 * @provider: the interconnect provider we are removing nodes from
928 * Return: 0 on success, or an error code otherwise
930 int icc_nodes_remove(struct icc_provider *provider)
932 struct icc_node *n, *tmp;
934 if (WARN_ON(IS_ERR_OR_NULL(provider)))
937 list_for_each_entry_safe_reverse(n, tmp, &provider->nodes, node_list) {
939 icc_node_destroy(n->id);
944 EXPORT_SYMBOL_GPL(icc_nodes_remove);
947 * icc_provider_init() - initialize a new interconnect provider
948 * @provider: the interconnect provider to initialize
950 * Must be called before adding nodes to the provider.
952 void icc_provider_init(struct icc_provider *provider)
954 WARN_ON(!provider->set);
956 INIT_LIST_HEAD(&provider->nodes);
958 EXPORT_SYMBOL_GPL(icc_provider_init);
961 * icc_provider_register() - register a new interconnect provider
962 * @provider: the interconnect provider to register
964 * Return: 0 on success, or an error code otherwise
966 int icc_provider_register(struct icc_provider *provider)
968 if (WARN_ON(!provider->xlate && !provider->xlate_extended))
971 mutex_lock(&icc_lock);
972 list_add_tail(&provider->provider_list, &icc_providers);
973 mutex_unlock(&icc_lock);
975 dev_dbg(provider->dev, "interconnect provider registered\n");
979 EXPORT_SYMBOL_GPL(icc_provider_register);
982 * icc_provider_deregister() - deregister an interconnect provider
983 * @provider: the interconnect provider to deregister
985 void icc_provider_deregister(struct icc_provider *provider)
987 mutex_lock(&icc_lock);
988 WARN_ON(provider->users);
990 list_del(&provider->provider_list);
991 mutex_unlock(&icc_lock);
993 EXPORT_SYMBOL_GPL(icc_provider_deregister);
995 static const struct of_device_id __maybe_unused ignore_list[] = {
996 { .compatible = "qcom,sc7180-ipa-virt" },
997 { .compatible = "qcom,sc8180x-ipa-virt" },
998 { .compatible = "qcom,sdx55-ipa-virt" },
999 { .compatible = "qcom,sm8150-ipa-virt" },
1000 { .compatible = "qcom,sm8250-ipa-virt" },
1004 static int of_count_icc_providers(struct device_node *np)
1006 struct device_node *child;
1009 for_each_available_child_of_node(np, child) {
1010 if (of_property_read_bool(child, "#interconnect-cells") &&
1011 likely(!of_match_node(ignore_list, child)))
1013 count += of_count_icc_providers(child);
1019 void icc_sync_state(struct device *dev)
1021 struct icc_provider *p;
1027 if (count < providers_count)
1030 mutex_lock(&icc_lock);
1031 mutex_lock(&icc_bw_lock);
1032 synced_state = true;
1033 list_for_each_entry(p, &icc_providers, provider_list) {
1034 dev_dbg(p->dev, "interconnect provider is in synced state\n");
1035 list_for_each_entry(n, &p->nodes, node_list) {
1036 if (n->init_avg || n->init_peak) {
1039 aggregate_requests(n);
1044 mutex_unlock(&icc_bw_lock);
1045 mutex_unlock(&icc_lock);
1047 EXPORT_SYMBOL_GPL(icc_sync_state);
1049 static int __init icc_init(void)
1051 struct device_node *root;
1053 /* Teach lockdep about lock ordering wrt. shrinker: */
1054 fs_reclaim_acquire(GFP_KERNEL);
1055 might_lock(&icc_bw_lock);
1056 fs_reclaim_release(GFP_KERNEL);
1058 root = of_find_node_by_path("/");
1060 providers_count = of_count_icc_providers(root);
1063 icc_debugfs_dir = debugfs_create_dir("interconnect", NULL);
1064 debugfs_create_file("interconnect_summary", 0444,
1065 icc_debugfs_dir, NULL, &icc_summary_fops);
1066 debugfs_create_file("interconnect_graph", 0444,
1067 icc_debugfs_dir, NULL, &icc_graph_fops);
1071 device_initcall(icc_init);