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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <mripard@xxxxxxxxxx>
> > ---
> >   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(&priv->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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux