Re: [PATCH v7 3/8] drm/ttm/tests: Add tests for ttm_bo functions

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

 



Hi Karolina,

> +/*
> + * A test case heavily inspired by ww_test_edeadlk_normal(). Checks
> + * if -EDEADLK is properly propagated by ttm_bo_reserve()
> + */
> +static void ttm_bo_reserve_deadlock(struct kunit *test)
> +{
> +	struct ttm_buffer_object *bo1, *bo2;
> +	struct ww_acquire_ctx ctx1, ctx2;
> +	bool interruptible = false;
> +	bool no_wait = false;
> +	int err;
> +
> +	bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> +	bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> +
> +	ww_acquire_init(&ctx1, &reservation_ww_class);
> +	mutex_lock(&bo2->base.resv->lock.base);
> +
> +	/* The deadlock will be caught by WW mutex, don't warn about it */
> +	lock_release(&bo2->base.resv->lock.base.dep_map, 1);

OK... by motidfying the lock map, you avoid lockdep to complain.

> +	bo2->base.resv->lock.ctx = &ctx2;
> +	ctx2 = ctx1;
> +	ctx2.stamp--; /* Make the context holding the lock younger */
> +	err = ttm_bo_reserve(bo1, interruptible, no_wait, &ctx1);
> +	KUNIT_ASSERT_EQ(test, err, 0);
> +
> +	err = ttm_bo_reserve(bo2, interruptible, no_wait, &ctx1);
> +	KUNIT_ASSERT_EQ(test, err, -EDEADLK);
> +
> +	dma_resv_unlock(bo1->base.resv);
> +	ww_acquire_fini(&ctx1);
> +}

so... what you're doing here is swapping the lock timing and
catch and report the deadlock... Could you please add some more
comment to better explain the idea behind this test and its
implementation?

Anyway, looks good to me and you can add my:

Reviewed-by: Andi Shyti <andi.shyti@xxxxxxxxxxxxxxx>

Andi



[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