interconnect: qcom: Prevent duplicate BCMs being added to commit list

Having the same node being added to bcm voter commit list will result
in an infinite loop when walking through the list. Prevent the same
node from being added multiple times by checking bcm->list and
clean up commit list after sending the commands to RPMh.

Change-Id: Ie210437df43efd537bdcb0143b03423964ac3840
Signed-off-by: David Dai <daidavid1@codeaurora.org>
This commit is contained in:
David Dai 2019-11-14 15:40:51 -08:00
commit f1441eef72

View file

@ -211,7 +211,8 @@ void qcom_icc_bcm_voter_add(struct bcm_voter *voter, struct qcom_icc_bcm *bcm)
return;
mutex_lock(&voter->lock);
list_add_tail(&bcm->list, &voter->commit_list);
if (list_empty(&bcm->list))
list_add_tail(&bcm->list, &voter->commit_list);
if (list_empty(&bcm->ws_list))
list_add_tail(&bcm->ws_list, &voter->ws_list);
@ -280,6 +281,9 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
goto out;
}
list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list)
list_del_init(&bcm->list);
INIT_LIST_HEAD(&voter->commit_list);
list_for_each_entry_safe(bcm, bcm_tmp, &voter->ws_list, ws_list) {
@ -322,6 +326,9 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
}
out:
list_for_each_entry_safe(bcm, bcm_tmp, &voter->commit_list, list)
list_del_init(&bcm->list);
INIT_LIST_HEAD(&voter->commit_list);
mutex_unlock(&voter->lock);
return ret;