interconnect: Add helpers for enabling/disabling a path
There is a repeated pattern in multiple drivers where they want to switch the bandwidth between zero and some other value. This is happening often in the suspend/resume callbacks. Let's add helper functions to enable and disable the path, so that callers don't have to take care of remembering the bandwidth values and handle this in the framework instead. With this patch the users can call icc_disable() and icc_enable() to lower their bandwidth request to zero and then restore it back to it's previous value. Suggested-by: Evan Green <evgreen@chromium.org> Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Link: https://lore.kernel.org/r/20200507120846.8354-1-georgi.djakov@linaro.org Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
This commit is contained in:
@@ -158,6 +158,7 @@ static struct icc_path *path_init(struct device *dev, struct icc_node *dst,
|
||||
hlist_add_head(&path->reqs[i].req_node, &node->req_list);
|
||||
path->reqs[i].node = node;
|
||||
path->reqs[i].dev = dev;
|
||||
path->reqs[i].enabled = true;
|
||||
/* reference to previous node was saved during path traversal */
|
||||
node = node->reverse;
|
||||
}
|
||||
@@ -249,9 +250,12 @@ static int aggregate_requests(struct icc_node *node)
|
||||
if (p->pre_aggregate)
|
||||
p->pre_aggregate(node);
|
||||
|
||||
hlist_for_each_entry(r, &node->req_list, req_node)
|
||||
hlist_for_each_entry(r, &node->req_list, req_node) {
|
||||
if (!r->enabled)
|
||||
continue;
|
||||
p->aggregate(node, r->tag, r->avg_bw, r->peak_bw,
|
||||
&node->avg_bw, &node->peak_bw);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -571,6 +575,39 @@ int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(icc_set_bw);
|
||||
|
||||
static int __icc_enable(struct icc_path *path, bool enable)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!path)
|
||||
return 0;
|
||||
|
||||
if (WARN_ON(IS_ERR(path) || !path->num_nodes))
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&icc_lock);
|
||||
|
||||
for (i = 0; i < path->num_nodes; i++)
|
||||
path->reqs[i].enabled = enable;
|
||||
|
||||
mutex_unlock(&icc_lock);
|
||||
|
||||
return icc_set_bw(path, path->reqs[0].avg_bw,
|
||||
path->reqs[0].peak_bw);
|
||||
}
|
||||
|
||||
int icc_enable(struct icc_path *path)
|
||||
{
|
||||
return __icc_enable(path, true);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(icc_enable);
|
||||
|
||||
int icc_disable(struct icc_path *path)
|
||||
{
|
||||
return __icc_enable(path, false);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(icc_disable);
|
||||
|
||||
/**
|
||||
* icc_get() - return a handle for path between two endpoints
|
||||
* @dev: the device requesting the path
|
||||
|
Reference in New Issue
Block a user