[PATCH] drm/panthor: ignore CS IRQs for uninitialized slots

Osama Abdelkader <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
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: [email protected]
Signed-off-by: Osama Abdelkader <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.