diff mbox series

[RFT] interconnect: qcom: icc-rpm: Fix peak rate calculation

Message ID 20231205-qcom_icc_calc_rate-typo-v1-1-9d4378dcf53e@quicinc.com
State Accepted
Commit 9085b23b668ad5aca62df4f071b306a47152e6b3
Headers show
Series [RFT] interconnect: qcom: icc-rpm: Fix peak rate calculation | expand

Commit Message

Bjorn Andersson Dec. 5, 2023, 10:14 p.m. UTC
Per the commit message of commit 'dd014803f260 ("interconnect: qcom:
icc-rpm: Add AB/IB calculations coefficients")', the peak rate should be
100/ib_percent. But, in what looks like a typical typo, the numerator
value is discarded in the calculation.

Update the implementation to match the described intention.

Fixes: dd014803f260 ("interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients")
Cc: stable@vger.kernel.org
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
Spotted while reading the code, patch is untested.
---
 drivers/interconnect/qcom/icc-rpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 0f5f12ac05f36f117e793656c3f560625e927f1b
change-id: 20231205-qcom_icc_calc_rate-typo-a1542df4f222

Best regards,

Comments

Konrad Dybcio Dec. 6, 2023, 12:19 p.m. UTC | #1
On 12/5/23 23:14, Bjorn Andersson wrote:
> Per the commit message of commit 'dd014803f260 ("interconnect: qcom:
> icc-rpm: Add AB/IB calculations coefficients")', the peak rate should be
> 100/ib_percent. But, in what looks like a typical typo, the numerator
> value is discarded in the calculation.
> 
> Update the implementation to match the described intention.
> 
> Fixes: dd014803f260 ("interconnect: qcom: icc-rpm: Add AB/IB calculations coefficients")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
> ---
> Spotted while reading the code, patch is untested.
> ---
>   drivers/interconnect/qcom/icc-rpm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
> index fb54e78f8fd7..a8ed435f696c 100644
> --- a/drivers/interconnect/qcom/icc-rpm.c
> +++ b/drivers/interconnect/qcom/icc-rpm.c
> @@ -307,7 +307,7 @@ static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node
>   
>   	if (qn->ib_coeff) {
>   		agg_peak_rate = qn->max_peak[ctx] * 100;
> -		agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff);
> +		agg_peak_rate = div_u64(agg_peak_rate, qn->ib_coeff);
Oh fun.. I'dve assumed the compiler is smart enough to catch this

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
diff mbox series

Patch

diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c
index fb54e78f8fd7..a8ed435f696c 100644
--- a/drivers/interconnect/qcom/icc-rpm.c
+++ b/drivers/interconnect/qcom/icc-rpm.c
@@ -307,7 +307,7 @@  static u64 qcom_icc_calc_rate(struct qcom_icc_provider *qp, struct qcom_icc_node
 
 	if (qn->ib_coeff) {
 		agg_peak_rate = qn->max_peak[ctx] * 100;
-		agg_peak_rate = div_u64(qn->max_peak[ctx], qn->ib_coeff);
+		agg_peak_rate = div_u64(agg_peak_rate, qn->ib_coeff);
 	} else {
 		agg_peak_rate = qn->max_peak[ctx];
 	}