Loading drivers/platform/msm/msm_bus/msm_bus_rules.c +51 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,7 @@ static bool check_rule(struct rules_def *rule) ret = do_compare_op(src_field, rule->rule_ops.thresh[i], rule->rule_ops.op[i]); rule->rule_ops.curr_bw = src_field; if (rule->rule_ops.combo_op == OP_AND) { if (!ret) return ret; Loading Loading @@ -710,6 +711,56 @@ void msm_rule_unregister(int num_rules, struct bus_rule_type *rule, mutex_unlock(&msm_bus_rules_lock); } int msm_rule_query_bandwidth(struct bus_rule_type *rule, u64 *bw, struct notifier_block *nb) { struct rule_node_info *node = NULL; struct rules_def *node_rule; int ret = -ENXIO; if (!rule) { pr_err("%s: invalid rule pointer", __func__); return ret; } mutex_lock(&msm_bus_rules_lock); if (nb) { node = get_node(NB_ID, nb); if (!node) { pr_err("%s: Can't find node", __func__); goto exit_rule_not_found; } list_for_each_entry(node_rule, &node->node_rules, link) { if (comp_rules(&node_rule->rule_ops, rule) == 0) { *bw = node_rule->rule_ops.curr_bw; ret = 0; break; } } } else { list_for_each_entry(node, &node_list, link) { list_for_each_entry(node_rule, &node->node_rules, link) { if (comp_rules(&node_rule->rule_ops, rule) == 0) { *bw = node_rule->rule_ops.curr_bw; ret = 0; break; } } } } if (ret) pr_err("%s: can't find the rule", __func__); exit_rule_not_found: mutex_unlock(&msm_bus_rules_lock); return ret; } bool msm_rule_update(struct bus_rule_type *old_rule, struct bus_rule_type *new_rule, struct notifier_block *nb) Loading include/linux/msm_bus_rules.h +8 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ struct bus_rule_type { u64 dst_bw; int mode; void *client_data; u64 curr_bw; }; #if (defined(CONFIG_BUS_TOPOLOGY_ADHOC)) Loading @@ -63,6 +64,8 @@ bool msm_rule_update(struct bus_rule_type *old_rule, void msm_rule_evaluate_rules(int node); void print_rules_buf(char *buf, int count); bool msm_rule_are_rules_registered(void); int msm_rule_query_bandwidth(struct bus_rule_type *rule, u64 *bw, struct notifier_block *nb); #else static inline void msm_rule_register(int num_rules, struct bus_rule_type *rule, struct notifier_block *nb) Loading @@ -89,5 +92,10 @@ static inline bool msm_rule_update(struct bus_rule_type *old_rule, static inline void msm_rule_evaluate_rules(int node) { } static inline int msm_rule_query_bandwidth(struct bus_rule_type *rule, u64 *bw, struct notifier_block *nb) { return false; } #endif /* defined(CONFIG_BUS_TOPOLOGY_ADHOC) */ #endif /* _ARCH_ARM_MACH_MSM_BUS_RULES_H */ Loading
drivers/platform/msm/msm_bus/msm_bus_rules.c +51 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,7 @@ static bool check_rule(struct rules_def *rule) ret = do_compare_op(src_field, rule->rule_ops.thresh[i], rule->rule_ops.op[i]); rule->rule_ops.curr_bw = src_field; if (rule->rule_ops.combo_op == OP_AND) { if (!ret) return ret; Loading Loading @@ -710,6 +711,56 @@ void msm_rule_unregister(int num_rules, struct bus_rule_type *rule, mutex_unlock(&msm_bus_rules_lock); } int msm_rule_query_bandwidth(struct bus_rule_type *rule, u64 *bw, struct notifier_block *nb) { struct rule_node_info *node = NULL; struct rules_def *node_rule; int ret = -ENXIO; if (!rule) { pr_err("%s: invalid rule pointer", __func__); return ret; } mutex_lock(&msm_bus_rules_lock); if (nb) { node = get_node(NB_ID, nb); if (!node) { pr_err("%s: Can't find node", __func__); goto exit_rule_not_found; } list_for_each_entry(node_rule, &node->node_rules, link) { if (comp_rules(&node_rule->rule_ops, rule) == 0) { *bw = node_rule->rule_ops.curr_bw; ret = 0; break; } } } else { list_for_each_entry(node, &node_list, link) { list_for_each_entry(node_rule, &node->node_rules, link) { if (comp_rules(&node_rule->rule_ops, rule) == 0) { *bw = node_rule->rule_ops.curr_bw; ret = 0; break; } } } } if (ret) pr_err("%s: can't find the rule", __func__); exit_rule_not_found: mutex_unlock(&msm_bus_rules_lock); return ret; } bool msm_rule_update(struct bus_rule_type *old_rule, struct bus_rule_type *new_rule, struct notifier_block *nb) Loading
include/linux/msm_bus_rules.h +8 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ struct bus_rule_type { u64 dst_bw; int mode; void *client_data; u64 curr_bw; }; #if (defined(CONFIG_BUS_TOPOLOGY_ADHOC)) Loading @@ -63,6 +64,8 @@ bool msm_rule_update(struct bus_rule_type *old_rule, void msm_rule_evaluate_rules(int node); void print_rules_buf(char *buf, int count); bool msm_rule_are_rules_registered(void); int msm_rule_query_bandwidth(struct bus_rule_type *rule, u64 *bw, struct notifier_block *nb); #else static inline void msm_rule_register(int num_rules, struct bus_rule_type *rule, struct notifier_block *nb) Loading @@ -89,5 +92,10 @@ static inline bool msm_rule_update(struct bus_rule_type *old_rule, static inline void msm_rule_evaluate_rules(int node) { } static inline int msm_rule_query_bandwidth(struct bus_rule_type *rule, u64 *bw, struct notifier_block *nb) { return false; } #endif /* defined(CONFIG_BUS_TOPOLOGY_ADHOC) */ #endif /* _ARCH_ARM_MACH_MSM_BUS_RULES_H */