[PATCH v3 09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init

2023-07-28 Thread Maxime Ripard
The new helper to init the locking context allows to remove some
boilerplate.

Reviewed-by: Javier Martinez Canillas 
Reviewed-by: MaĆ­ra Canal 
Signed-off-by: Maxime Ripard 
---
 drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 --
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
index 776a7b01608f..ff1deaed0cab 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
@@ -20,7 +20,6 @@
 
 struct pv_muxing_priv {
struct vc4_dev *vc4;
-   struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_state *state;
 };
 
@@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit 
*test)
 static int vc4_pv_muxing_test_init(struct kunit *test)
 {
const struct pv_muxing_param *params = test->param_value;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct pv_muxing_priv *priv;
struct drm_device *drm;
@@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
priv->vc4 = vc4;
 
-   drm_modeset_acquire_init(>ctx, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = >ctx;
+   state->acquire_ctx = ctx;
 
priv->state = state;
 
@@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test)
struct drm_atomic_state *state = priv->state;
 
drm_atomic_state_put(state);
-   drm_modeset_drop_locks(>ctx);
-   drm_modeset_acquire_fini(>ctx);
 }
 
 static struct kunit_case vc4_pv_muxing_tests[] = {
@@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = {
  */
 static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit 
*test)
 {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -811,13 +810,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
 
-   drm_modeset_acquire_init(, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -844,7 +844,7 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -866,13 +866,11 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel);
 
drm_atomic_state_put(state);
-   drm_modeset_drop_locks();
-   drm_modeset_acquire_fini();
 }
 
 static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
 {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -885,13 +883,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
 
-   drm_modeset_acquire_init(, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct 
kunit *test)
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -954,14 +953,12 @@ static void 

[PATCH v2 09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init

2023-07-20 Thread Maxime Ripard
The new helper to init the locking context allows to remove some
boilerplate.

Reviewed-by: Javier Martinez Canillas 
Signed-off-by: Maxime Ripard 
---
 drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 --
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
index 776a7b01608f..ff1deaed0cab 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
@@ -20,7 +20,6 @@
 
 struct pv_muxing_priv {
struct vc4_dev *vc4;
-   struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_state *state;
 };
 
@@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit 
*test)
 static int vc4_pv_muxing_test_init(struct kunit *test)
 {
const struct pv_muxing_param *params = test->param_value;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct pv_muxing_priv *priv;
struct drm_device *drm;
@@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
priv->vc4 = vc4;
 
-   drm_modeset_acquire_init(>ctx, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = >ctx;
+   state->acquire_ctx = ctx;
 
priv->state = state;
 
@@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test)
struct drm_atomic_state *state = priv->state;
 
drm_atomic_state_put(state);
-   drm_modeset_drop_locks(>ctx);
-   drm_modeset_acquire_fini(>ctx);
 }
 
 static struct kunit_case vc4_pv_muxing_tests[] = {
@@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = {
  */
 static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit 
*test)
 {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -811,13 +810,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
 
-   drm_modeset_acquire_init(, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -844,7 +844,7 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -866,13 +866,11 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel);
 
drm_atomic_state_put(state);
-   drm_modeset_drop_locks();
-   drm_modeset_acquire_fini();
 }
 
 static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
 {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -885,13 +883,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
 
-   drm_modeset_acquire_init(, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct 
kunit *test)
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -954,14 +953,12 @@ static void 
drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)

Re: [09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init

2023-07-20 Thread Maxime Ripard
On Tue, Jul 18, 2023 at 01:24:29AM +0800, suijingfeng wrote:
> On 2023/7/10 15:47, Maxime Ripard wrote:
> > The new helper to init the locking context allows to remove some
> > boilerplate.
> > 
> > Signed-off-by: Maxime Ripard 
> > ---
> >   drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 
> > --
> >   1 file changed, 19 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
> > b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
> > index 776a7b01608f..ff1deaed0cab 100644
> > --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
> > +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
> > @@ -20,7 +20,6 @@
> >   struct pv_muxing_priv {
> > struct vc4_dev *vc4;
> > -   struct drm_modeset_acquire_ctx ctx;
> > struct drm_atomic_state *state;
> >   };
> > @@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit 
> > *test)
> >   static int vc4_pv_muxing_test_init(struct kunit *test)
> >   {
> > const struct pv_muxing_param *params = test->param_value;
> > +   struct drm_modeset_acquire_ctx *ctx;
> > struct drm_atomic_state *state;
> > struct pv_muxing_priv *priv;
> > struct drm_device *drm;
> > @@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
> > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
> > priv->vc4 = vc4;
> > -   drm_modeset_acquire_init(>ctx, 0);
> > +   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
> 
> > +   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
> 
> The pointer returned by drm_kunit_helper_acquire_ctx_alloc() function can't
> be NULL,
> 
> if ctx is NULL, the current kthread will be terminated by the
> KUNIT_ASSERT_NOT_NULL() in the drm_kunit_helper_acquire_ctx_alloc().
> 
> so only a PTR_ERR is possible, right?
> 
> If so, probably invent a KUNIT_ASSERT_NOT_ERR() function to call is enough.
> 
> I'm fine with this patch, but I feel the checking if the ctx is NULL is
> redundant.

I guess, but we're still reference that pointer later on, so making sure
that it's a valid pointer still makes sense.

Maxime


signature.asc
Description: PGP signature


Re: [PATCH 09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init

2023-07-19 Thread Javier Martinez Canillas
Maxime Ripard  writes:

> The new helper to init the locking context allows to remove some
> boilerplate.
>
> Signed-off-by: Maxime Ripard 
> ---

Reviewed-by: Javier Martinez Canillas 

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat



Re: [09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init

2023-07-17 Thread suijingfeng

Hi,


On 2023/7/10 15:47, Maxime Ripard wrote:

The new helper to init the locking context allows to remove some
boilerplate.

Signed-off-by: Maxime Ripard 
---
  drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 --
  1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
index 776a7b01608f..ff1deaed0cab 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
@@ -20,7 +20,6 @@
  
  struct pv_muxing_priv {

struct vc4_dev *vc4;
-   struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_state *state;
  };
  
@@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test)

  static int vc4_pv_muxing_test_init(struct kunit *test)
  {
const struct pv_muxing_param *params = test->param_value;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct pv_muxing_priv *priv;
struct drm_device *drm;
@@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
priv->vc4 = vc4;
  
-	drm_modeset_acquire_init(>ctx, 0);

+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);



+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
  


The pointer returned by drm_kunit_helper_acquire_ctx_alloc() function 
can't be NULL,


if ctx is NULL, the current kthread will be terminated by the 
KUNIT_ASSERT_NOT_NULL() in the drm_kunit_helper_acquire_ctx_alloc().


so only a PTR_ERR is possible, right?

If so, probably invent a KUNIT_ASSERT_NOT_ERR() function to call is enough.

I'm fine with this patch, but I feel the checking if the ctx is NULL is 
redundant.



drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
  
-	state->acquire_ctx = >ctx;

+   state->acquire_ctx = ctx;
  
  	priv->state = state;
  
@@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test)

struct drm_atomic_state *state = priv->state;
  
  	drm_atomic_state_put(state);

-   drm_modeset_drop_locks(>ctx);
-   drm_modeset_acquire_fini(>ctx);
  }
  
  static struct kunit_case vc4_pv_muxing_tests[] = {

@@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = {
   */
  static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit 
*test)
  {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -811,13 +810,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
  
-	drm_modeset_acquire_init(, 0);

+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
  
  	drm = >base;

state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
  
-	state->acquire_ctx = 

+   state->acquire_ctx = ctx;
  
  	ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);

KUNIT_ASSERT_EQ(test, ret, 0);
@@ -844,7 +844,7 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
  
-	state->acquire_ctx = 

+   state->acquire_ctx = ctx;
  
  	ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);

KUNIT_ASSERT_EQ(test, ret, 0);
@@ -866,13 +866,11 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel);
  
  	drm_atomic_state_put(state);

-   drm_modeset_drop_locks();
-   drm_modeset_acquire_fini();
  }
  
  static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)

  {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -885,13 +883,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
  
-	drm_modeset_acquire_init(, 0);

+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
  
  	drm = >base;

state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
  
-	state->acquire_ctx = 

+   state->acquire_ctx = ctx;
  
  	ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);

KUNIT_ASSERT_EQ(test, ret, 0);
@@ -929,7 +928,7 @@ static void 

[PATCH 09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init

2023-07-10 Thread Maxime Ripard
The new helper to init the locking context allows to remove some
boilerplate.

Signed-off-by: Maxime Ripard 
---
 drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 --
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c 
b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
index 776a7b01608f..ff1deaed0cab 100644
--- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
+++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
@@ -20,7 +20,6 @@
 
 struct pv_muxing_priv {
struct vc4_dev *vc4;
-   struct drm_modeset_acquire_ctx ctx;
struct drm_atomic_state *state;
 };
 
@@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit 
*test)
 static int vc4_pv_muxing_test_init(struct kunit *test)
 {
const struct pv_muxing_param *params = test->param_value;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct pv_muxing_priv *priv;
struct drm_device *drm;
@@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
priv->vc4 = vc4;
 
-   drm_modeset_acquire_init(>ctx, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = >ctx;
+   state->acquire_ctx = ctx;
 
priv->state = state;
 
@@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test)
struct drm_atomic_state *state = priv->state;
 
drm_atomic_state_put(state);
-   drm_modeset_drop_locks(>ctx);
-   drm_modeset_acquire_fini(>ctx);
 }
 
 static struct kunit_case vc4_pv_muxing_tests[] = {
@@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = {
  */
 static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit 
*test)
 {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -811,13 +810,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
 
-   drm_modeset_acquire_init(, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -844,7 +844,7 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -866,13 +866,11 @@ static void 
drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes
KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel);
 
drm_atomic_state_put(state);
-   drm_modeset_drop_locks();
-   drm_modeset_acquire_fini();
 }
 
 static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
 {
-   struct drm_modeset_acquire_ctx ctx;
+   struct drm_modeset_acquire_ctx *ctx;
struct drm_atomic_state *state;
struct vc4_crtc_state *new_vc4_crtc_state;
struct vc4_hvs_state *new_hvs_state;
@@ -885,13 +883,14 @@ static void 
drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
vc4 = vc5_mock_device(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
 
-   drm_modeset_acquire_init(, 0);
+   ctx = drm_kunit_helper_acquire_ctx_alloc(test);
+   KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx);
 
drm = >base;
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct 
kunit *test)
state = drm_atomic_state_alloc(drm);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state);
 
-   state->acquire_ctx = 
+   state->acquire_ctx = ctx;
 
ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0);
KUNIT_ASSERT_EQ(test, ret, 0);
@@ -954,14 +953,12 @@ static void 
drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test)
}