Skip to content

Commit e85d0e0

Browse files
mbrost05gregkh
authored andcommitted
drm/xe: Use usleep_range for accurate long-running workload timeslicing
commit 80f9c60 upstream. msleep is not very accurate in terms of how long it actually sleeps, whereas usleep_range is precise. Replace the timeslice sleep for long-running workloads with the more accurate usleep_range to avoid jitter if the sleep period is less than 20ms. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Cc: stable@vger.kernel.org Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://patch.msgid.link/20251212182847.1683222-3-matthew.brost@intel.com (cherry picked from commit ca415c4) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a7229c1 commit e85d0e0

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

drivers/gpu/drm/xe/xe_guc_submit.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,24 @@ static u32 wq_space_until_wrap(struct xe_exec_queue *q)
670670
return (WQ_SIZE - q->guc->wqi_tail);
671671
}
672672

673+
static inline void relaxed_ms_sleep(unsigned int delay_ms)
674+
{
675+
unsigned long min_us, max_us;
676+
677+
if (!delay_ms)
678+
return;
679+
680+
if (delay_ms > 20) {
681+
msleep(delay_ms);
682+
return;
683+
}
684+
685+
min_us = mul_u32_u32(delay_ms, 1000);
686+
max_us = min_us + 500;
687+
688+
usleep_range(min_us, max_us);
689+
}
690+
673691
static int wq_wait_for_space(struct xe_exec_queue *q, u32 wqi_size)
674692
{
675693
struct xe_guc *guc = exec_queue_to_guc(q);
@@ -1559,7 +1577,7 @@ static void __guc_exec_queue_process_msg_suspend(struct xe_sched_msg *msg)
15591577
since_resume_ms;
15601578

15611579
if (wait_ms > 0 && q->guc->resume_time)
1562-
msleep(wait_ms);
1580+
relaxed_ms_sleep(wait_ms);
15631581

15641582
set_exec_queue_suspended(q);
15651583
disable_scheduling(q, false);

0 commit comments

Comments
 (0)