dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: dri-devel@lists.freedesktop.org,
	Florent Tomasin <florent.tomasin@arm.com>,
	Heinrich Fink <hfink@snap.com>,
	kernel@collabora.com
Subject: Re: [PATCH v1 6/8] drm/panthor: Fix the logic that decides when to stop ticking
Date: Thu, 6 Nov 2025 16:29:48 +0000	[thread overview]
Message-ID: <50a6bd19-d8a7-4db5-b7c2-c4f0f52b6372@arm.com> (raw)
In-Reply-To: <20251106144656.1012274-7-boris.brezillon@collabora.com>

On 06/11/2025 14:46, Boris Brezillon wrote:
> When we have multiple active groups with the same priority, we need to
> keep ticking for the priority rotation to take place. If we don't do
> that, we might starve slots with lower priorities.
> 
> It's annoying to deal with that in tick_ctx_update_resched_target(),
> so let's add a ::stop_tick field to the tick context which is
> initialized to true, and downgraded to false as soon as we detect
> something that requires to tick to happen. This way we can complement
> the current logic with extra conditions if needed.
> 
> Fixes: de8548813824 ("drm/panthor: Add the scheduler logical block")
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>  drivers/gpu/drm/panthor/panthor_sched.c | 36 ++++++++++++-------------
>  1 file changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index 1eba56e7360d..7b164228af7b 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -1882,6 +1882,7 @@ struct panthor_sched_tick_ctx {
>  	struct panthor_vm *vms[MAX_CS_PER_CSG];
>  	u32 as_count;
>  	bool immediate_tick;
> +	bool stop_tick;
>  	u32 csg_upd_failed_mask;
>  };
>  
> @@ -1941,10 +1942,17 @@ tick_ctx_pick_groups_from_list(const struct panthor_scheduler *sched,
>  		if (!owned_by_tick_ctx)
>  			group_get(group);
>  
> -		list_move_tail(&group->run_node, &ctx->groups[group->priority]);
>  		ctx->group_count++;
> +
> +		/* If we have more than one active group with the same priority,
> +		 * we need to keep ticking to rotate the CSG priority.
> +		 */
>  		if (group_is_idle(group))
>  			ctx->idle_group_count++;
> +		else if (!list_empty(&ctx->groups[group->priority]))
> +			ctx->stop_tick = false;
> +
> +		list_move_tail(&group->run_node, &ctx->groups[group->priority]);
>  
>  		if (i == ctx->as_count)
>  			ctx->vms[ctx->as_count++] = group->vm;
> @@ -1996,6 +2004,7 @@ tick_ctx_init(struct panthor_scheduler *sched,
>  	memset(ctx, 0, sizeof(*ctx));
>  	csgs_upd_ctx_init(&upd_ctx);
>  
> +	ctx->stop_tick = true;
>  	ctx->min_priority = PANTHOR_CSG_PRIORITY_COUNT;
>  	for (i = 0; i < ARRAY_SIZE(ctx->groups); i++) {
>  		INIT_LIST_HEAD(&ctx->groups[i]);
> @@ -2308,32 +2317,21 @@ static u64
>  tick_ctx_update_resched_target(struct panthor_scheduler *sched,
>  			       const struct panthor_sched_tick_ctx *ctx)
>  {
> -	/* We had space left, no need to reschedule until some external event happens. */
> -	if (!tick_ctx_is_full(sched, ctx))
> -		goto no_tick;
> +	u64 resched_target;
>  
> -	/* If idle groups were scheduled, no need to wake up until some external
> -	 * event happens (group unblocked, new job submitted, ...).
> -	 */
> -	if (ctx->idle_group_count)
> +	if (ctx->stop_tick)
>  		goto no_tick;
>  
>  	if (drm_WARN_ON(&sched->ptdev->base, ctx->min_priority >= PANTHOR_CSG_PRIORITY_COUNT))
>  		goto no_tick;
>  
> -	/* If there are groups of the same priority waiting, we need to
> -	 * keep the scheduler ticking, otherwise, we'll just wait for
> -	 * new groups with higher priority to be queued.
> -	 */
> -	if (!list_empty(&sched->groups.runnable[ctx->min_priority])) {
> -		u64 resched_target = sched->last_tick + sched->tick_period;
> +	resched_target = sched->last_tick + sched->tick_period;
>  
> -		if (time_before64(sched->resched_target, sched->last_tick) ||
> -		    time_before64(resched_target, sched->resched_target))
> -			sched->resched_target = resched_target;
> +	if (time_before64(sched->resched_target, sched->last_tick) ||
> +	    time_before64(resched_target, sched->resched_target))
> +		sched->resched_target = resched_target;
>  
> -		return sched->resched_target - sched->last_tick;
> -	}
> +	return sched->resched_target - sched->last_tick;
>  
>  no_tick:
>  	sched->resched_target = U64_MAX;


  reply	other threads:[~2025-11-06 16:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06 14:46 [PATCH v1 0/8] drm/panthor: Misc scheduler fixes Boris Brezillon
2025-11-06 14:46 ` [PATCH v1 1/8] drm/panthor: Simplify group idleness tracking Boris Brezillon
2025-11-06 16:15   ` Steven Price
2025-11-06 14:46 ` [PATCH v1 2/8] drm/panthor: Don't try to enable extract events Boris Brezillon
2025-11-06 16:17   ` Steven Price
2025-11-06 14:46 ` [PATCH v1 3/8] drm/panthor: Fix the group priority rotation logic Boris Brezillon
2025-11-06 16:18   ` Steven Price
2025-11-06 16:30     ` Boris Brezillon
2025-11-06 14:46 ` [PATCH v1 4/8] drm/panthor: Fix the full_tick check Boris Brezillon
2025-11-06 16:20   ` Steven Price
2025-11-06 14:46 ` [PATCH v1 5/8] drm/panthor: Fix immediate ticking on a disabled tick Boris Brezillon
2025-11-06 16:23   ` Steven Price
2025-11-06 16:33     ` Boris Brezillon
2025-11-06 14:46 ` [PATCH v1 6/8] drm/panthor: Fix the logic that decides when to stop ticking Boris Brezillon
2025-11-06 16:29   ` Steven Price [this message]
2025-11-06 14:46 ` [PATCH v1 7/8] drm/panthor: Make sure we resume the tick when new jobs are submitted Boris Brezillon
2025-11-06 16:39   ` Steven Price
2025-11-06 14:46 ` [PATCH v1 8/8] drm/panthor: Kill panthor_sched_immediate_tick() Boris Brezillon
2025-11-06 16:44   ` Steven Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50a6bd19-d8a7-4db5-b7c2-c4f0f52b6372@arm.com \
    --to=steven.price@arm.com \
    --cc=adrian.larumbe@collabora.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=florent.tomasin@arm.com \
    --cc=hfink@snap.com \
    --cc=kernel@collabora.com \
    --cc=liviu.dudau@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox