Message ID | 20230726-topic-icc_coeff-v1-1-31616960818c@linaro.org |
---|---|
State | New |
Headers | show |
Series | Fix up icc clock rate calculation on some platforms | expand |
Hi Konrad, kernel test robot noticed the following build warnings: [auto build test WARNING on 1e25dd7772483f477f79986d956028e9f47f990a] url: https://github.com/intel-lab-lkp/linux/commits/Konrad-Dybcio/interconnect-qcom-icc-rpm-Add-AB-IB-calculations-coefficients/20230727-002710 base: 1e25dd7772483f477f79986d956028e9f47f990a patch link: https://lore.kernel.org/r/20230726-topic-icc_coeff-v1-1-31616960818c%40linaro.org patch subject: [PATCH 1/4] interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20230729/202307291745.0JcdYvBz-lkp@intel.com/config) compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230729/202307291745.0JcdYvBz-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307291745.0JcdYvBz-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/interconnect/qcom/icc-rpm.c: In function 'qcom_icc_bus_aggregate': >> drivers/interconnect/qcom/icc-rpm.c:302:27: warning: variable 'agg_peak_rate' set but not used [-Wunused-but-set-variable] 302 | u64 agg_avg_rate, agg_peak_rate, agg_rate; | ^~~~~~~~~~~~~ vim +/agg_peak_rate +302 drivers/interconnect/qcom/icc-rpm.c 293 294 /** 295 * qcom_icc_bus_aggregate - calculate bus clock rates by traversing all nodes 296 * @provider: generic interconnect provider 297 * @agg_clk_rate: array containing the aggregated clock rates in kHz 298 */ 299 static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_rate) 300 { 301 struct qcom_icc_provider *qp = to_qcom_provider(provider); > 302 u64 agg_avg_rate, agg_peak_rate, agg_rate; 303 struct qcom_icc_node *qn; 304 struct icc_node *node; 305 u16 percent; 306 int i; 307 308 /* 309 * Iterate nodes on the provider, aggregate bandwidth requests for 310 * every bucket and convert them into bus clock rates. 311 */ 312 list_for_each_entry(node, &provider->nodes, node_list) { 313 qn = node->data; 314 for (i = 0; i < QCOM_SMD_RPM_STATE_NUM; i++) { 315 if (qn->channels) 316 agg_avg_rate = div_u64(qn->sum_avg[i], qn->channels); 317 else 318 agg_avg_rate = qn->sum_avg[i]; 319 320 percent = qp->ab_percent ? qp->ab_percent : 100; 321 agg_avg_rate = mult_frac(percent, agg_avg_rate, 100); 322 323 percent = qn->ib_percent ? qn->ib_percent : 100; 324 agg_peak_rate = mult_frac(percent, qn->max_peak[i], 100); 325 326 agg_rate = max_t(u64, agg_avg_rate, qn->max_peak[i]); 327 do_div(agg_rate, qn->buswidth); 328 329 agg_clk_rate[i] = max_t(u64, agg_clk_rate[i], agg_rate); 330 } 331 } 332 } 333
diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index 2c16917ba1fd..2de0e1dfe225 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -298,9 +298,11 @@ static int qcom_icc_bw_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, */ static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_rate) { - u64 agg_avg_rate, agg_rate; + struct qcom_icc_provider *qp = to_qcom_provider(provider); + u64 agg_avg_rate, agg_peak_rate, agg_rate; struct qcom_icc_node *qn; struct icc_node *node; + u16 percent; int i; /* @@ -315,6 +317,12 @@ static void qcom_icc_bus_aggregate(struct icc_provider *provider, u64 *agg_clk_r else agg_avg_rate = qn->sum_avg[i]; + percent = qp->ab_percent ? qp->ab_percent : 100; + agg_avg_rate = mult_frac(percent, agg_avg_rate, 100); + + percent = qn->ib_percent ? qn->ib_percent : 100; + agg_peak_rate = mult_frac(percent, qn->max_peak[i], 100); + agg_rate = max_t(u64, agg_avg_rate, qn->max_peak[i]); do_div(agg_rate, qn->buswidth); diff --git a/drivers/interconnect/qcom/icc-rpm.h b/drivers/interconnect/qcom/icc-rpm.h index eed3451af3e6..dbb3146a81c4 100644 --- a/drivers/interconnect/qcom/icc-rpm.h +++ b/drivers/interconnect/qcom/icc-rpm.h @@ -45,6 +45,7 @@ struct rpm_clk_resource { * @regmap: regmap for QoS registers read/write access * @qos_offset: offset to QoS registers * @bus_clk_rate: bus clock rate in Hz + * @ab_percent: a percentage-based coefficient for compensating the AB calculations * @bus_clk_desc: a pointer to a rpm_clk_resource description of bus clocks * @bus_clk: a pointer to a HLOS-owned bus clock * @intf_clks: a clk_bulk_data array of interface clocks @@ -58,6 +59,7 @@ struct qcom_icc_provider { struct regmap *regmap; unsigned int qos_offset; u32 bus_clk_rate[QCOM_SMD_RPM_STATE_NUM]; + u16 ab_percent; const struct rpm_clk_resource *bus_clk_desc; struct clk *bus_clk; struct clk_bulk_data *intf_clks; @@ -93,6 +95,7 @@ struct qcom_icc_qos { * @num_links: the total number of @links * @channels: number of channels at this node (e.g. DDR channels) * @buswidth: width of the interconnect between a node and the bus (bytes) + * @ib_percent: a percentage-based coefficient for compensating the IB calculations * @sum_avg: current sum aggregate value of all avg bw requests * @max_peak: current max aggregate value of all peak bw requests * @mas_rpm_id: RPM id for devices that are bus masters @@ -106,6 +109,7 @@ struct qcom_icc_node { u16 num_links; u16 channels; u16 buswidth; + u16 ib_percent; u64 sum_avg[QCOM_SMD_RPM_STATE_NUM]; u64 max_peak[QCOM_SMD_RPM_STATE_NUM]; int mas_rpm_id; @@ -123,6 +127,7 @@ struct qcom_icc_desc { enum qcom_icc_type type; const struct regmap_config *regmap_cfg; unsigned int qos_offset; + u16 ab_percent; }; /* Valid for all bus types */
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 downstream does (X%)*AB and IB/(Y%) which feels a bit backwards, especially given that the divisors for IB turn out to always be 25, 50, 200 making this a convenient conversion to 4x, 2x, 0.5x.. This commit uses the more sane, non-inverse approach. Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org> --- drivers/interconnect/qcom/icc-rpm.c | 10 +++++++++- drivers/interconnect/qcom/icc-rpm.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-)