[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5d1c7066-33a8-4347-a15d-c600bf847dc8@oss.qualcomm.com>
Date: Thu, 22 Jan 2026 21:21:39 +0100
From: Konrad Dybcio <konrad.dybcio@....qualcomm.com>
To: Gabor Juhos <j4g8y7@...il.com>, Ulf Hansson <ulf.hansson@...aro.org>,
Konrad Dybcio <konradybcio@...nel.org>,
Bjorn Andersson <andersson@...nel.org>
Cc: linux-arm-msm@...r.kernel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pmdomain: qcom: rpmpd: fix off-by-one error in clamping
to the highest state
On 1/22/26 6:20 PM, Gabor Juhos wrote:
> As it is indicated by the comment, the rpmpd_aggregate_corner() function
> tries to clamp the state to the highest corner/level supported by the
> given power domain, however the calculation of the highest state contains
> an off-by-one error.
>
> The 'max_state' member of the 'rpmpd' structure indicates the highest
> corner/level, and as such it does not needs to be decremented.
>
> Change the code to use the 'max_state' value directly to avoid the error.
>
> Fixes: 98c8b3efacae ("soc: qcom: rpmpd: Add sync_state")
> Signed-off-by: Gabor Juhos <j4g8y7@...il.com>
> ---
> drivers/pmdomain/qcom/rpmpd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/qcom/rpmpd.c b/drivers/pmdomain/qcom/rpmpd.c
> index f8580ec0f73785544aeb6f686438f39b477d134d..98ab4f9ea9bff431614739f37cd32b7b3bb407e4 100644
> --- a/drivers/pmdomain/qcom/rpmpd.c
> +++ b/drivers/pmdomain/qcom/rpmpd.c
> @@ -1001,7 +1001,7 @@ static int rpmpd_aggregate_corner(struct rpmpd *pd)
>
> /* Clamp to the highest corner/level if sync_state isn't done yet */
> if (!pd->state_synced)
> - this_active_corner = this_sleep_corner = pd->max_state - 1;
> + this_active_corner = this_sleep_corner = pd->max_state;
Great catch, I copypastad it from the rpm_h_pd driver where a
similar variable represents level _count_
Reviewed-by: Konrad Dybcio <konrad.dybcio@....qualcomm.com>
Konrad
Powered by blists - more mailing lists