Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ttm/tests: Fix a warning in ttm_bo_unreserve_bulk

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>
Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/c5bd2df114781b4eb5c1e8295b2ae4ac2c30a179.1718192625.git.karolina.stolarek@intel.com

authored by

Karolina Stolarek and committed by
Arunpravin Paneer Selvam
588c4c8d 699f411d

+45 -31
+24 -16
drivers/gpu/drm/ttm/tests/ttm_bo_test.c
··· 62 62 struct ttm_buffer_object *bo; 63 63 int err; 64 64 65 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 65 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 66 66 67 67 err = ttm_bo_reserve(bo, params->interruptible, params->no_wait, NULL); 68 68 KUNIT_ASSERT_EQ(test, err, 0); ··· 77 77 bool no_wait = true; 78 78 int err; 79 79 80 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 80 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 81 81 82 82 /* Let's lock it beforehand */ 83 83 dma_resv_lock(bo->base.resv, NULL); ··· 98 98 99 99 ww_acquire_init(&ctx, &reservation_ww_class); 100 100 101 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 101 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 102 102 103 103 err = ttm_bo_reserve(bo, interruptible, no_wait, &ctx); 104 104 KUNIT_ASSERT_EQ(test, err, -EBUSY); ··· 116 116 117 117 ww_acquire_init(&ctx, &reservation_ww_class); 118 118 119 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 119 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 120 120 121 121 err = ttm_bo_reserve(bo, interruptible, no_wait, &ctx); 122 122 KUNIT_ASSERT_EQ(test, err, 0); ··· 144 144 bool no_wait = false; 145 145 int err; 146 146 147 - bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 148 - bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 147 + bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 148 + bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 149 149 150 150 ww_acquire_init(&ctx1, &reservation_ww_class); 151 151 ww_mutex_base_lock(&bo2->base.resv->lock.base); ··· 214 214 struct task_struct *task; 215 215 int err; 216 216 217 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 217 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 218 218 219 219 task = kthread_create(threaded_ttm_bo_reserve, bo, "ttm-bo-reserve"); 220 220 ··· 255 255 KUNIT_ASSERT_EQ(test, err, 0); 256 256 priv->ttm_dev = ttm_dev; 257 257 258 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 258 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 259 259 bo->priority = bo_prio; 260 260 261 261 err = ttm_resource_alloc(bo, place, &res1); ··· 294 294 KUNIT_ASSERT_EQ(test, err, 0); 295 295 priv->ttm_dev = ttm_dev; 296 296 297 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 297 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 298 298 place = ttm_place_kunit_init(test, mem_type, 0); 299 299 300 300 dma_resv_lock(bo->base.resv, NULL); ··· 327 327 struct ttm_resource *res1, *res2; 328 328 struct ttm_device *ttm_dev; 329 329 struct ttm_place *place; 330 + struct dma_resv *resv; 330 331 uint32_t mem_type = TTM_PL_SYSTEM; 331 332 unsigned int bo_priority = 0; 332 333 int err; ··· 339 338 ttm_dev = kunit_kzalloc(test, sizeof(*ttm_dev), GFP_KERNEL); 340 339 KUNIT_ASSERT_NOT_NULL(test, ttm_dev); 341 340 341 + resv = kunit_kzalloc(test, sizeof(*resv), GFP_KERNEL); 342 + KUNIT_ASSERT_NOT_NULL(test, ttm_dev); 343 + 342 344 err = ttm_device_kunit_init(priv, ttm_dev, false, false); 343 345 KUNIT_ASSERT_EQ(test, err, 0); 344 346 priv->ttm_dev = ttm_dev; 345 347 346 - bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 347 - bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 348 + dma_resv_init(resv); 349 + 350 + bo1 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, resv); 351 + bo2 = ttm_bo_kunit_init(test, test->priv, BO_SIZE, resv); 348 352 349 353 dma_resv_lock(bo1->base.resv, NULL); 350 354 ttm_bo_set_bulk_move(bo1, &lru_bulk_move); ··· 375 369 376 370 ttm_resource_free(bo1, &res1); 377 371 ttm_resource_free(bo2, &res2); 372 + 373 + dma_resv_fini(resv); 378 374 } 379 375 380 376 static void ttm_bo_put_basic(struct kunit *test) ··· 398 390 KUNIT_ASSERT_EQ(test, err, 0); 399 391 priv->ttm_dev = ttm_dev; 400 392 401 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 393 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 402 394 bo->type = ttm_bo_type_device; 403 395 404 396 err = ttm_resource_alloc(bo, place, &res); ··· 459 451 460 452 dma_fence_signal(fence); 461 453 462 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 454 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 463 455 bo->type = ttm_bo_type_device; 464 456 bo->base.resv = external_resv; 465 457 ··· 481 473 KUNIT_ASSERT_EQ(test, err, 0); 482 474 priv->ttm_dev = ttm_dev; 483 475 484 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 476 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 485 477 486 478 for (int i = 0; i < no_pins; i++) { 487 479 dma_resv_lock(bo->base.resv, NULL); ··· 516 508 KUNIT_ASSERT_EQ(test, err, 0); 517 509 priv->ttm_dev = ttm_dev; 518 510 519 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 511 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 520 512 521 513 err = ttm_resource_alloc(bo, place, &res); 522 514 KUNIT_ASSERT_EQ(test, err, 0); ··· 567 559 KUNIT_ASSERT_EQ(test, err, 0); 568 560 priv->ttm_dev = ttm_dev; 569 561 570 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 562 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 571 563 572 564 err = ttm_resource_alloc(bo, place, &res); 573 565 KUNIT_ASSERT_EQ(test, err, 0);
+6 -1
drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.c
··· 51 51 52 52 struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test, 53 53 struct ttm_test_devices *devs, 54 - size_t size) 54 + size_t size, 55 + struct dma_resv *obj) 55 56 { 56 57 struct drm_gem_object gem_obj = { }; 57 58 struct ttm_buffer_object *bo; ··· 62 61 KUNIT_ASSERT_NOT_NULL(test, bo); 63 62 64 63 bo->base = gem_obj; 64 + 65 + if (obj) 66 + bo->base.resv = obj; 67 + 65 68 err = drm_gem_object_init(devs->drm, &bo->base, size); 66 69 KUNIT_ASSERT_EQ(test, err, 0); 67 70
+2 -1
drivers/gpu/drm/ttm/tests/ttm_kunit_helpers.h
··· 28 28 bool use_dma32); 29 29 struct ttm_buffer_object *ttm_bo_kunit_init(struct kunit *test, 30 30 struct ttm_test_devices *devs, 31 - size_t size); 31 + size_t size, 32 + struct dma_resv *obj); 32 33 struct ttm_place *ttm_place_kunit_init(struct kunit *test, 33 34 uint32_t mem_type, uint32_t flags); 34 35
+2 -2
drivers/gpu/drm/ttm/tests/ttm_pool_test.c
··· 57 57 struct ttm_tt *tt; 58 58 int err; 59 59 60 - bo = ttm_bo_kunit_init(test, priv->devs, size); 60 + bo = ttm_bo_kunit_init(test, priv->devs, size, NULL); 61 61 KUNIT_ASSERT_NOT_NULL(test, bo); 62 62 priv->mock_bo = bo; 63 63 ··· 209 209 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 210 210 KUNIT_ASSERT_NOT_NULL(test, tt); 211 211 212 - bo = ttm_bo_kunit_init(test, devs, size); 212 + bo = ttm_bo_kunit_init(test, devs, size, NULL); 213 213 KUNIT_ASSERT_NOT_NULL(test, bo); 214 214 215 215 err = ttm_sg_tt_init(tt, bo, 0, caching);
+1 -1
drivers/gpu/drm/ttm/tests/ttm_resource_test.c
··· 54 54 /* Make sure we have what we need for a good BO mock */ 55 55 KUNIT_ASSERT_NOT_NULL(test, priv->devs->ttm_dev); 56 56 57 - priv->bo = ttm_bo_kunit_init(test, priv->devs, size); 57 + priv->bo = ttm_bo_kunit_init(test, priv->devs, size, NULL); 58 58 priv->place = ttm_place_kunit_init(test, mem_type, flags); 59 59 } 60 60
+10 -10
drivers/gpu/drm/ttm/tests/ttm_tt_test.c
··· 63 63 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 64 64 KUNIT_ASSERT_NOT_NULL(test, tt); 65 65 66 - bo = ttm_bo_kunit_init(test, test->priv, params->size); 66 + bo = ttm_bo_kunit_init(test, test->priv, params->size, NULL); 67 67 68 68 err = ttm_tt_init(tt, bo, page_flags, caching, extra_pages); 69 69 KUNIT_ASSERT_EQ(test, err, 0); ··· 89 89 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 90 90 KUNIT_ASSERT_NOT_NULL(test, tt); 91 91 92 - bo = ttm_bo_kunit_init(test, test->priv, size); 92 + bo = ttm_bo_kunit_init(test, test->priv, size, NULL); 93 93 94 94 /* Make the object size misaligned */ 95 95 bo->base.size += 1; ··· 110 110 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 111 111 KUNIT_ASSERT_NOT_NULL(test, tt); 112 112 113 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 113 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 114 114 115 115 err = ttm_tt_init(tt, bo, 0, caching, 0); 116 116 KUNIT_ASSERT_EQ(test, err, 0); ··· 130 130 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 131 131 KUNIT_ASSERT_NOT_NULL(test, tt); 132 132 133 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 133 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 134 134 135 135 err = ttm_sg_tt_init(tt, bo, 0, caching); 136 136 KUNIT_ASSERT_EQ(test, err, 0); ··· 151 151 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 152 152 KUNIT_ASSERT_NOT_NULL(test, tt); 153 153 154 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 154 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 155 155 156 156 err = ttm_tt_init(tt, bo, 0, caching, 0); 157 157 KUNIT_ASSERT_EQ(test, err, 0); ··· 168 168 struct ttm_buffer_object *bo; 169 169 int err; 170 170 171 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 171 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 172 172 bo->type = ttm_bo_type_device; 173 173 174 174 dma_resv_lock(bo->base.resv, NULL); ··· 187 187 struct ttm_buffer_object *bo; 188 188 int err; 189 189 190 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 190 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 191 191 bo->type = ttm_bo_type_sg + 1; 192 192 193 193 dma_resv_lock(bo->base.resv, NULL); ··· 208 208 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); 209 209 KUNIT_ASSERT_NOT_NULL(test, tt); 210 210 211 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 211 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 212 212 213 213 err = ttm_tt_init(tt, bo, 0, caching, 0); 214 214 KUNIT_ASSERT_EQ(test, err, 0); ··· 239 239 struct ttm_buffer_object *bo; 240 240 int err; 241 241 242 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 242 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 243 243 244 244 /* Update ttm_device_funcs so we don't alloc ttm_tt */ 245 245 devs->ttm_dev->funcs = &ttm_dev_empty_funcs; ··· 257 257 struct ttm_buffer_object *bo; 258 258 int err; 259 259 260 - bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE); 260 + bo = ttm_bo_kunit_init(test, test->priv, BO_SIZE, NULL); 261 261 262 262 dma_resv_lock(bo->base.resv, NULL); 263 263 err = ttm_tt_create(bo, false);