Skip to contentSkip to conversation

drm/panthor: Misc fixes

PATCH Applied Boris Brezillon 3 participants 9 messages Apr 4, 2025 – Apr 10, 2025

Subsystems (3)

v3 of 4 Applied Latest is v4 →

lore
Share & tools
lore

Boris Brezillon

author maintainer
#0 lore raw

v3 cover drm/panthor: Misc fixes

Hello,

This is a collection of fixes for bugs found while working on adding JM support to panthor. Those are not particularly tied to JM support and are worth having regardless.

Note that the last two don't have Fixes tag because they fix issues we can't really hit with the current implementation (no fault handling, and no shared irq line).

Changelog available in each patch if you're interested.

Regards,

Boris

Boris Brezillon (5):
drm/panthor: Fix GPU_COHERENCY_ACE[_LITE] definitions drm/panthor: Call panthor_gpu_coherency_init() after PM resume() drm/panthor: Update panthor_mmu::irq::mask when needed drm/panthor: Let IRQ handlers clear the interrupts themselves drm/panthor: Don't update MMU_INT_MASK in panthor_mmu_irq_handler()

 drivers/gpu/drm/panthor/panthor_device.c | 8 ++++----
 drivers/gpu/drm/panthor/panthor_device.h | 2 --
 drivers/gpu/drm/panthor/panthor_fw.c     | 2 ++
 drivers/gpu/drm/panthor/panthor_gpu.c    | 2 ++
 drivers/gpu/drm/panthor/panthor_mmu.c    | 9 ++++++++-
 drivers/gpu/drm/panthor/panthor_regs.h   | 4 ++--
 6 files changed, 18 insertions(+), 9 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v3 1/5 drm/panthor: Fix GPU_COHERENCY_ACE[_LITE] definitions

GPU_COHERENCY_ACE and GPU_COHERENCY_ACE_LITE definitions have been swapped.

Changes in v2:
- New patch

Changes in v3:
- Add Steve's R-b

Fixes 546b366600ef ("drm/panthor: Add GPU register definitions")
---
 drivers/gpu/drm/panthor/panthor_regs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/panthor/panthor_regs.h +2 -2
index b7b3b3add166..a7a323dc5cf9 100644
@@ -133,8 +133,8 @@
 #define GPU_COHERENCY_PROT_BIT(name)			BIT(GPU_COHERENCY_  ## name)
 
 #define GPU_COHERENCY_PROTOCOL				0x304
-#define   GPU_COHERENCY_ACE				0
-#define   GPU_COHERENCY_ACE_LITE			1
+#define   GPU_COHERENCY_ACE_LITE			0
+#define   GPU_COHERENCY_ACE				1
 #define   GPU_COHERENCY_NONE				31
 
 #define MCU_CONTROL					0x700
Signature · 1 line
2.49.0
maintainer Reviewed-by on v3 1/5
#2 lore raw

Re: [PATCH v3 1/5] drm/panthor: Fix GPU_COHERENCY_ACE[_LITE] definitions

Quoted 6 lines · Boris Brezillon

GPU_COHERENCY_ACE and GPU_COHERENCY_ACE_LITE definitions have been swapped.

Changes in v2:
- New patch

Quoted 7 lines

Changes in v3:
- Add Steve's R-b

Fixes 546b366600ef ("drm/panthor: Add GPU register definitions")

Best regards,
Liviu

Quoted 22 lines
---
 drivers/gpu/drm/panthor/panthor_regs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/panthor/panthor_regs.h +2 -2
index b7b3b3add166..a7a323dc5cf9 100644
@@ -133,8 +133,8 @@
 #define GPU_COHERENCY_PROT_BIT(name)			BIT(GPU_COHERENCY_  ## name)
 
 #define GPU_COHERENCY_PROTOCOL				0x304
-#define   GPU_COHERENCY_ACE				0
-#define   GPU_COHERENCY_ACE_LITE			1
+#define   GPU_COHERENCY_ACE_LITE			0
+#define   GPU_COHERENCY_ACE				1
 #define   GPU_COHERENCY_NONE				31
 
 #define MCU_CONTROL					0x700
Signature · 1 line
2.49.0
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
author maintainer
#3 lore raw

PATCH v3 2/5 drm/panthor: Call panthor_gpu_coherency_init() after PM resume()

In reply to Boris Brezillon

When the device is coherent, panthor_gpu_coherency_init() will read GPU_COHERENCY_FEATURES to make sure the GPU supports the ACE-Lite coherency protocol, which will fail if the clocks/power-domains are not enabled when the read is done. Move the panthor_gpu_coherency_init() call after the device has been resumed to prevent that.

Changes in v2:
- Add Liviu's R-b

Changes in v3:
- Add Steve's R-b

Fixes dd7db8d911a1 ("drm/panthor: Explicitly set the coherency mode")
---
 drivers/gpu/drm/panthor/panthor_device.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/panthor/panthor_device.c +4 -4
index a9da1d1eeb70..c73c1608d6e6 100644
@@ -171,10 +171,6 @@ int panthor_device_init(struct panthor_device *ptdev)
 	struct page *p;
 	int ret;
 
-	ret = panthor_gpu_coherency_init(ptdev);
-	if (ret)
-		return ret;
-
 	init_completion(&ptdev->unplug.done);
 	ret = drmm_mutex_init(&ptdev->base, &ptdev->unplug.lock);
 	if (ret)
@@ -247,6 +243,10 @@ int panthor_device_init(struct panthor_device *ptdev)
 	if (ret)
 		goto err_rpm_put;
 
+	ret = panthor_gpu_coherency_init(ptdev);
+	if (ret)
+		return ret;
+
 	ret = panthor_mmu_init(ptdev);
 	if (ret)
 		goto err_unplug_gpu;
Signature · 1 line
2.49.0
author maintainer
#4 lore raw

PATCH v3 3/5 drm/panthor: Update panthor_mmu::irq::mask when needed

In reply to Boris Brezillon

When we clear the faulty bits in the AS mask, we also need to update the panthor_mmu::irq::mask field otherwise our IRQ handler won't get called again until the GPU is reset.

Changes in v2:
- Add Liviu's R-b

Changes in v3:
- Add Steve's R-b

Fixes 647810ec2476 ("drm/panthor: Add the MMU/VM logical block")
---
 drivers/gpu/drm/panthor/panthor_mmu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/panthor/panthor_mmu.c +1 -0
index 12a02e28f50f..7cca97d298ea 100644
@@ -781,6 +781,7 @@ int panthor_vm_active(struct panthor_vm *vm)
 	if (ptdev->mmu->as.faulty_mask & panthor_mmu_as_fault_mask(ptdev, as)) {
 		gpu_write(ptdev, MMU_INT_CLEAR, panthor_mmu_as_fault_mask(ptdev, as));
 		ptdev->mmu->as.faulty_mask &= ~panthor_mmu_as_fault_mask(ptdev, as);
+		ptdev->mmu->irq.mask |= panthor_mmu_as_fault_mask(ptdev, as);
 		gpu_write(ptdev, MMU_INT_MASK, ~ptdev->mmu->as.faulty_mask);
 	}
 
Signature · 1 line
2.49.0
author maintainer
#5 lore raw

PATCH v3 4/5 drm/panthor: Let IRQ handlers clear the interrupts themselves

In reply to Boris Brezillon

MMU handler needs to be in control of the job interrupt clears because clearing the interrupt also unblocks the writer/reader that triggered the fault, and we don't want it to be unblocked until we've had a chance to process the IRQ.

Since clearing the clearing is just one line, let's make it explicit instead of doing it in the generic code path.

Note that this commit changes the existing behavior in that the MMU COMPLETED irqs are no longer cleared, which is fine because they are masked, so we're not risking an interrupt flood.

Changes in v3:
- Mention the fact we no longer clear MMU COMPLETED irqs
- Add Liviu's R-b

Changes in v2:
- Move the MMU_INT_CLEAR around

---
 drivers/gpu/drm/panthor/panthor_device.h | 2 --
 drivers/gpu/drm/panthor/panthor_fw.c     | 2 ++
 drivers/gpu/drm/panthor/panthor_gpu.c    | 2 ++
 drivers/gpu/drm/panthor/panthor_mmu.c    | 7 +++++++
 4 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/panthor/panthor_device.h +0 -2
index da6574021664..4c27b6d85f46 100644
@@ -383,8 +383,6 @@ static irqreturn_t panthor_ ## __name ## _irq_threaded_handler(int irq, void *da
 		if (!status)									\
 			break;									\
 												\
-		gpu_write(ptdev, __reg_prefix ## _INT_CLEAR, status);				\
-												\
 		__handler(ptdev, status);							\
 		ret = IRQ_HANDLED;								\
 	}											\
drivers/gpu/drm/panthor/panthor_fw.c +2 -0
index 0f52766a3120..446bb377b953 100644
@@ -1008,6 +1008,8 @@ static void panthor_fw_init_global_iface(struct panthor_device *ptdev)
 
 static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 status)
 {
+	gpu_write(ptdev, JOB_INT_CLEAR, status);
+
 	if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF))
 		ptdev->fw->booted = true;
 
drivers/gpu/drm/panthor/panthor_gpu.c +2 -0
index 671049020afa..32d678a0114e 100644
@@ -150,6 +150,8 @@ static void panthor_gpu_init_info(struct panthor_device *ptdev)
 
 static void panthor_gpu_irq_handler(struct panthor_device *ptdev, u32 status)
 {
+	gpu_write(ptdev, GPU_INT_CLEAR, status);
+
 	if (status & GPU_IRQ_FAULT) {
 		u32 fault_status = gpu_read(ptdev, GPU_FAULT_STATUS);
 		u64 address = ((u64)gpu_read(ptdev, GPU_FAULT_ADDR_HI) << 32) |
drivers/gpu/drm/panthor/panthor_mmu.c +7 -0
index 7cca97d298ea..0ba76982d45b 100644
@@ -1710,6 +1710,13 @@ static void panthor_mmu_irq_handler(struct panthor_device *ptdev, u32 status)
 			access_type, access_type_name(ptdev, fault_status),
 			source_id);
 
+		/* We don't handle VM faults at the moment, so let's just clear the
+		 * interrupt and let the writer/reader crash.
+		 * Note that COMPLETED irqs are never cleared, but this is fine
+		 * because they are always masked.
+		 */
+		gpu_write(ptdev, MMU_INT_CLEAR, mask);
+
 		/* Ignore MMU interrupts on this AS until it's been
 		 * re-enabled.
 		 */
Signature · 1 line
2.49.0
maintainer Reviewed-by on v3 4/5
#6 lore raw

Re: [PATCH v3 4/5] drm/panthor: Let IRQ handlers clear the interrupts themselves

Quoted 8 lines · Boris Brezillon

MMU handler needs to be in control of the job interrupt clears because clearing the interrupt also unblocks the writer/reader that triggered the fault, and we don't want it to be unblocked until we've had a chance to process the IRQ.

Since clearing the clearing is just one line, let's make it explicit instead of doing it in the generic code path.

Quoted 6 lines

Note that this commit changes the existing behavior in that the MMU COMPLETED irqs are no longer cleared, which is fine because they are masked, so we're not risking an interrupt flood.

Changes in v3:
- Mention the fact we no longer clear MMU COMPLETED irqs

Thanks!

Quoted 71 lines

- Add Liviu's R-b

Changes in v2:
- Move the MMU_INT_CLEAR around

---
 drivers/gpu/drm/panthor/panthor_device.h | 2 --
 drivers/gpu/drm/panthor/panthor_fw.c     | 2 ++
 drivers/gpu/drm/panthor/panthor_gpu.c    | 2 ++
 drivers/gpu/drm/panthor/panthor_mmu.c    | 7 +++++++
 4 files changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/panthor/panthor_device.h +0 -2
index da6574021664..4c27b6d85f46 100644
@@ -383,8 +383,6 @@ static irqreturn_t panthor_ ## __name ## _irq_threaded_handler(int irq, void *da
 		if (!status)									\
 			break;									\
 												\
-		gpu_write(ptdev, __reg_prefix ## _INT_CLEAR, status);				\
-												\
 		__handler(ptdev, status);							\
 		ret = IRQ_HANDLED;								\
 	}											\
drivers/gpu/drm/panthor/panthor_fw.c +2 -0
index 0f52766a3120..446bb377b953 100644
@@ -1008,6 +1008,8 @@ static void panthor_fw_init_global_iface(struct panthor_device *ptdev)
 
 static void panthor_job_irq_handler(struct panthor_device *ptdev, u32 status)
 {
+	gpu_write(ptdev, JOB_INT_CLEAR, status);
+
 	if (!ptdev->fw->booted && (status & JOB_INT_GLOBAL_IF))
 		ptdev->fw->booted = true;
 
drivers/gpu/drm/panthor/panthor_gpu.c +2 -0
index 671049020afa..32d678a0114e 100644
@@ -150,6 +150,8 @@ static void panthor_gpu_init_info(struct panthor_device *ptdev)
 
 static void panthor_gpu_irq_handler(struct panthor_device *ptdev, u32 status)
 {
+	gpu_write(ptdev, GPU_INT_CLEAR, status);
+
 	if (status & GPU_IRQ_FAULT) {
 		u32 fault_status = gpu_read(ptdev, GPU_FAULT_STATUS);
 		u64 address = ((u64)gpu_read(ptdev, GPU_FAULT_ADDR_HI) << 32) |
drivers/gpu/drm/panthor/panthor_mmu.c +7 -0
index 7cca97d298ea..0ba76982d45b 100644
@@ -1710,6 +1710,13 @@ static void panthor_mmu_irq_handler(struct panthor_device *ptdev, u32 status)
 			access_type, access_type_name(ptdev, fault_status),
 			source_id);
 
+		/* We don't handle VM faults at the moment, so let's just clear the
+		 * interrupt and let the writer/reader crash.
+		 * Note that COMPLETED irqs are never cleared, but this is fine
+		 * because they are always masked.
+		 */
+		gpu_write(ptdev, MMU_INT_CLEAR, mask);
+
 		/* Ignore MMU interrupts on this AS until it's been
 		 * re-enabled.
 		 */
author maintainer
#7 lore raw

PATCH v3 5/5 drm/panthor: Don't update MMU_INT_MASK in panthor_mmu_irq_handler()

In reply to Boris Brezillon

Interrupts are automatically unmasked in panthor_mmu_irq_threaded_handler() when the handler returns. Unmasking prematurely might generate spurious interrupts if the IRQ line is shared.

Changes in v2:
- New patch

Changes in v3:
- Add R-bs

---
 drivers/gpu/drm/panthor/panthor_mmu.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/panthor/panthor_mmu.c +0 -1
index 0ba76982d45b..dc173c6edde0 100644
@@ -1721,7 +1721,6 @@ static void panthor_mmu_irq_handler(struct panthor_device *ptdev, u32 status)
 		 * re-enabled.
 		 */
 		ptdev->mmu->irq.mask = new_int_mask;
-		gpu_write(ptdev, MMU_INT_MASK, new_int_mask);
 
 		if (ptdev->mmu->as.slots[as].vm)
 			ptdev->mmu->as.slots[as].vm->unhandled_fault = true;
Signature · 1 line
2.49.0
author maintainer Applied
#8 lore raw
In reply to Boris Brezillon
Quoted 14 lines · On Fri, 4 Apr 2025 10:09:28 +0200 Boris Brezillon…

Hello,

This is a collection of fixes for bugs found while working on adding JM support to panthor. Those are not particularly tied to JM support and are worth having regardless.

Note that the last two don't have Fixes tag because they fix issues we can't really hit with the current implementation (no fault handling, and no shared irq line).

Changelog available in each patch if you're interested.

Regards,

Quoted 8 lines

Boris

Boris Brezillon (5):
drm/panthor: Fix GPU_COHERENCY_ACE[_LITE] definitions drm/panthor: Call panthor_gpu_coherency_init() after PM resume() drm/panthor: Update panthor_mmu::irq::mask when needed drm/panthor: Let IRQ handlers clear the interrupts themselves drm/panthor: Don't update MMU_INT_MASK in panthor_mmu_irq_handler()

Queued to drm-misc-next.

Quoted 9 lines
 drivers/gpu/drm/panthor/panthor_device.c | 8 ++++----
 drivers/gpu/drm/panthor/panthor_device.h | 2 --
 drivers/gpu/drm/panthor/panthor_fw.c     | 2 ++
 drivers/gpu/drm/panthor/panthor_gpu.c    | 2 ++
 drivers/gpu/drm/panthor/panthor_mmu.c    | 9 ++++++++-
 drivers/gpu/drm/panthor/panthor_regs.h   | 4 ++--
 6 files changed, 18 insertions(+), 9 deletions(-)