From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Karolina Stolarek <karolina.stolarek@intel.com>,
dri-devel@lists.freedesktop.org
Cc: "Christian König" <christian.koenig@amd.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Amaranath Somalapuram" <asomalap@amd.com>
Subject: Re: [PATCH v12 01/10] drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk
Date: Fri, 24 May 2024 17:16:04 +0200 [thread overview]
Message-ID: <e30abb8e15f9ca4835513bcb0d22260e269f692f.camel@linux.intel.com> (raw)
In-Reply-To: <aeca4459b42d06be8b040aa65bc44294fe437fdb.1715767062.git.karolina.stolarek@intel.com>
On Wed, 2024-05-15 at 13:24 +0200, Karolina Stolarek wrote:
> BOs in a bulk move have to share the same reservation object. That is
> not the case in the ttm_bo_unreserve_bulk subtest. Update
> ttm_bo_kunit_init() helper to accept dma_resv object so we can define
> buffer objects that share the same resv. Update calls to that helper
> accordingly.
>
> Fixes: 995279d280d1 ("drm/ttm/tests: Add tests for ttm_bo functions")
> Suggested-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Karolina Stolarek <karolina.stolarek@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/ttm/tests/ttm_bo_test.c | 40 +++++++++++------
> --
> drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c | 7 +++-
> drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h | 3 +-
> drivers/gpu/drm/ttm/tests/ttm_pool_test.c | 4 +-
> drivers/gpu/drm/ttm/tests/ttm_resource_test.c | 2 +-
> drivers/gpu/drm/ttm/tests/ttm_tt_test.c | 20 +++++-----
> 6 files changed, 45 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> index 1f8a4f8adc92..ffcfe5e6709a 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_test.c
> @@ -56,7 +56,7 @@ static void
> ttm_bo_reserve_optimistic_no_ticket(struct kunit *test)
> struct ttm_buffer_object *bo;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_bo_reserve(bo, params->interruptible, params-
> >no_wait, NULL);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -71,7 +71,7 @@ static void ttm_bo_reserve_locked_no_sleep(struct
> kunit *test)
> bool no_wait = true;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> /* Let's lock it beforehand */
> dma_resv_lock(bo->base.resv, NULL);
> @@ -92,7 +92,7 @@ static void ttm_bo_reserve_no_wait_ticket(struct
> kunit *test)
>
> ww_acquire_init(&ctx, &reservation_ww_class);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_bo_reserve(bo, interruptible, no_wait, &ctx);
> KUNIT_ASSERT_EQ(test, err, -EBUSY);
> @@ -110,7 +110,7 @@ static void ttm_bo_reserve_double_resv(struct
> kunit *test)
>
> ww_acquire_init(&ctx, &reservation_ww_class);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_bo_reserve(bo, interruptible, no_wait, &ctx);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -138,8 +138,8 @@ static void ttm_bo_reserve_deadlock(struct kunit
> *test)
> 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);
> + bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> + bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> ww_acquire_init(&ctx1, &reservation_ww_class);
> mutex_lock(&bo2->base.resv->lock.base);
> @@ -208,7 +208,7 @@ static void ttm_bo_reserve_interrupted(struct
> kunit *test)
> struct task_struct *task;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> task = kthread_create(threaded_ttm_bo_reserve, bo, "ttm-bo-
> reserve");
>
> @@ -249,7 +249,7 @@ static void ttm_bo_unreserve_basic(struct kunit
> *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> bo->priority = bo_prio;
>
> err = ttm_resource_alloc(bo, place, &res1);
> @@ -288,7 +288,7 @@ static void ttm_bo_unreserve_pinned(struct kunit
> *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> place = ttm_place_kunit_init(test, mem_type, 0);
>
> dma_resv_lock(bo->base.resv, NULL);
> @@ -321,6 +321,7 @@ static void ttm_bo_unreserve_bulk(struct kunit
> *test)
> struct ttm_resource *res1, *res2;
> struct ttm_device *ttm_dev;
> struct ttm_place *place;
> + struct dma_resv *resv;
> uint32_t mem_type = TTM_PL_SYSTEM;
> unsigned int bo_priority = 0;
> int err;
> @@ -332,12 +333,17 @@ static void ttm_bo_unreserve_bulk(struct kunit
> *test)
> ttm_dev = kunit_kzalloc(test, sizeof(*ttm_dev), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, ttm_dev);
>
> + resv = kunit_kzalloc(test, sizeof(*resv), GFP_KERNEL);
> + KUNIT_ASSERT_NOT_NULL(test, ttm_dev);
> +
> err = ttm_device_kunit_init(priv, ttm_dev, false, false);
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> - bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + dma_resv_init(resv);
> +
> + bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, resv);
> + bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, resv);
>
> dma_resv_lock(bo1->base.resv, NULL);
> ttm_bo_set_bulk_move(bo1, &lru_bulk_move);
> @@ -363,6 +369,8 @@ static void ttm_bo_unreserve_bulk(struct kunit
> *test)
>
> ttm_resource_free(bo1, &res1);
> ttm_resource_free(bo2, &res2);
> +
> + dma_resv_fini(resv);
> }
>
> static void ttm_bo_put_basic(struct kunit *test)
> @@ -384,7 +392,7 @@ static void ttm_bo_put_basic(struct kunit *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> bo->type = ttm_bo_type_device;
>
> err = ttm_resource_alloc(bo, place, &res);
> @@ -445,7 +453,7 @@ static void ttm_bo_put_shared_resv(struct kunit
> *test)
>
> dma_fence_signal(fence);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> bo->type = ttm_bo_type_device;
> bo->base.resv = external_resv;
>
> @@ -467,7 +475,7 @@ static void ttm_bo_pin_basic(struct kunit *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> for (int i = 0; i < no_pins; i++) {
> dma_resv_lock(bo->base.resv, NULL);
> @@ -502,7 +510,7 @@ static void ttm_bo_pin_unpin_resource(struct
> kunit *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_resource_alloc(bo, place, &res);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -553,7 +561,7 @@ static void ttm_bo_multiple_pin_one_unpin(struct
> kunit *test)
> KUNIT_ASSERT_EQ(test, err, 0);
> priv->ttm_dev = ttm_dev;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_resource_alloc(bo, place, &res);
> KUNIT_ASSERT_EQ(test, err, 0);
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
> b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
> index 7b7c1fa805fc..5be317a0af56 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
> @@ -51,7 +51,8 @@ EXPORT_SYMBOL_GPL(ttm_device_kunit_init);
>
> struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
> struct ttm_test_devices
> *devs,
> - size_t size)
> + size_t size,
> + struct dma_resv *obj)
> {
> struct drm_gem_object gem_obj = { };
> struct ttm_buffer_object *bo;
> @@ -61,6 +62,10 @@ struct ttm_buffer_object *ttm_bo_kunit_init(struct
> kunit *test,
> KUNIT_ASSERT_NOT_NULL(test, bo);
>
> bo->base = gem_obj;
> +
> + if (obj)
> + bo->base.resv = obj;
> +
> err = drm_gem_object_init(devs->drm, &bo->base, size);
> KUNIT_ASSERT_EQ(test, err, 0);
>
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h
> b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h
> index 2f51c833a536..c83d31b23c9a 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h
> +++ b/drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h
> @@ -28,7 +28,8 @@ int ttm_device_kunit_init(struct ttm_test_devices
> *priv,
> bool use_dma32);
> struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test,
> struct ttm_test_devices
> *devs,
> - size_t size);
> + size_t size,
> + struct dma_resv *obj);
> struct ttm_place *ttm_place_kunit_init(struct kunit *test,
> uint32_t mem_type, uint32_t
> flags);
>
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
> b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
> index 0a3fede84da9..4643f91c6bd5 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
> @@ -57,7 +57,7 @@ static struct ttm_tt *ttm_tt_kunit_init(struct
> kunit *test,
> struct ttm_tt *tt;
> int err;
>
> - bo = ttm_bo_kunit_init(test, priv->devs, size);
> + bo = ttm_bo_kunit_init(test, priv->devs, size, NULL);
> KUNIT_ASSERT_NOT_NULL(test, bo);
> priv->mock_bo = bo;
>
> @@ -209,7 +209,7 @@ static void ttm_pool_alloc_basic_dma_addr(struct
> kunit *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, devs, size);
> + bo = ttm_bo_kunit_init(test, devs, size, NULL);
> KUNIT_ASSERT_NOT_NULL(test, bo);
>
> err = ttm_sg_tt_init(tt, bo, 0, caching);
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_resource_test.c
> b/drivers/gpu/drm/ttm/tests/ttm_resource_test.c
> index 029e1f094bb0..67584058dadb 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_resource_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_resource_test.c
> @@ -54,7 +54,7 @@ static void ttm_init_test_mocks(struct kunit *test,
> /* Make sure we have what we need for a good BO mock */
> KUNIT_ASSERT_NOT_NULL(test, priv->devs->ttm_dev);
>
> - priv->bo = ttm_bo_kunit_init(test, priv->devs, size);
> + priv->bo = ttm_bo_kunit_init(test, priv->devs, size, NULL);
> priv->place = ttm_place_kunit_init(test, mem_type, flags);
> }
>
> diff --git a/drivers/gpu/drm/ttm/tests/ttm_tt_test.c
> b/drivers/gpu/drm/ttm/tests/ttm_tt_test.c
> index fd4502c18de6..67bf51723c92 100644
> --- a/drivers/gpu/drm/ttm/tests/ttm_tt_test.c
> +++ b/drivers/gpu/drm/ttm/tests/ttm_tt_test.c
> @@ -63,7 +63,7 @@ static void ttm_tt_init_basic(struct kunit *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, test->priv, params->size);
> + bo = ttm_bo_kunit_init(test, test->priv, params->size,
> NULL);
>
> err = ttm_tt_init(tt, bo, page_flags, caching, extra_pages);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -89,7 +89,7 @@ static void ttm_tt_init_misaligned(struct kunit
> *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, test->priv, size);
> + bo = ttm_bo_kunit_init(test, test->priv, size, NULL);
>
> /* Make the object size misaligned */
> bo->base.size += 1;
> @@ -110,7 +110,7 @@ static void ttm_tt_fini_basic(struct kunit *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_tt_init(tt, bo, 0, caching, 0);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -130,7 +130,7 @@ static void ttm_tt_fini_sg(struct kunit *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_sg_tt_init(tt, bo, 0, caching);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -151,7 +151,7 @@ static void ttm_tt_fini_shmem(struct kunit *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_tt_init(tt, bo, 0, caching, 0);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -168,7 +168,7 @@ static void ttm_tt_create_basic(struct kunit
> *test)
> struct ttm_buffer_object *bo;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> bo->type = ttm_bo_type_device;
>
> dma_resv_lock(bo->base.resv, NULL);
> @@ -187,7 +187,7 @@ static void ttm_tt_create_invalid_bo_type(struct
> kunit *test)
> struct ttm_buffer_object *bo;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
> bo->type = ttm_bo_type_sg + 1;
>
> dma_resv_lock(bo->base.resv, NULL);
> @@ -208,7 +208,7 @@ static void ttm_tt_create_ttm_exists(struct kunit
> *test)
> tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL);
> KUNIT_ASSERT_NOT_NULL(test, tt);
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> err = ttm_tt_init(tt, bo, 0, caching, 0);
> KUNIT_ASSERT_EQ(test, err, 0);
> @@ -239,7 +239,7 @@ static void ttm_tt_create_failed(struct kunit
> *test)
> struct ttm_buffer_object *bo;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> /* Update ttm_device_funcs so we don't alloc ttm_tt */
> devs->ttm_dev->funcs = &ttm_dev_empty_funcs;
> @@ -257,7 +257,7 @@ static void ttm_tt_destroy_basic(struct kunit
> *test)
> struct ttm_buffer_object *bo;
> int err;
>
> - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE);
> + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL);
>
> dma_resv_lock(bo->base.resv, NULL);
> err = ttm_tt_create(bo, false);
next prev parent reply other threads:[~2024-05-24 15:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 11:24 [PATCH v12 00/10] Improve test coverage of TTM Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 01/10] drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk Karolina Stolarek
2024-05-24 15:16 ` Thomas Hellström [this message]
2024-05-15 11:24 ` [PATCH v12 02/10] drm/ttm/tests: Delete unnecessary config option Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 03/10] drm/ttm/tests: Set DMA mask in KUnit device Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 04/10] drm/ttm/tests: Use an init function from the helpers lib Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 05/10] drm/ttm/tests: Test simple BO creation and validation Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 06/10] drm/ttm/tests: Add tests with mock resource managers Karolina Stolarek
2024-05-29 12:58 ` Thomas Hellström
2024-06-03 6:55 ` Karolina Stolarek
2024-06-03 7:24 ` Thomas Hellström
2024-06-03 8:28 ` Karolina Stolarek
2024-06-03 9:30 ` Thomas Hellström
2024-06-03 9:46 ` Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 07/10] drm/ttm/tests: Add test cases dependent on fence signaling Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 08/10] drm/ttm/tests: Add eviction testing Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 09/10] drm/ttm/tests: Add tests for ttm_tt_populate Karolina Stolarek
2024-05-15 11:24 ` [PATCH v12 10/10] drm/ttm/tests: Add TODO file Karolina Stolarek
2024-05-24 15:29 ` Thomas Hellström
2024-05-17 3:37 ` [PATCH v12 00/10] Improve test coverage of TTM Somalapuram, Amaranath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e30abb8e15f9ca4835513bcb0d22260e269f692f.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=asomalap@amd.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karolina.stolarek@intel.com \
--cc=matthew.auld@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.