[PATCH] drm/i915/slpc: Balance the inc/dec for num_waiters

Anirban, Sk sk.anirban at intel.com
Sat Apr 26 08:54:03 UTC 2025


Hi Vinay,

On 26-04-2025 03:21, Vinay Belgaumkar wrote:
> As seen in some recent failures, SLPC num_waiters value is < 0.
> This happens because the inc/dec are not balanced. We should skip
> decrement for the same conditions as the increment. Currently, we
> do that for power saving profile mode. This patch also ensures that
> num_waiters is incremented in the case min_softlimit is at boost
> freq. It ensures that we don't reduce the frequency while this request
> is in flight.
>
> Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13598
> Cc: Sk Anirban <sk.anirban at intel.com>
> Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar at intel.com>
> ---
>   drivers/gpu/drm/i915/gt/intel_rps.c | 14 +++++++++++---
>   1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c b/drivers/gpu/drm/i915/gt/intel_rps.c
> index 8731f275fdd9..b609e3aa2122 100644
> --- a/drivers/gpu/drm/i915/gt/intel_rps.c
> +++ b/drivers/gpu/drm/i915/gt/intel_rps.c
> @@ -1003,6 +1003,10 @@ void intel_rps_dec_waiters(struct intel_rps *rps)
>   	if (rps_uses_slpc(rps)) {
>   		slpc = rps_to_slpc(rps);
>   
> +		/* Don't decrement num_waiters for req where increment was skipped */
> +		if (slpc->power_profile == SLPC_POWER_PROFILES_POWER_SAVING)
> +			return;
> +
>   		intel_guc_slpc_dec_waiters(slpc);
>   	} else {
>   		atomic_dec(&rps->num_waiters);
> @@ -1031,11 +1035,15 @@ void intel_rps_boost(struct i915_request *rq)
>   			if (slpc->power_profile == SLPC_POWER_PROFILES_POWER_SAVING)
>   				return;
>   
> -			if (slpc->min_freq_softlimit >= slpc->boost_freq)
> -				return;
> -
>   			/* Return if old value is non zero */
>   			if (!atomic_fetch_inc(&slpc->num_waiters)) {
> +				/*
> +				 * Skip queuing boost work if frequency is already boosted,
> +				 * but still increment num_waiters.
> +				 */
> +				if (slpc->min_freq_softlimit >= slpc->boost_freq)
> +					return;
> +
>   				GT_TRACE(rps_to_gt(rps), "boost fence:%llx:%llx\n",
>   					 rq->fence.context, rq->fence.seqno);
>   				queue_work(rps_to_gt(rps)->i915->unordered_wq,
Tested on DG2, working as expected.
Reviewed-by: Sk Anirban <sk.anirban at intel.com>


More information about the dri-devel mailing list