mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
interconnect: qcom: Move bcm_div() to common code
This helper is useful for both SMD_RPM and RPMH code, extract it. Assisted-by: LLM Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Reviewed-by: Abel Vesa <abel.vesa@oss.qualcomm.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Link: https://patch.msgid.link/20260909-topic-icc_rpm_smd_qol-v1-1-6dc5b5e97626@oss.qualcomm.com Signed-off-by: Georgi Djakov <djakov@kernel.org>
This commit is contained in:
parent
cee9395acd
commit
51797517fa
|
|
@ -3,7 +3,6 @@
|
|||
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <asm/div64.h>
|
||||
#include <linux/interconnect-provider.h>
|
||||
#include <linux/list_sort.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -14,6 +13,7 @@
|
|||
#include <soc/qcom/tcs.h>
|
||||
|
||||
#include "bcm-voter.h"
|
||||
#include "icc-common.h"
|
||||
#include "icc-rpmh.h"
|
||||
|
||||
static LIST_HEAD(bcm_voters);
|
||||
|
|
@ -47,17 +47,6 @@ static int cmp_vcd(void *priv, const struct list_head *a, const struct list_head
|
|||
return bcm_a->aux_data.vcd - bcm_b->aux_data.vcd;
|
||||
}
|
||||
|
||||
static u64 bcm_div(u64 num, u32 base)
|
||||
{
|
||||
/* Ensure that small votes aren't lost. */
|
||||
if (num && num < base)
|
||||
return 1;
|
||||
|
||||
do_div(num, base);
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
/* BCMs with enable_mask use one-hot-encoding for on/off signaling */
|
||||
static void bcm_aggregate_mask(struct qcom_icc_bcm *bcm)
|
||||
{
|
||||
|
|
@ -99,20 +88,20 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)
|
|||
for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
|
||||
for (i = 0; i < bcm->num_nodes; i++) {
|
||||
node = bcm->nodes[i];
|
||||
temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,
|
||||
node->buswidth * node->channels);
|
||||
temp = qcom_bw_div(node->sum_avg[bucket] * bcm->aux_data.width,
|
||||
node->buswidth * node->channels);
|
||||
agg_avg[bucket] = max(agg_avg[bucket], temp);
|
||||
|
||||
temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,
|
||||
node->buswidth);
|
||||
temp = qcom_bw_div(node->max_peak[bucket] * bcm->aux_data.width,
|
||||
node->buswidth);
|
||||
agg_peak[bucket] = max(agg_peak[bucket], temp);
|
||||
}
|
||||
|
||||
temp = agg_avg[bucket] * bcm->vote_scale;
|
||||
bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);
|
||||
bcm->vote_x[bucket] = qcom_bw_div(temp, bcm->aux_data.unit);
|
||||
|
||||
temp = agg_peak[bucket] * bcm->vote_scale;
|
||||
bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
|
||||
bcm->vote_y[bucket] = qcom_bw_div(temp, bcm->aux_data.unit);
|
||||
}
|
||||
|
||||
if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&
|
||||
|
|
|
|||
|
|
@ -7,6 +7,15 @@
|
|||
#define __DRIVERS_INTERCONNECT_QCOM_ICC_COMMON_H__
|
||||
|
||||
#include <linux/interconnect-provider.h>
|
||||
#include <linux/math64.h>
|
||||
|
||||
static inline u64 qcom_bw_div(u64 num, u32 base)
|
||||
{
|
||||
if (num && num < base)
|
||||
return 1;
|
||||
|
||||
return div_u64(num, base);
|
||||
}
|
||||
|
||||
struct icc_node_data *qcom_icc_xlate_extended(const struct of_phandle_args *spec,
|
||||
void *data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user