mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/panthor: ignore CS IRQs for uninitialized slots
@ 2026-08-11 14:33 Osama Abdelkader
  2026-08-11 14:55 ` Boris Brezillon
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Abdelkader @ 2026-08-11 14:33 UTC (permalink / raw)
  To: Boris Brezillon, Steven Price, Liviu Dudau, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Heiko Stuebner, dri-devel, linux-kernel
  Cc: Osama Abdelkader, stable

CS interrupts are reported through firmware-provided bits in the CSG
interface. sched_process_csg_irq_locked() iterates over those bits and
passes each CS ID to cs_slot_process_irq_locked().

panthor_fw_get_cs_iface() only bounds the CS ID against MAX_CS_PER_CSG,
while the firmware can expose fewer CS slots. If an IRQ bit is reported
for a slot beyond sched->cs_slot_count, the driver can fetch a
zero-initialized interface entry and dereference cs_iface->input.

Ignore IRQs for slots that were not exposed by the firmware. The CSG IRQ
acknowledgment is already updated from cs_irq_req before processing the
individual CS IRQs, so ignored bits are still acknowledged.

Fixes: de8548813824 ("drm/panthor: Add the scheduler logical block")
Cc: stable@vger.kernel.org
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
 drivers/gpu/drm/panthor/panthor_sched.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index 64749750e6ee..1e230936e99c 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -1705,6 +1705,9 @@ static bool cs_slot_process_irq_locked(struct panthor_device *ptdev,
 
 	lockdep_assert_held(&ptdev->scheduler->lock);
 
+	if (cs_id >= ptdev->scheduler->cs_slot_count)
+		return false;
+
 	cs_iface = panthor_fw_get_cs_iface(ptdev, csg_id, cs_id);
 	req = cs_iface->input->req;
 	ack = cs_iface->output->ack;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/panthor: ignore CS IRQs for uninitialized slots
  2026-08-11 14:33 [PATCH] drm/panthor: ignore CS IRQs for uninitialized slots Osama Abdelkader
@ 2026-08-11 14:55 ` Boris Brezillon
  0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2026-08-11 14:55 UTC (permalink / raw)
  To: Osama Abdelkader
  Cc: Steven Price, Liviu Dudau, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Heiko Stuebner,
	dri-devel, linux-kernel, stable

On Tue, 11 Aug 2026 16:33:18 +0200
Osama Abdelkader <osama.abdelkader@gmail.com> wrote:

> CS interrupts are reported through firmware-provided bits in the CSG
> interface. sched_process_csg_irq_locked() iterates over those bits and
> passes each CS ID to cs_slot_process_irq_locked().
> 
> panthor_fw_get_cs_iface() only bounds the CS ID against MAX_CS_PER_CSG,
> while the firmware can expose fewer CS slots. If an IRQ bit is reported
> for a slot beyond sched->cs_slot_count, the driver can fetch a
> zero-initialized interface entry and dereference cs_iface->input.
> 
> Ignore IRQs for slots that were not exposed by the firmware. The CSG IRQ
> acknowledgment is already updated from cs_irq_req before processing the
> individual CS IRQs, so ignored bits are still acknowledged.
> 
> Fixes: de8548813824 ("drm/panthor: Add the scheduler logical block")
> Cc: stable@vger.kernel.org
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> ---
>  drivers/gpu/drm/panthor/panthor_sched.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index 64749750e6ee..1e230936e99c 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -1705,6 +1705,9 @@ static bool cs_slot_process_irq_locked(struct panthor_device *ptdev,
>  
>  	lockdep_assert_held(&ptdev->scheduler->lock);
>  
> +	if (cs_id >= ptdev->scheduler->cs_slot_count)

	if (drm_WARN_ON_ONCE(&ptdev->base, cs_id >= ptdev->scheduler->cs_slot_count))

Since this is certainly not supposed to happen. Looks good otherwise.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> +		return false;
> +
>  	cs_iface = panthor_fw_get_cs_iface(ptdev, csg_id, cs_id);
>  	req = cs_iface->input->req;
>  	ack = cs_iface->output->ack;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-11 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-11 14:33 [PATCH] drm/panthor: ignore CS IRQs for uninitialized slots Osama Abdelkader
2026-08-11 14:55 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®