diff options
author | Christian König <christian.koenig@amd.com> | 2017-04-27 12:20:47 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-06 12:48:04 -0500 |
commit | 6af046d26f34278eacd6ecddb37170624f6d4251 (patch) | |
tree | 994a35f99ee86912803c16a0b5145f4e492469a6 /drivers/gpu/drm/amd | |
parent | dfb8fa9828dba4a83545c8d854bb6bc003a95d95 (diff) |
drm/amdgpu: use the new TTM bytes moved counter v2
Instead of the global statistics use the per context bytes moved counter.
v2: rebased
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 |
2 files changed, 6 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index faab662ce680..5e89d7a7178f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -344,7 +344,6 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
344 | { | 344 | { |
345 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | 345 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); |
346 | struct ttm_operation_ctx ctx = { true, false }; | 346 | struct ttm_operation_ctx ctx = { true, false }; |
347 | u64 initial_bytes_moved, bytes_moved; | ||
348 | uint32_t domain; | 347 | uint32_t domain; |
349 | int r; | 348 | int r; |
350 | 349 | ||
@@ -374,15 +373,13 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
374 | 373 | ||
375 | retry: | 374 | retry: |
376 | amdgpu_ttm_placement_from_domain(bo, domain); | 375 | amdgpu_ttm_placement_from_domain(bo, domain); |
377 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | ||
378 | r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); | 376 | r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); |
379 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - | 377 | |
380 | initial_bytes_moved; | 378 | p->bytes_moved += ctx.bytes_moved; |
381 | p->bytes_moved += bytes_moved; | ||
382 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && | 379 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && |
383 | bo->tbo.mem.mem_type == TTM_PL_VRAM && | 380 | bo->tbo.mem.mem_type == TTM_PL_VRAM && |
384 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) | 381 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) |
385 | p->bytes_moved_vis += bytes_moved; | 382 | p->bytes_moved_vis += ctx.bytes_moved; |
386 | 383 | ||
387 | if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { | 384 | if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { |
388 | domain = bo->allowed_domains; | 385 | domain = bo->allowed_domains; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 15027f751e07..dc0a8be98043 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -331,7 +331,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, | |||
331 | struct amdgpu_bo *bo; | 331 | struct amdgpu_bo *bo; |
332 | enum ttm_bo_type type; | 332 | enum ttm_bo_type type; |
333 | unsigned long page_align; | 333 | unsigned long page_align; |
334 | u64 initial_bytes_moved, bytes_moved; | ||
335 | size_t acc_size; | 334 | size_t acc_size; |
336 | int r; | 335 | int r; |
337 | 336 | ||
@@ -406,22 +405,19 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, | |||
406 | bo->tbo.bdev = &adev->mman.bdev; | 405 | bo->tbo.bdev = &adev->mman.bdev; |
407 | amdgpu_ttm_placement_from_domain(bo, domain); | 406 | amdgpu_ttm_placement_from_domain(bo, domain); |
408 | 407 | ||
409 | initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); | ||
410 | /* Kernel allocation are uninterruptible */ | ||
411 | r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, | 408 | r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, |
412 | &bo->placement, page_align, &ctx, NULL, | 409 | &bo->placement, page_align, &ctx, NULL, |
413 | acc_size, sg, resv, &amdgpu_ttm_bo_destroy); | 410 | acc_size, sg, resv, &amdgpu_ttm_bo_destroy); |
414 | if (unlikely(r != 0)) | 411 | if (unlikely(r != 0)) |
415 | return r; | 412 | return r; |
416 | 413 | ||
417 | bytes_moved = atomic64_read(&adev->num_bytes_moved) - | ||
418 | initial_bytes_moved; | ||
419 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && | 414 | if (adev->mc.visible_vram_size < adev->mc.real_vram_size && |
420 | bo->tbo.mem.mem_type == TTM_PL_VRAM && | 415 | bo->tbo.mem.mem_type == TTM_PL_VRAM && |
421 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) | 416 | bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) |
422 | amdgpu_cs_report_moved_bytes(adev, bytes_moved, bytes_moved); | 417 | amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, |
418 | ctx.bytes_moved); | ||
423 | else | 419 | else |
424 | amdgpu_cs_report_moved_bytes(adev, bytes_moved, 0); | 420 | amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); |
425 | 421 | ||
426 | if (kernel) | 422 | if (kernel) |
427 | bo->tbo.priority = 1; | 423 | bo->tbo.priority = 1; |