Skip to content

Commit c86ea84

Browse files
committed
drm/vc4: tests: Fix up vc4_test_lbm_size
Following the example of [1], move the state allocation out of the init function to make it thread safe. [1] commit 7e0351a ("drm/vc4: tests: Stop allocating the state in test init") Signed-off-by: Phil Elwell <[email protected]>
1 parent 9491e0b commit c86ea84

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

drivers/gpu/drm/vc4/tests/vc4_test_lbm_size.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct vc4_lbm_size_priv {
2323
struct vc4_dev *vc4;
2424
struct drm_file *file;
2525
struct drm_modeset_acquire_ctx ctx;
26-
struct drm_atomic_state *state;
2726
};
2827

2928
struct vc4_lbm_size_param {
@@ -181,17 +180,26 @@ static void drm_vc4_test_vc4_lbm_size(struct kunit *test)
181180
const struct vc4_lbm_size_priv *priv = test->priv;
182181
const struct drm_format_info *info;
183182
struct drm_mode_fb_cmd2 fb_req = { };
184-
struct drm_atomic_state *state = priv->state;
185183
struct vc4_plane_state *vc4_plane_state;
186184
struct drm_plane_state *plane_state;
185+
struct drm_modeset_acquire_ctx ctx;
187186
struct vc4_dummy_output *output;
187+
struct drm_atomic_state *state;
188188
struct drm_framebuffer *fb;
189189
struct drm_plane *plane;
190+
struct drm_device *drm;
190191
struct drm_crtc *crtc;
191192
struct vc4_dev *vc4;
192193
unsigned int i;
193194
int ret;
194195

196+
drm_modeset_acquire_init(&ctx, 0);
197+
198+
vc4 = priv->vc4;
199+
drm = &vc4->base;
200+
state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx);
201+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
202+
195203
info = drm_format_info(params->fourcc);
196204
KUNIT_ASSERT_NOT_NULL(test, info);
197205

@@ -269,6 +277,9 @@ static void drm_vc4_test_vc4_lbm_size(struct kunit *test)
269277

270278
for (i = 0; i < info->num_planes; i++)
271279
drm_mode_destroy_dumb(state->dev, fb_req.handles[i], priv->file);
280+
281+
drm_modeset_drop_locks(&ctx);
282+
drm_modeset_acquire_fini(&ctx);
272283
}
273284

274285
static struct kunit_case vc4_lbm_size_tests[] = {
@@ -279,9 +290,7 @@ static struct kunit_case vc4_lbm_size_tests[] = {
279290

280291
static int vc4_lbm_size_test_init(struct kunit *test)
281292
{
282-
struct drm_modeset_acquire_ctx *ctx;
283293
struct vc4_lbm_size_priv *priv;
284-
struct drm_device *drm;
285294
struct vc4_dev *vc4;
286295

287296
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
@@ -295,13 +304,6 @@ static int vc4_lbm_size_test_init(struct kunit *test)
295304
priv->file = drm_file_alloc(priv->vc4->base.primary);
296305
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->file);
297306

298-
ctx = drm_kunit_helper_acquire_ctx_alloc(test);
299-
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
300-
301-
drm = &vc4->base;
302-
priv->state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx);
303-
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->state);
304-
305307
return 0;
306308
}
307309

0 commit comments

Comments
 (0)