From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795797399; b=LDqeWncV71Kg+h8Q8k0brm26pxCkWvDP8LpQf+7dy7WQ47+HBcmdA8JJzJtuprkq1dR/ Z9n0kLE9wP/tFzXGqqLcw7TT4t+5EFUR2X9+zQ7wcPQUoQ7QIXT3CIoDZMJymNHZQXhCY A+gjE+Mj9zE2Bfmca0dFhxEV0G8wBb5y2ABMp+SH0I1gACrOIrttEDr2LDUASzNByDoDL QOJeksXY6RYsahU5oKZLmIrzIdTf1CKsmGPCVAWWEG4lvF3UJwRmdq/TY/DFLDcB33jWp NpUWFgzWEXiE4shtBrZ67XLBeDfyg3JFMoJ04QOwYFDZHGrXxYNNi96rSBCSzO+3vUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795797399; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=nyxEO58jG2eRS60AFB3FuIq+ozdE/sL6szu/SNOCHkU=; b=4qeLtaCd4IRxFvHDvcS7pGF1ESt9cTE+mf+SSnxU0yvB4WcZbDLWvHNZyFVfCo7zv0px zDUou+3nG9YH3WNP/xnqaZpZkIaSkX1OY8KKXT34H/MA5dgWXpyALhW33VhNkSmDAyN2d afz3RnGE+ztTMnvQUuhcqoluW7V+Hk7nNdPDoNNNiN/QBUCT/48dNl8Ysy4+1RF1ARMUp r/8+8nS7m3KQHSfn4f53iGYrf5unMMBq0fCuArAMC9Jb0XRNDNZHJ648WWAMpAUzq9wO8 6Jx08WHW/aLa20dQMdDvstmF6TQ81h0GCtgYXIJwvl36YwC3W59hi3gDufE/50GLtDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=RuXYDHbs; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90A10606A32A; Fri, 27 Nov 2026 16:36:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 90A10606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=RuXYDHbs Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C3E41570; Fri, 27 Nov 2026 08:36:34 -0800 (PST) Received: from [10.0.129.128] (e122027.cambridge.arm.com [10.0.129.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 93AB23F632; Fri, 27 Nov 2026 08:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1795797397; bh=EFyjz5K6FQSICQk4qVCWxpHVr1zg47R7gms4zh34/8Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=RuXYDHbs0klo6rqmTIFbWccVkoffHuEh+tKD+TdfkhY8pOhrThjyfqgwOEx3GX8i1 p2OlSLNY5CUwgHLb95vhb/+eyNx9NsndsVzI9o5La3N5rsszhDPzN1YIj/7GLwZKYN A/eh1lMd9TGmf/KM8gzt0BrzFQAdsyDdQxgdCNNM= Message-ID: <3970b78c-b72a-49ca-9125-75d242508a9d@arm.com> Date: Fri, 27 Nov 2026 16:36:26 +0000 X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 02/13] drm/panthor: Minor scheduler refactoring To: Ketil Johnsen , Boris Brezillon , Liviu Dudau , Akash Goel , Karunika Choo , Lukas Zapolskas , Chris Diamand , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Daniel Almeida , Alice Ryhl Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Florent Tomasin References: <20261116112601.3483649-1-ketil.johnsen@arm.com> <20261116112601.3483649-3-ketil.johnsen@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20261116112601.3483649-3-ketil.johnsen@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 16/11/2026 11:25, Ketil Johnsen wrote: > From: Florent Tomasin > > Refactor parts of the group scheduling logic into new helper functions. > This will simplify addition of the protected mode feature. > > Remove redundant assignments of csg_slot. > > Reviewed-by: Boris Brezillon > Signed-off-by: Florent Tomasin > Co-developed-by: Ketil Johnsen > Signed-off-by: Ketil Johnsen Reviewed-by: Steven Price > > --- > > v5: > - Actually handle error from csg_slot_prog_locked() > > v4: > - Handle error from csg_slot_prog_locked() > > v3: > - Use panthor_fw_csg_endpoint_req_update() (was rebase mistake) > - Function rename to tick_ctx_update_group_prio() > > v2: > - Moved option to ding only the CSG doorbell to later patch > --- > drivers/gpu/drm/panthor/panthor_sched.c | 135 +++++++++++++++--------- > 1 file changed, 83 insertions(+), 52 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c > index a343c5180e01e..d632fe1bf4db8 100644 > --- a/drivers/gpu/drm/panthor/panthor_sched.c > +++ b/drivers/gpu/drm/panthor/panthor_sched.c > @@ -2345,12 +2345,85 @@ tick_ctx_cleanup(struct panthor_scheduler *sched, > } > } > > +static void > +tick_ctx_evict_group(struct panthor_scheduler *sched, > + struct panthor_csg_slots_upd_ctx *upd_ctx, > + struct panthor_group *group) > +{ > + struct panthor_device *ptdev = sched->ptdev; > + > + if (drm_WARN_ON(&ptdev->base, group->csg_id < 0)) > + return; > + > + csgs_upd_ctx_queue_reqs(ptdev, upd_ctx, group->csg_id, > + group_can_run(group) ? > + CSG_STATE_SUSPEND : CSG_STATE_TERMINATE, > + CSG_STATE_MASK); > +} > + > +static void > +tick_ctx_update_group_prio(struct panthor_scheduler *sched, > + struct panthor_csg_slots_upd_ctx *upd_ctx, > + struct panthor_group *group, > + int new_csg_prio) > +{ > + struct panthor_device *ptdev = sched->ptdev; > + struct panthor_fw_csg_iface *csg_iface; > + struct panthor_csg_slot *csg_slot; > + > + if (group->csg_id < 0) > + return; > + > + csg_iface = panthor_fw_get_csg_iface(ptdev, group->csg_id); > + csg_slot = &sched->csg_slots[group->csg_id]; > + > + if (csg_slot->priority != new_csg_prio) { > + panthor_fw_csg_endpoint_req_update(ptdev, csg_iface, > + CSG_EP_REQ_PRIORITY(new_csg_prio), > + CSG_EP_REQ_PRIORITY_MASK); > + csgs_upd_ctx_queue_reqs(ptdev, upd_ctx, group->csg_id, > + csg_iface->output->ack ^ CSG_ENDPOINT_CONFIG, > + CSG_ENDPOINT_CONFIG); > + } > +} > + > +static int > +tick_ctx_schedule_group(struct panthor_scheduler *sched, > + struct panthor_csg_slots_upd_ctx *upd_ctx, > + struct panthor_group *group, > + int csg_id, int csg_prio) > +{ > + struct panthor_device *ptdev = sched->ptdev; > + struct panthor_fw_csg_iface *csg_iface = > + panthor_fw_get_csg_iface(ptdev, csg_id); > + int ret; > + > + ret = group_bind_locked(group, csg_id); > + if (ret) > + return ret; > + > + ret = csg_slot_prog_locked(ptdev, csg_id, csg_prio); > + if (ret) { > + group_unbind_locked(group); > + return ret; > + } > + > + csgs_upd_ctx_queue_reqs(ptdev, upd_ctx, csg_id, > + group->state == PANTHOR_CS_GROUP_SUSPENDED ? > + CSG_STATE_RESUME : CSG_STATE_START, > + CSG_STATE_MASK); > + csgs_upd_ctx_queue_reqs(ptdev, upd_ctx, csg_id, > + csg_iface->output->ack ^ CSG_ENDPOINT_CONFIG, > + CSG_ENDPOINT_CONFIG); > + > + return 0; > +} > + > static void > tick_ctx_apply(struct panthor_scheduler *sched, struct panthor_sched_tick_ctx *ctx) > { > struct panthor_group *group, *tmp; > struct panthor_device *ptdev = sched->ptdev; > - struct panthor_csg_slot *csg_slot; > int prio, new_csg_prio = MAX_CSG_PRIO, i; > u32 free_csg_slots = 0; > struct panthor_csg_slots_upd_ctx upd_ctx; > @@ -2360,44 +2433,13 @@ tick_ctx_apply(struct panthor_scheduler *sched, struct panthor_sched_tick_ctx *c > > for (prio = PANTHOR_CSG_PRIORITY_COUNT - 1; prio >= 0; prio--) { > /* Suspend or terminate evicted groups. */ > - list_for_each_entry(group, &ctx->old_groups[prio], run_node) { > - bool term = !group_can_run(group); > - int csg_id = group->csg_id; > - > - if (drm_WARN_ON(&ptdev->base, csg_id < 0)) > - continue; > - > - csg_slot = &sched->csg_slots[csg_id]; > - csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, > - term ? CSG_STATE_TERMINATE : CSG_STATE_SUSPEND, > - CSG_STATE_MASK); > - } > + list_for_each_entry(group, &ctx->old_groups[prio], run_node) > + tick_ctx_evict_group(sched, &upd_ctx, group); > > /* Update priorities on already running groups. */ > - list_for_each_entry(group, &ctx->groups[prio], run_node) { > - struct panthor_fw_csg_iface *csg_iface; > - int csg_id = group->csg_id; > - > - if (csg_id < 0) { > - new_csg_prio--; > - continue; > - } > - > - csg_slot = &sched->csg_slots[csg_id]; > - csg_iface = panthor_fw_get_csg_iface(ptdev, csg_id); > - if (csg_slot->priority == new_csg_prio) { > - new_csg_prio--; > - continue; > - } > - > - panthor_fw_csg_endpoint_req_update(ptdev, csg_iface, > - CSG_EP_REQ_PRIORITY(new_csg_prio), > - CSG_EP_REQ_PRIORITY_MASK); > - csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, > - csg_iface->output->ack ^ CSG_ENDPOINT_CONFIG, > - CSG_ENDPOINT_CONFIG); > - new_csg_prio--; > - } > + list_for_each_entry(group, &ctx->groups[prio], run_node) > + tick_ctx_update_group_prio(sched, &upd_ctx, group, > + new_csg_prio--); > } > > ret = csgs_upd_ctx_apply_locked(ptdev, &upd_ctx); > @@ -2425,34 +2467,23 @@ tick_ctx_apply(struct panthor_scheduler *sched, struct panthor_sched_tick_ctx *c > for (prio = PANTHOR_CSG_PRIORITY_COUNT - 1; prio >= 0; prio--) { > list_for_each_entry(group, &ctx->groups[prio], run_node) { > int csg_id = group->csg_id; > - struct panthor_fw_csg_iface *csg_iface; > + int csg_prio = new_csg_prio--; > > - if (csg_id >= 0) { > - new_csg_prio--; > + if (csg_id >= 0) > continue; > - } > > csg_id = ffs(free_csg_slots) - 1; > if (drm_WARN_ON(&ptdev->base, csg_id < 0)) > break; > > - csg_iface = panthor_fw_get_csg_iface(ptdev, csg_id); > - csg_slot = &sched->csg_slots[csg_id]; > - ret = group_bind_locked(group, csg_id); > + ret = tick_ctx_schedule_group(sched, &upd_ctx, group, > + csg_id, csg_prio); > if (ret) { > panthor_device_schedule_reset(ptdev); > ctx->csg_upd_failed_mask |= BIT(csg_id); > return; > } > > - csg_slot_prog_locked(ptdev, csg_id, new_csg_prio--); > - csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, > - group->state == PANTHOR_CS_GROUP_SUSPENDED ? > - CSG_STATE_RESUME : CSG_STATE_START, > - CSG_STATE_MASK); > - csgs_upd_ctx_queue_reqs(ptdev, &upd_ctx, csg_id, > - csg_iface->output->ack ^ CSG_ENDPOINT_CONFIG, > - CSG_ENDPOINT_CONFIG); > free_csg_slots &= ~BIT(csg_id); > } > }