* [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT
@ 2026-03-04 8:56 Maarten Lankhorst
2026-03-04 8:58 ` Hogander, Jouni
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Maarten Lankhorst @ 2026-03-04 8:56 UTC (permalink / raw)
To: dri-devel
Cc: intel-xe, Jouni Högander, Maarten Lankhorst,
kernel test robot
Fix a compile error in the kunit tests when CONFIG_PREEMPT_RT is
enabled, and the normal mutex is converted into a rtmutex.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202602261547.3bM6yVAS-lkp@intel.com/
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
Changes since v1:
- Use the correct locking primitive (Jouni)
drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
index d468f83220720..f3103307b5df9 100644
--- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
+++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
@@ -222,13 +222,13 @@ static void ttm_bo_reserve_interrupted(struct kunit *test)
KUNIT_FAIL(test, "Couldn't create ttm bo reserve task\n");
/* Take a lock so the threaded reserve has to wait */
- mutex_lock(&bo->base.resv->lock.base);
+ dma_resv_lock(bo->base.resv, NULL);
wake_up_process(task);
msleep(20);
err = kthread_stop(task);
- mutex_unlock(&bo->base.resv->lock.base);
+ dma_resv_unlock(bo->base.resv);
KUNIT_ASSERT_EQ(test, err, -ERESTARTSYS);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT
2026-03-04 8:56 [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT Maarten Lankhorst
@ 2026-03-04 8:58 ` Hogander, Jouni
2026-03-04 9:25 ` Maarten Lankhorst
2026-03-05 3:40 ` Claude review: " Claude Code Review Bot
2026-03-05 3:40 ` Claude Code Review Bot
2 siblings, 1 reply; 5+ messages in thread
From: Hogander, Jouni @ 2026-03-04 8:58 UTC (permalink / raw)
To: dev@lankhorst.se, dri-devel@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org, lkp
On Wed, 2026-03-04 at 09:56 +0100, Maarten Lankhorst wrote:
> Fix a compile error in the kunit tests when CONFIG_PREEMPT_RT is
> enabled, and the normal mutex is converted into a rtmutex.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes:
> https://lore.kernel.org/oe-kbuild-all/202602261547.3bM6yVAS-lkp@intel.com/
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
> ---
> Changes since v1:
> - Use the correct locking primitive (Jouni)
>
> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> index d468f83220720..f3103307b5df9 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> @@ -222,13 +222,13 @@ static void ttm_bo_reserve_interrupted(struct
> kunit *test)
> KUNIT_FAIL(test, "Couldn't create ttm bo reserve
> task\n");
>
> /* Take a lock so the threaded reserve has to wait */
> - mutex_lock(&bo->base.resv->lock.base);
> + dma_resv_lock(bo->base.resv, NULL);
>
> wake_up_process(task);
> msleep(20);
> err = kthread_stop(task);
>
> - mutex_unlock(&bo->base.resv->lock.base);
> + dma_resv_unlock(bo->base.resv);
>
> KUNIT_ASSERT_EQ(test, err, -ERESTARTSYS);
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT
2026-03-04 8:58 ` Hogander, Jouni
@ 2026-03-04 9:25 ` Maarten Lankhorst
0 siblings, 0 replies; 5+ messages in thread
From: Maarten Lankhorst @ 2026-03-04 9:25 UTC (permalink / raw)
To: Hogander, Jouni, dri-devel@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org, lkp
Hey,
Den 2026-03-04 kl. 09:58, skrev Hogander, Jouni:
> On Wed, 2026-03-04 at 09:56 +0100, Maarten Lankhorst wrote:
>> Fix a compile error in the kunit tests when CONFIG_PREEMPT_RT is
>> enabled, and the normal mutex is converted into a rtmutex.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Closes:
>> https://lore.kernel.org/oe-kbuild-all/202602261547.3bM6yVAS-lkp@intel.com/
>> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
>
> Reviewed-by: Jouni Högander <jouni.hogander@intel.com>
Thanks, tested if UML was still passing and it does.
./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/ttm/tests/.kunitconfig
....
[10:06:16] [PASSED] ttm_bo_reserve_interrupted
Will wait for CI kunit results and then push.
>
>> ---
>> Changes since v1:
>> - Use the correct locking primitive (Jouni)
>>
>> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> index d468f83220720..f3103307b5df9 100644
>> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
>> @@ -222,13 +222,13 @@ static void ttm_bo_reserve_interrupted(struct
>> kunit *test)
>> KUNIT_FAIL(test, "Couldn't create ttm bo reserve
>> task\n");
>>
>> /* Take a lock so the threaded reserve has to wait */
>> - mutex_lock(&bo->base.resv->lock.base);
>> + dma_resv_lock(bo->base.resv, NULL);
>>
>> wake_up_process(task);
>> msleep(20);
>> err = kthread_stop(task);
>>
>> - mutex_unlock(&bo->base.resv->lock.base);
>> + dma_resv_unlock(bo->base.resv);
>>
>> KUNIT_ASSERT_EQ(test, err, -ERESTARTSYS);
>> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Claude review: drm/ttm/tests: Fix build failure on PREEMPT_RT
2026-03-04 8:56 [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT Maarten Lankhorst
2026-03-04 8:58 ` Hogander, Jouni
@ 2026-03-05 3:40 ` Claude Code Review Bot
2026-03-05 3:40 ` Claude Code Review Bot
2 siblings, 0 replies; 5+ messages in thread
From: Claude Code Review Bot @ 2026-03-05 3:40 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Problem:** The test `ttm_bo_reserve_interrupted` directly locks the underlying mutex of the dma_resv's ww_mutex via `mutex_lock(&bo->base.resv->lock.base)`. On PREEMPT_RT, `struct mutex` becomes `struct rt_mutex` with a different layout, causing a compile error.
**Fix analysis:**
The change from:
```c
mutex_lock(&bo->base.resv->lock.base);
...
mutex_unlock(&bo->base.resv->lock.base);
```
to:
```c
dma_resv_lock(bo->base.resv, NULL);
...
dma_resv_unlock(bo->base.resv);
```
is correct. Looking at the implementation in `include/linux/dma-resv.h:342`, `dma_resv_lock()` with a NULL context calls `ww_mutex_lock(&obj->lock, NULL)`, which behaves as a plain lock without deadlock avoidance — semantically equivalent to what the old code was doing by locking the base mutex directly.
**Semantic correctness:** The test's purpose is for the main thread to hold the reservation lock, then have `threaded_ttm_bo_reserve` (line 184) attempt to acquire it via `ttm_bo_reserve()` with a proper `ww_acquire_ctx`, expecting the thread to be interrupted and return `-ERESTARTSYS`. Using `dma_resv_lock(NULL)` vs raw `mutex_lock` on the base doesn't change the contention behavior — the threaded locker will still block and get signaled.
**Minor note:** `dma_resv_unlock()` (line 461) calls `dma_resv_reset_max_fences(obj)` before `ww_mutex_unlock()`, which zeroes `obj->max_fences`. This is a harmless side effect in this test context since no fences are attached.
**v1 → v2 change:** The changelog says "Use the correct locking primitive (Jouni)", which aligns with this being the v2 improvement — using the proper API rather than some other workaround (likely `#ifdef PREEMPT_RT` or similar in v1).
**Reviewed-by worthy.** No issues found.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Claude review: drm/ttm/tests: Fix build failure on PREEMPT_RT
2026-03-04 8:56 [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT Maarten Lankhorst
2026-03-04 8:58 ` Hogander, Jouni
2026-03-05 3:40 ` Claude review: " Claude Code Review Bot
@ 2026-03-05 3:40 ` Claude Code Review Bot
2 siblings, 0 replies; 5+ messages in thread
From: Claude Code Review Bot @ 2026-03-05 3:40 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: drm/ttm/tests: Fix build failure on PREEMPT_RT
Author: Maarten Lankhorst <dev@lankhorst.se>
Patches: 3
Reviewed: 2026-03-05T13:40:45.267716
---
This is a single-patch fix for a compile error in TTM kunit tests when `CONFIG_PREEMPT_RT` is enabled. On PREEMPT_RT, `struct mutex` is replaced by `struct rt_mutex`, so directly accessing `bo->base.resv->lock.base` as a `mutex` fails to compile. The fix correctly switches to the proper `dma_resv_lock()`/`dma_resv_unlock()` API instead of reaching into ww_mutex internals. This is a clean, straightforward fix.
**Verdict: Looks good.**
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-03-05 3:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-04 8:56 [PATCH v2] drm/ttm/tests: Fix build failure on PREEMPT_RT Maarten Lankhorst
2026-03-04 8:58 ` Hogander, Jouni
2026-03-04 9:25 ` Maarten Lankhorst
2026-03-05 3:40 ` Claude review: " Claude Code Review Bot
2026-03-05 3:40 ` Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox