Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: Move exponential sleep logic to helper

We want to reuse the same increased sleep logic in other places.
To avoid code duplication, move it to the helper.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260127193727.601-3-michal.wajdeczko@intel.com

+22 -4
+1 -4
drivers/gpu/drm/xe/xe_guc_submit.c
··· 1049 1049 return -ENODEV; 1050 1050 } 1051 1051 1052 - msleep(sleep_period_ms); 1053 - sleep_total_ms += sleep_period_ms; 1054 - if (sleep_period_ms < 64) 1055 - sleep_period_ms <<= 1; 1052 + sleep_total_ms += xe_sleep_exponential_ms(&sleep_period_ms, 64); 1056 1053 goto try_again; 1057 1054 } 1058 1055 }
+21
drivers/gpu/drm/xe/xe_sleep.h
··· 33 33 usleep_range(min_us, max_us); 34 34 } 35 35 36 + /** 37 + * xe_sleep_exponential_ms() - Sleep for a exponentially increased time. 38 + * @sleep_period_ms: current time in msec to sleep 39 + * @max_sleep_ms: maximum time in msec to sleep 40 + * 41 + * Sleep for the @sleep_period_ms and exponentially increase this time for the 42 + * next loop, unless reaching the @max_sleep_ms limit. 43 + * 44 + * Return: approximate time in msec the task was delayed. 45 + */ 46 + static inline unsigned int xe_sleep_exponential_ms(unsigned int *sleep_period_ms, 47 + unsigned int max_sleep_ms) 48 + { 49 + unsigned int delay_ms = *sleep_period_ms; 50 + unsigned int next_delay_ms = 2 * delay_ms; 51 + 52 + xe_sleep_relaxed_ms(delay_ms); 53 + *sleep_period_ms = min(next_delay_ms, max_sleep_ms); 54 + return delay_ms; 55 + } 56 + 36 57 #endif