drm/xe/pcode: Fix pcode_try_request polling delays
Subsystems (2)
PATCH 1/1 drm/xe/pcode: Fix pcode_try_request polling delays
Honor OOB max for udelay. Also add a backoff for 'wait' as it exponentially increases so that doesn't overflow and also caps to a sane limit so we dont suffer overtly extended wait times as we progress.
v2: Fix accumnulation of 'wait' so 'slept' is accurate and
accounts for atomic-udelay clamping. (Sashiko)
--- drivers/gpu/drm/xe/xe_pcode.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_pcode.c +8 -4
@@ -146,6 +146,7 @@ int xe_pcode_read(struct xe_tile *tile, u32 mbox, u32 *val0, u32 *val1)return err; } +#define __XE_PCODE_WAIT_MAX_BACKOFF_100MS (100 * USEC_PER_MSEC)static int pcode_try_request (struct xe_tile *tile,u32 mbox,u32 request,u32 reply_mask,u32 reply,int *status,bool atomic,int timeout_us,bool locked)
@@ -164,11 +165,14 @@ static int pcode_try_request(struct xe_tile *tile, u32 mbox,if ((*status ==0 ) && ((request & reply_mask) == reply))return 0 ; -if (atomic) -udelay (wait); -else + wait =min_t (int, wait <<1 , __XE_PCODE_WAIT_MAX_BACKOFF_100MS); +if (atomic) { +/* don't overflow udelay */ + wait = min_t(int, wait, (MAX_UDELAY_MS * 1000); +udelay (wait)); + }else {usleep_range (wait, wait <<1 ); - wait <<=1 ; + } }return -ETIMEDOUT ;
base-commit: 2cd78713d917a02987f21b437561a5e1e13ddda2
Signature · 1 line
2.43.0
Patchwork
CI✗ CI.KUnit: failure for series starting with [1/1] drm/xe/pcode: Fix pcode_try_request polling delays
== Series Details ==
== Series Details ==
Series: series starting with [1/1] drm/xe/pcode: Fix pcode_try_request polling delays
URL : https://patchwork.freedesktop.org/series/177492/
State : failure
== Summary ==
+ trap cleanup EXIT
+ kunitconfigs=('/kernel/drivers/gpu/tests/.kunitconfig' '/kernel/drivers/gpu/drm/xe/.kunitconfig' '/kernel/drivers/gpu/drm/tests/.kunitconfig' '/kernel/drivers/gpu/drm/ttm/tests/.kunitconfig' '/kernel/drivers/dma-buf/.kunitconfig')
+ for kcfg in "${kunitconfigs[@]}"
+ [[ ! -f /kernel/drivers/gpu/tests/.kunitconfig ]]
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/tests/.kunitconfig
[18:19:01] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [18:19:07] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48 [18:19:27] Starting KUnit Kernel (1/1)... [18:19:27] ============================================================ Running tests with: $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [18:19:27] ================= gpu_buddy (14 subtests) ================== [18:19:27] [PASSED] gpu_test_buddy_alloc_limit [18:19:27] [PASSED] gpu_test_buddy_alloc_optimistic [18:19:27] [PASSED] gpu_test_buddy_alloc_pessimistic [18:19:27] [PASSED] gpu_test_buddy_alloc_pathological [18:19:27] [PASSED] gpu_test_buddy_alloc_contiguous [18:19:27] [PASSED] gpu_test_buddy_alloc_clear [18:19:27] [PASSED] gpu_test_buddy_alloc_range [18:19:28] [PASSED] gpu_test_buddy_alloc_range_bias [18:19:29] [PASSED] gpu_test_buddy_fragmentation_performance [18:19:29] [PASSED] gpu_test_buddy_dirty_tracker_performance [18:19:29] [PASSED] gpu_test_buddy_alloc_exceeds_max_order [18:19:29] [PASSED] gpu_test_buddy_offset_aligned_allocation [18:19:29] [PASSED] gpu_test_buddy_subtree_offset_alignment_stress [18:19:29] [PASSED] gpu_test_buddy_addr_to_block [18:19:29] ==================== [PASSED] gpu_buddy ==================== [18:19:29] ============================================================ [18:19:29] Testing complete. Ran 14 tests: passed: 14 [18:19:29] Elapsed time: 28.058s total, 5.172s configuring, 20.818s building, 2.034s running
+ for kcfg in "${kunitconfigs[@]}"
+ [[ ! -f /kernel/drivers/gpu/drm/xe/.kunitconfig ]]
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:In file included from ../include/linux/nodemask.h:92,
from ../include/linux/numa.h:6,
from ../include/linux/cpumask.h:15,
from ../include/linux/smp.h:13,
from ../include/linux/interrupt_rc.h:18,
from ../include/linux/spinlock.h:60,
from ../include/linux/sched.h:38,
from ../include/linux/delay.h:13,
from ../drivers/gpu/drm/xe/xe_pcode.c:8:../drivers/gpu/drm/xe/xe_pcode.c: In function ‘pcode_try_request’:../drivers/gpu/drm/xe/xe_pcode.c:171:71: error: expected ‘)’ before ‘;’ token
171 | wait = min_t(int, wait, (MAX_UDELAY_MS * 1000);
| ^../include/linux/minmax.h:86:38: note: in definition of macro ‘__cmp_once_unique’
86 | ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
| ^../include/linux/minmax.h:161:27: note: in expansion of macro ‘__cmp_once’
161 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
| ^~~~~~~~~~
../drivers/gpu/drm/xe/xe_pcode.c:171:32: note: in expansion of macro ‘min_t’
171 | wait = min_t(int, wait, (MAX_UDELAY_MS * 1000);
| ^~~~~../include/linux/minmax.h:86:37: note: to match this ‘(’
86 | ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
| ^../include/linux/minmax.h:89:9: note: in expansion of macro ‘__cmp_once_unique’
89 | __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
| ^~~~~~~~~~~~~~~~~
../include/linux/minmax.h:161:27: note: in expansion of macro ‘__cmp_once’
161 | #define min_t(type, x, y) __cmp_once(min, type, x, y)
| ^~~~~~~~~~../drivers/gpu/drm/xe/xe_pcode.c:171:32: note: in expansion of macro ‘min_t’
171 | wait = min_t(int, wait, (MAX_UDELAY_MS * 1000);
| ^~~~~
make[7]: *** [../scripts/Makefile.build:290: drivers/gpu/drm/xe/xe_pcode.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:572: drivers/gpu/drm/xe] Error 2 make[5]: *** [../scripts/Makefile.build:572: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:572: drivers/gpu] Error 2 make[3]: *** [../scripts/Makefile.build:572: drivers] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/kernel/Makefile:2244: .] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[18:19:30] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [18:19:32] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] drm/xe/pcode: syntax error in pcode_try_request() due to misplaced parenthesis --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/xe/pcode: syntax error in pcode_try_request() due to misplaced parenthesis --
commit 3c7a166635d4e14258beaf50fb0fab91cf40aa3f
Author: Alan Previn <[email protected]>
drm/xe/pcode: Fix pcode_try_request polling delays
This commit caps the exponential backoff delay in pcode_try_request() to 100ms and clamps the wait duration to the maximum allowed udelay value when polling in atomic context.
Quoted 14 lines
drivers/gpu/drm/xe/xe_pcode.c +1
-0@@ -146,6 +146,7 @@ int xe_pcode_read(struct xe_tile *tile, u32 mbox, u32 *val0, u32 *val1)return err; } +#define __XE_PCODE_WAIT_MAX_BACKOFF_100MS (100 * USEC_PER_MSEC)static int pcode_try_request (struct xe_tile *tile,u32 mbox,u32 request,u32 reply_mask,u32 reply,int *status,bool atomic,int timeout_us,bool locked)@@ -164,11 +165,14 @@ static int pcode_try_request(struct xe_tile *tile, u32 mbox,if ((*status ==0 ) && ((request & reply_mask) == reply))
drivers/gpu/drm/xe/xe_pcode.c static int pcode_try_request(struct xe_tile *tile, u32 mbox, · line 172
Quoted 10 lines
drivers/gpu/drm/xe/xe_pcode.c +5
-3return 0 ; -if (atomic) -udelay (wait); -else + wait =min_t (int, wait <<1 , __XE_PCODE_WAIT_MAX_BACKOFF_100MS); +if (atomic) { +/* don't overflow udelay */ + wait = min_t(int, wait, (MAX_UDELAY_MS * 1000); +udelay (wait));
[Severity: High]
Does this break compilation of drivers/gpu/drm/xe/xe_pcode.c? In the atomic branch of pcode_try_request(), the closing parenthesis for min_t() is missing before the semicolon and appears after udelay(wait) instead:
wait = min_t(int, wait, (MAX_UDELAY_MS * 1000)); udelay(wait);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1