From: Boris Brezillon <boris.brezillon@collabora.com>
To: Chia-I Wu <olvaffe@gmail.com>
Cc: Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 06/11] drm/panthor: Prepare the scheduler logic for FW events in IRQ context
Date: Wed, 13 May 2026 10:29:41 +0200 [thread overview]
Message-ID: <20260513102941.7321cbc3@fedora> (raw)
In-Reply-To: <CAPaKu7RjHvRAYZDehSF9R_8T-uTrC9-NfsAPSOX0n=-2phunpg@mail.gmail.com>
On Tue, 12 May 2026 14:04:43 -0700
Chia-I Wu <olvaffe@gmail.com> wrote:
> On Tue, May 12, 2026 at 5:14 AM Boris Brezillon
> <boris.brezillon@collabora.com> wrote:
> >
> > Add a specific spinlock for events processing, and force processing
> > of events in the panthor_sched_report_fw_events() path rather than
> > deferring it to a work item. We also fast-track fence signalling by
> > making the job completion logic IRQ-safe.
> >
> > Note that it requires changing a couple spin_lock() into
> > spin_lock_irqsave() when those are taken inside a events_lock section.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> > drivers/gpu/drm/panthor/panthor_sched.c | 332 +++++++++++++++-----------------
> > 1 file changed, 155 insertions(+), 177 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> > index 5b34032deff8..fbf76b59b7ef 100644
> > --- a/drivers/gpu/drm/panthor/panthor_sched.c
> > +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> > @@ -177,18 +177,6 @@ struct panthor_scheduler {
> > */
> > struct work_struct sync_upd_work;
> >
> > - /**
> > - * @fw_events_work: Work used to process FW events outside the interrupt path.
> > - *
> > - * Even if the interrupt is threaded, we need any event processing
> > - * that require taking the panthor_scheduler::lock to be processed
> > - * outside the interrupt path so we don't block the tick logic when
> > - * it calls panthor_fw_{csg,wait}_wait_acks(). Since most of the
> > - * event processing requires taking this lock, we just delegate all
> > - * FW event processing to the scheduler workqueue.
> > - */
> > - struct work_struct fw_events_work;
> > -
> > /**
> > * @fw_events: Bitmask encoding pending FW events.
> > */
> If we process all fw events in the irq context, we can remove
> fw_events as well. More on this below.
Oops, forgot to remove this field, indeed.
> > @@ -254,6 +242,15 @@ struct panthor_scheduler {
> > struct list_head waiting;
> > } groups;
> >
> > + /**
> > + * @events_lock: Lock taken when processing events.
> > + *
> > + * This also needs to be taken when csg_slots are updated, to make sure
> > + * the event processing logic doesn't touch groups that have left the CSG
> > + * slot.
> > + */
> > + spinlock_t events_lock;
> > +
> > /**
> > * @csg_slots: FW command stream group slots.
> It looks like read access can use either lock (process context) or
> events_lock (irq context), while write access must use events_lock
> (process context). Can we put that into the comment, or if makes
> sense, enforce that with accessor functions?
You're right. I'll mention that updates to csg_slots[] must be done
with both the ::lock and ::events_lock held, while reads can be done
with any of them held.
>
>
> > */
> > @@ -676,9 +673,6 @@ struct panthor_group {
> > */
> > struct panthor_kernel_bo *protm_suspend_buf;
> >
> > - /** @sync_upd_work: Work used to check/signal job fences. */
> > - struct work_struct sync_upd_work;
> > -
> Can we make this a preparatory commit, where group_sync_upd_work is
> replaced by group_check_job_completion?
I'll try to split that up.
>
> Multiple things happen in this commit. I try to identify things that
> can be separate commits. If this does not make sense, feel free to
> ignore.
>
> > /** @tiler_oom_work: Work used to process tiler OOM events happening on this group. */
> > struct work_struct tiler_oom_work;
> >
[...]
> > /**
> > * panthor_sched_report_fw_events() - Report FW events to the scheduler.
> > * @ptdev: Device.
> > @@ -1902,8 +1953,19 @@ void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events)
> This can be renamed to panthor_sched_handle_fw_events.
It's not quite handling events though. For most of them, it's really
just deferring the processing to work items, SYNC_UPDATE is the
exception.
>
> > if (!ptdev->scheduler)
> > return;
> >
> > - atomic_or(events, &ptdev->scheduler->fw_events);
> > - sched_queue_work(ptdev->scheduler, fw_events);
> > + guard(spinlock_irqsave)(&ptdev->scheduler->events_lock);
> > +
> > + if (events & JOB_INT_GLOBAL_IF) {
> > + sched_process_global_irq_locked(ptdev);
> > + events &= ~JOB_INT_GLOBAL_IF;
> > + }
> > +
> > + while (events) {
> > + u32 csg_id = ffs(events) - 1;
> > +
> > + sched_process_csg_irq_locked(ptdev, csg_id);
> > + events &= ~BIT(csg_id);
> > + }
> This handles all fw events in the irq context. Are there concerns that
> it may take too long? I might be wrong, but it seems possible to
> handle only CSG_SYNC_UPDATE and defer the rest as before.
I started with just the SYNC_UPDATE processing done in the hard-irq
context, but after auditing the other stuff done in the handler, I
realized it's basically just deferring all actual processing to work
items. Yes, there's the overhead of demuxing the events from the
ack/req regs, but part of this is already done to get to SYNC_UPDATE
anyway, so at this point we're probably better off demuxing everything
and scheduling works for all kind of events.
I also compared the perfs between the two approaches (though I didn't
do as much testing as I did with the new version, so I might have
missed something), and it didn't seem to matter at all, because the
interrupts we receive the most are SYNC_UPDATE and IDLE events, and
those are at the same level.
next prev parent reply other threads:[~2026-05-13 8:29 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 11:37 [PATCH v2 00/11] drm/panthor: Reduce dma_fence signalling latency Boris Brezillon
2026-05-12 11:37 ` [PATCH v2 01/11] drm/panthor: Make panthor_irq::state a non-atomic field Boris Brezillon
2026-05-12 18:40 ` Chia-I Wu
2026-05-12 11:37 ` [PATCH v2 02/11] drm/panthor: Move the register accessors before the IRQ helpers Boris Brezillon
2026-05-12 18:41 ` Chia-I Wu
2026-05-12 11:37 ` [PATCH v2 03/11] drm/panthor: Replace the panthor_irq macro machinery by inline helpers Boris Brezillon
2026-05-12 18:58 ` Chia-I Wu
2026-05-13 8:03 ` Boris Brezillon
2026-05-13 16:46 ` Chia-I Wu
2026-05-12 11:37 ` [PATCH v2 04/11] drm/panthor: Extend the IRQ logic to allow fast/hard IRQ handlers Boris Brezillon
2026-05-12 19:11 ` Chia-I Wu
2026-05-13 8:09 ` Boris Brezillon
2026-05-13 17:06 ` Chia-I Wu
2026-05-13 17:30 ` Boris Brezillon
2026-05-13 18:17 ` Chia-I Wu
2026-05-12 11:37 ` [PATCH v2 05/11] drm/panthor: Make panthor_fw_{update,toggle}_reqs() callable from IRQ context Boris Brezillon
2026-05-12 19:29 ` Chia-I Wu
2026-05-12 19:29 ` [PATCH v2 05/11] drm/panthor: Make panthor_fw_{update, toggle}_reqs() " Chia-I Wu
2026-05-12 11:37 ` [PATCH v2 06/11] drm/panthor: Prepare the scheduler logic for FW events in " Boris Brezillon
2026-05-12 21:04 ` Chia-I Wu
2026-05-13 8:29 ` Boris Brezillon [this message]
2026-05-13 17:47 ` Chia-I Wu
2026-05-12 11:37 ` [PATCH v2 07/11] drm/panthor: Automate CSG IRQ processing at group unbind time Boris Brezillon
2026-05-12 21:16 ` Chia-I Wu
2026-05-14 14:17 ` Steven Price
2026-05-12 11:37 ` [PATCH v2 08/11] drm/panthor: Automatically enable interrupts in panthor_fw_wait_acks() Boris Brezillon
2026-05-12 21:55 ` Chia-I Wu
2026-05-13 8:42 ` Boris Brezillon
2026-05-13 17:14 ` Chia-I Wu
2026-05-14 14:25 ` Steven Price
2026-05-12 11:37 ` [PATCH v2 09/11] drm/panthor: Process FW events in IRQ context Boris Brezillon
2026-05-12 22:05 ` Chia-I Wu
2026-05-12 22:09 ` Chia-I Wu
2026-05-13 8:44 ` Boris Brezillon
2026-05-14 15:23 ` Steven Price
2026-05-12 11:37 ` [PATCH v2 10/11] drm/panthor: Use the irqsave variant of spin_lock in panthor_gpu_irq_handler() Boris Brezillon
2026-05-14 15:26 ` Steven Price
2026-05-12 11:37 ` [PATCH v2 11/11] drm/panthor: Process GPU events in IRQ context Boris Brezillon
2026-05-12 11:50 ` Boris Brezillon
2026-05-12 22:40 ` Chia-I Wu
2026-05-13 8:54 ` Boris Brezillon
2026-05-13 18:07 ` Chia-I Wu
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=20260513102941.7321cbc3@fedora \
--to=boris.brezillon@collabora.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=olvaffe@gmail.com \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.