The "skip reset" test waits for the timeout handler to run for the duration of 2 * MOCK_TIMEOUT, and because the mock scheduler opted to remove the "skip reset" flag once it fires, this gives opportunity for the timeout handler to run twice. Second time the job will be removed from the mock scheduler job list and the drm_mock_sched_advance() call in the test will fail. Fix it by making the "don't reset" flag persist for the lifetime of the job and add a new flag to verify that the code path had executed as expected.
Unified · Split
| @@ -219,7 +219,7 @@ mock_sched_timedout_job(struct drm_sched_job *sched_job) · 218 unmodified lines | |||
| 219 | unsigned long flags; | 219 | unsigned long flags; |
| 220 | 220 | ||
| 221 | if (job->flags & DRM_MOCK_SCHED_JOB_DONT_RESET) { | 221 | if (job->flags & DRM_MOCK_SCHED_JOB_DONT_RESET) { |
| 222 | job->flags &= ~DRM_MOCK_SCHED_JOB_DONT_RESET; | 222 | job->flags |= DRM_MOCK_SCHED_JOB_RESET_SKIPPED; |
| 223 | return DRM_GPU_SCHED_STAT_NO_HANG; | 223 | return DRM_GPU_SCHED_STAT_NO_HANG; |
| 224 | } | 224 | } |
| 225 | 225 | ||
| @@ -95,9 +95,10 @@ struct drm_mock_sched_job { · 94 unmodified lines | |||
| 95 | 95 | ||
| 96 | struct completion done; | 96 | struct completion done; |
| 97 | 97 | ||
| 98 | #define DRM_MOCK_SCHED_JOB_DONE 0x1 | 98 | #define DRM_MOCK_SCHED_JOB_DONE 0x1 |
| 99 | #define DRM_MOCK_SCHED_JOB_TIMEDOUT 0x2 | 99 | #define DRM_MOCK_SCHED_JOB_TIMEDOUT 0x2 |
| 100 | #define DRM_MOCK_SCHED_JOB_DONT_RESET 0x4 | 100 | #define DRM_MOCK_SCHED_JOB_DONT_RESET 0x4 |
| 101 | #define DRM_MOCK_SCHED_JOB_RESET_SKIPPED 0x8 | ||
| 101 | unsigned long flags; | 102 | unsigned long flags; |
| 102 | 103 | ||
| 103 | struct list_head link; | 104 | struct list_head link; |
| @@ -317,8 +317,8 @@ static void drm_sched_skip_reset(struct kunit *test) · 316 unmodified lines | |||
| 317 | KUNIT_ASSERT_FALSE(test, done); | 317 | KUNIT_ASSERT_FALSE(test, done); |
| 318 | 318 | ||
| 319 | KUNIT_ASSERT_EQ(test, | 319 | KUNIT_ASSERT_EQ(test, |
| 320 | job->flags & DRM_MOCK_SCHED_JOB_DONT_RESET, | 320 | job->flags & DRM_MOCK_SCHED_JOB_RESET_SKIPPED, |
| 321 | 0); | 321 | DRM_MOCK_SCHED_JOB_RESET_SKIPPED); |
| 322 | 322 | ||
| 323 | i = drm_mock_sched_advance(sched, 1); | 323 | i = drm_mock_sched_advance(sched, 1); |
| 324 | KUNIT_ASSERT_EQ(test, i, 1); | 324 | KUNIT_ASSERT_EQ(test, i, 1); |