Skip to content

Commit dd01480

Browse files
konradybcioGeorgi Djakov
authored andcommitted
interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients
Presumably due to the hardware being so complex, some nodes (or busses) have different (usually higher) requirements for bandwidth than what the usual calculations would suggest. Looking at the available downstream files, it seems like AB values are adjusted per-bus and IB values are adjusted per-node. With that in mind, introduce percentage-based coefficient struct members and use them in the calculations. One thing to note is that the IB coefficient is inverse (100/ib_percent) which feels a bit backwards, but it's necessary for precision.. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20230726-topic-icc_coeff-v4-1-c04b60caa467@linaro.org Signed-off-by: Georgi Djakov <djakov@kernel.org>
1 parent 0bb80ec commit dd01480

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

drivers/interconnect/qcom/icc-rpm.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
298298
*/
299299
static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_rate)
300300
{
301-
u64 agg_avg_rate, agg_rate;
301+
struct qcom_icc_provider *qp = to_qcom_provider(provider);
302+
u64 agg_avg_rate, agg_peak_rate, agg_rate;
302303
struct qcom_icc_node *qn;
303304
struct icc_node *node;
304305
int i;
@@ -315,8 +316,19 @@ static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_r
315316
else
316317
agg_avg_rate = qn->sum_avg[i];
317318

318-
agg_rate = max_t(u64, agg_avg_rate, qn->max_peak[i]);
319-
do_div(agg_rate, qn->buswidth);
319+
if (qp->ab_coeff) {
320+
agg_avg_rate = agg_avg_rate * qp->ab_coeff;
321+
agg_avg_rate = div_u64(agg_avg_rate, 100);
322+
}
323+
324+
if (qp->ib_coeff) {
325+
agg_peak_rate = qn->max_peak[i] * 100;
326+
agg_peak_rate = div_u64(qn->max_peak[i], qp->ib_coeff);
327+
} else {
328+
agg_peak_rate = qn->max_peak[i];
329+
}
330+
331+
agg_rate = max_t(u64, agg_avg_rate, agg_peak_rate);
320332

321333
agg_clk_rate[i] = max_t(u64, agg_clk_rate[i], agg_rate);
322334
}

drivers/interconnect/qcom/icc-rpm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ struct rpm_clk_resource {
4444
* @type: the ICC provider type
4545
* @regmap: regmap for QoS registers read/write access
4646
* @qos_offset: offset to QoS registers
47+
* @ab_coeff: a percentage-based coefficient for compensating the AB calculations
48+
* @ib_coeff: an inverse-percentage-based coefficient for compensating the IB calculations
4749
* @bus_clk_rate: bus clock rate in Hz
4850
* @bus_clk_desc: a pointer to a rpm_clk_resource description of bus clocks
4951
* @bus_clk: a pointer to a HLOS-owned bus clock
@@ -57,6 +59,8 @@ struct qcom_icc_provider {
5759
enum qcom_icc_type type;
5860
struct regmap *regmap;
5961
unsigned int qos_offset;
62+
u16 ab_coeff;
63+
u16 ib_coeff;
6064
u32 bus_clk_rate[QCOM_SMD_RPM_STATE_NUM];
6165
const struct rpm_clk_resource *bus_clk_desc;
6266
struct clk *bus_clk;
@@ -123,6 +127,8 @@ struct qcom_icc_desc {
123127
enum qcom_icc_type type;
124128
const struct regmap_config *regmap_cfg;
125129
unsigned int qos_offset;
130+
u16 ab_coeff;
131+
u16 ib_coeff;
126132
};
127133

128134
/* Valid for all bus types */

0 commit comments

Comments
 (0)