Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

interconnect: Revert to previous config if any request fails

When consumers report their bandwidth needs with icc_set_bw(), it's
possible that the requested amount of bandwidth is not available or just
the new configuration fails to apply on some path. In this case revert to
the previous configuration and propagate the error back to the consumers
to let them know that bandwidth is not available, hardware is busy or
whatever error is returned by the interconnect platform driver.

Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Georgi Djakov and committed by
Greg Kroah-Hartman
dce6d406 ecfbed0c

+15 -2
+15 -2
drivers/interconnect/core.c
··· 414 414 int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) 415 415 { 416 416 struct icc_node *node; 417 + u32 old_avg, old_peak; 417 418 size_t i; 418 419 int ret; 419 420 420 - if (!path) 421 + if (!path || !path->num_nodes) 421 422 return 0; 422 423 423 424 mutex_lock(&icc_lock); 425 + 426 + old_avg = path->reqs[0].avg_bw; 427 + old_peak = path->reqs[0].peak_bw; 424 428 425 429 for (i = 0; i < path->num_nodes; i++) { 426 430 node = path->reqs[i].node; ··· 438 434 } 439 435 440 436 ret = apply_constraints(path); 441 - if (ret) 437 + if (ret) { 442 438 pr_debug("interconnect: error applying constraints (%d)\n", 443 439 ret); 440 + 441 + for (i = 0; i < path->num_nodes; i++) { 442 + node = path->reqs[i].node; 443 + path->reqs[i].avg_bw = old_avg; 444 + path->reqs[i].peak_bw = old_peak; 445 + aggregate_requests(node); 446 + } 447 + apply_constraints(path); 448 + } 444 449 445 450 mutex_unlock(&icc_lock); 446 451