aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-02-09 19:13:30 -0500
committerDave Airlie <airlied@redhat.com>2017-02-09 19:13:30 -0500
commit13f62f54d174d3417c3caaafedf5e22a0a03e442 (patch)
treebc7bbc06c12f5125ae7f3e681ef3855d57651012 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
parentf320d3572344d34a6d8b516261416df0193602f6 (diff)
parentfad061270ac43ff9eed315f0eae7c40b694592de (diff)
Merge branch 'drm-next-4.11' of git://people.freedesktop.org/~agd5f/linux into drm-next
Some additional fixes for 4.11. Delayed a bit due to Chinese New Year. Highlights: - Powerplay fixes - VCE and UVD powergating fixes - Clean up amdgpu SI gfx code to match CI and VI - Misc bug fixes * 'drm-next-4.11' of git://people.freedesktop.org/~agd5f/linux: (30 commits) drm/amdgpu: report the number of bytes moved at buffer creation drm/amdgpu: fix a potential deadlock in amdgpu_bo_create_restricted() drm/amdgpu: add support for new smc firmware on polaris drm/amd/powerplay: refine code to avoid potential bug that the memory not cleared. drm/amdgpu: shut up #warning for compile testing drm/amdgpu/virt: fix double kfree on bo_va drm/radeon: remove some dead code drm/radeon: avoid kernel segfault in vce when gpu fails to resume drm/amd/powerplay: set fan speed to max in profile peak mode only. drm/amd/gfx6: update gb_addr_config drm/amdgpu: update HAINAN_GB_ADDR_CONFIG_GOLDEN drm/amdgpu: update VERDE_GB_ADDR_CONFIG_GOLDEN drm/amdgpu: refine si_read_register drm/amdgpu/gfx6: clean up spi configuration drm/amdgpu/gfx6: clean up cu configuration drm/amdgpu/gfx6: clean up rb configuration drm/amdgpu: refine vce3.0 code and related powerplay pg code. drm/amdgpu: move subfunctions to the front of vce_v2_0.c. drm/amdgpu: enable vce pg feature on Kv. drm/amdgpu: refine code for VCE2.0 and related dpm code. ...
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 9bd1b4eae32e..ec7037a48b6e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -487,67 +487,50 @@ static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)
487 * 487 *
488 * @adev: amdgpu_device pointer 488 * @adev: amdgpu_device pointer
489 * @bo_va: bo_va to update 489 * @bo_va: bo_va to update
490 * @list: validation list
491 * @operation: map or unmap
490 * 492 *
491 * Update the bo_va directly after setting it's address. Errors are not 493 * Update the bo_va directly after setting its address. Errors are not
492 * vital here, so they are not reported back to userspace. 494 * vital here, so they are not reported back to userspace.
493 */ 495 */
494static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, 496static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
495 struct amdgpu_bo_va *bo_va, 497 struct amdgpu_bo_va *bo_va,
498 struct list_head *list,
496 uint32_t operation) 499 uint32_t operation)
497{ 500{
498 struct ttm_validate_buffer tv, *entry; 501 struct ttm_validate_buffer *entry;
499 struct amdgpu_bo_list_entry vm_pd; 502 int r = -ERESTARTSYS;
500 struct ww_acquire_ctx ticket;
501 struct list_head list, duplicates;
502 int r;
503
504 INIT_LIST_HEAD(&list);
505 INIT_LIST_HEAD(&duplicates);
506
507 tv.bo = &bo_va->bo->tbo;
508 tv.shared = true;
509 list_add(&tv.head, &list);
510 503
511 amdgpu_vm_get_pd_bo(bo_va->vm, &list, &vm_pd); 504 list_for_each_entry(entry, list, head) {
512
513 /* Provide duplicates to avoid -EALREADY */
514 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates);
515 if (r)
516 goto error_print;
517
518 list_for_each_entry(entry, &list, head) {
519 struct amdgpu_bo *bo = 505 struct amdgpu_bo *bo =
520 container_of(entry->bo, struct amdgpu_bo, tbo); 506 container_of(entry->bo, struct amdgpu_bo, tbo);
521 507
522 /* if anything is swapped out don't swap it in here, 508 /* if anything is swapped out don't swap it in here,
523 just abort and wait for the next CS */ 509 just abort and wait for the next CS */
524 if (!amdgpu_bo_gpu_accessible(bo)) 510 if (!amdgpu_bo_gpu_accessible(bo))
525 goto error_unreserve; 511 goto error;
526 512
527 if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow)) 513 if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow))
528 goto error_unreserve; 514 goto error;
529 } 515 }
530 516
531 r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check, 517 r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check,
532 NULL); 518 NULL);
533 if (r) 519 if (r)
534 goto error_unreserve; 520 goto error;
535 521
536 r = amdgpu_vm_update_page_directory(adev, bo_va->vm); 522 r = amdgpu_vm_update_page_directory(adev, bo_va->vm);
537 if (r) 523 if (r)
538 goto error_unreserve; 524 goto error;
539 525
540 r = amdgpu_vm_clear_freed(adev, bo_va->vm); 526 r = amdgpu_vm_clear_freed(adev, bo_va->vm);
541 if (r) 527 if (r)
542 goto error_unreserve; 528 goto error;
543 529
544 if (operation == AMDGPU_VA_OP_MAP) 530 if (operation == AMDGPU_VA_OP_MAP)
545 r = amdgpu_vm_bo_update(adev, bo_va, false); 531 r = amdgpu_vm_bo_update(adev, bo_va, false);
546 532
547error_unreserve: 533error:
548 ttm_eu_backoff_reservation(&ticket, &list);
549
550error_print:
551 if (r && r != -ERESTARTSYS) 534 if (r && r != -ERESTARTSYS)
552 DRM_ERROR("Couldn't update BO_VA (%d)\n", r); 535 DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
553} 536}
@@ -564,7 +547,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
564 struct amdgpu_bo_list_entry vm_pd; 547 struct amdgpu_bo_list_entry vm_pd;
565 struct ttm_validate_buffer tv; 548 struct ttm_validate_buffer tv;
566 struct ww_acquire_ctx ticket; 549 struct ww_acquire_ctx ticket;
567 struct list_head list, duplicates; 550 struct list_head list;
568 uint32_t invalid_flags, va_flags = 0; 551 uint32_t invalid_flags, va_flags = 0;
569 int r = 0; 552 int r = 0;
570 553
@@ -602,14 +585,13 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
602 return -ENOENT; 585 return -ENOENT;
603 abo = gem_to_amdgpu_bo(gobj); 586 abo = gem_to_amdgpu_bo(gobj);
604 INIT_LIST_HEAD(&list); 587 INIT_LIST_HEAD(&list);
605 INIT_LIST_HEAD(&duplicates);
606 tv.bo = &abo->tbo; 588 tv.bo = &abo->tbo;
607 tv.shared = true; 589 tv.shared = false;
608 list_add(&tv.head, &list); 590 list_add(&tv.head, &list);
609 591
610 amdgpu_vm_get_pd_bo(&fpriv->vm, &list, &vm_pd); 592 amdgpu_vm_get_pd_bo(&fpriv->vm, &list, &vm_pd);
611 593
612 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates); 594 r = ttm_eu_reserve_buffers(&ticket, &list, true, NULL);
613 if (r) { 595 if (r) {
614 drm_gem_object_unreference_unlocked(gobj); 596 drm_gem_object_unreference_unlocked(gobj);
615 return r; 597 return r;
@@ -640,10 +622,10 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
640 default: 622 default:
641 break; 623 break;
642 } 624 }
643 ttm_eu_backoff_reservation(&ticket, &list);
644 if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) && 625 if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) &&
645 !amdgpu_vm_debug) 626 !amdgpu_vm_debug)
646 amdgpu_gem_va_update_vm(adev, bo_va, args->operation); 627 amdgpu_gem_va_update_vm(adev, bo_va, &list, args->operation);
628 ttm_eu_backoff_reservation(&ticket, &list);
647 629
648 drm_gem_object_unreference_unlocked(gobj); 630 drm_gem_object_unreference_unlocked(gobj);
649 return r; 631 return r;