[PATCH v2 21/28] drm/panthor: Request AW to yield GPU access on idle
From: Karunika Choo
Date: Tue Nov 10 2026 - 11:04:58 EST
v15 GPU introduces a YIELD_IDLE command/interrupt to signal an access
window to relinquish GPU access as soon as it is idle. With FW v2, the
GPU is immediately yielded when it detects the GPU is idle and the
YIELD_IDLE interrupt is raised.
For latency and CPU scheduling reasons, we want to avoid constantly
yielding the GPU the moment it goes idle when there is only a singular
access window requesting access. As such, we only send YIELD_IDLE when:
- The GPU is granted to an access window and there are other access
windows requesting GPU access.
- A new GPU_REQUEST was received and the currently active access window
was the singular requesting AW.
Signed-off-by: Karunika Choo <karunika.choo@xxxxxxx>
---
v2:
- Align with arbitration scheduler retry work changes
- Align with sched-to-AW interface changes.
.../panthor/arbitration/panthor_arbitration.h | 1 +
.../arbitration/panthor_arbitration_drv.c | 5 +++
.../arbitration/panthor_arbitration_sched.c | 34 ++++++++++++++++++-
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h
index 02e1debf1d75a..0fcaf393a7d33 100644
--- a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration.h
@@ -67,6 +67,7 @@ int panthor_arbitration_on_grant(struct panthor_arbitration *adev, u8 sched_id,
int panthor_arbitration_on_stop(struct panthor_arbitration *adev, u8 sched_id);
int panthor_arbitration_on_close(struct panthor_arbitration *adev, u8 sched_id);
+int panthor_arbitration_notify_yield_idle(struct panthor_arbitration *adev, u8 sched_id);
int panthor_arbitration_notify_err(struct panthor_arbitration *adev, u8 aw_id);
#endif
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c
index dc63e85ace3de..4bd558d1984e7 100644
--- a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_drv.c
@@ -303,6 +303,11 @@ int panthor_arbitration_on_close(struct panthor_arbitration *adev, u8 sched_id)
return panthor_partition_control_close_window(adev->pc[sched_id]);
}
+int panthor_arbitration_notify_yield_idle(struct panthor_arbitration *adev, u8 sched_id)
+{
+ return panthor_partition_control_yield_idle(adev->pc[sched_id]);
+}
+
int panthor_arbitration_notify_err(struct panthor_arbitration *adev, u8 aw_id)
{
int idx;
diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_sched.c b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_sched.c
index 16bd0fac2514e..f137b73deaa32 100644
--- a/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_sched.c
+++ b/drivers/gpu/drm/panthor/arbitration/panthor_arbitration_sched.c
@@ -53,6 +53,7 @@ struct panthor_arbitration_work {
enum panthor_arbitration_retry_work {
PANTHOR_ARB_WORK_STOP = 0,
PANTHOR_ARB_WORK_CLOSE,
+ PANTHOR_ARB_WORK_YIELD_IDLE,
PANTHOR_ARB_WORK_COUNT,
};
@@ -186,6 +187,17 @@ static void arb_sched_queue_retry_work(struct panthor_arbitration_sched *sched,
arb_sched_queue_work(sched, &sched->retry_work);
}
+static void arb_sched_yield_idle_locked(struct panthor_arbitration_sched *sched)
+{
+ int ret;
+
+ lockdep_assert_held(&sched->lock);
+
+ ret = panthor_arbitration_notify_yield_idle(to_adev(sched), sched->id);
+ if (ret == -EAGAIN)
+ arb_sched_queue_retry_work(sched, PANTHOR_ARB_WORK_YIELD_IDLE);
+}
+
static int __arb_sched_stop_locked(struct panthor_arbitration_sched *sched)
{
int ret;
@@ -382,6 +394,10 @@ static int arb_sched_next_locked(struct panthor_arbitration_sched *sched)
arb_sched_grant_locked(sched);
+ if (sched->phase == ARB_SCHED_PHASE_GRANTED &&
+ !kfifo_is_empty(&sched->queue))
+ arb_sched_yield_idle_locked(sched);
+
wake_up_all(&sched->waitqueue);
return 0;
@@ -431,6 +447,12 @@ static void arb_sched_retry_work(struct work_struct *work)
return;
switch (sched->phase) {
+ case ARB_SCHED_PHASE_IDLE:
+ case ARB_SCHED_PHASE_GRANTING:
+ case ARB_SCHED_PHASE_GRANTED:
+ if (test_bit(PANTHOR_ARB_WORK_YIELD_IDLE, work_tmp))
+ arb_sched_yield_idle_locked(sched);
+ break;
case ARB_SCHED_PHASE_STOPPING:
if (test_bit(PANTHOR_ARB_WORK_STOP, work_tmp))
arb_sched_stop_locked(sched);
@@ -551,8 +573,18 @@ int panthor_arbitration_sched_on_request(struct panthor_arbitration_sched *sched
* Grant timer for the current AW has previously expired, request it to
* yield the GPU.
*/
- if (sched->grant_previously_expired)
+ if (sched->grant_previously_expired) {
arb_sched_request_stop_locked(sched);
+ return 0;
+ }
+
+ /*
+ * GPU was previously granted to a lone requesting AW, YIELD_IDLE was
+ * not sent to it. Send YIELD_IDLE to it now that multiple AWs are
+ * requesting for the GPU.
+ */
+ if (sched->phase == ARB_SCHED_PHASE_GRANTED && kfifo_len(&sched->queue) == 1)
+ arb_sched_yield_idle_locked(sched);
return 0;
}
--
2.43.0