aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2017-12-14 16:39:02 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-18 10:59:35 -0500
commitf5ec697e37023ce60dc1c38bf6b2bf32de767376 (patch)
treea0c41f14d3a0939c3fb8ddd721f35ceb6345dd2f /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
parent2543e28a81b8d687880315475ba1203ca2f7496a (diff)
drm/amdgpu: move fw_reserve functions to amdgpu_ttm.c
It's the only place they are used. Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c95
1 files changed, 0 insertions, 95 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 09ffa9fbcd92..3135287c0f5b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -597,101 +597,6 @@ void amdgpu_device_gart_location(struct amdgpu_device *adev,
597 mc->gart_size >> 20, mc->gart_start, mc->gart_end); 597 mc->gart_size >> 20, mc->gart_start, mc->gart_end);
598} 598}
599 599
600/*
601 * Firmware Reservation functions
602 */
603/**
604 * amdgpu_fw_reserve_vram_fini - free fw reserved vram
605 *
606 * @adev: amdgpu_device pointer
607 *
608 * free fw reserved vram if it has been reserved.
609 */
610void amdgpu_fw_reserve_vram_fini(struct amdgpu_device *adev)
611{
612 amdgpu_bo_free_kernel(&adev->fw_vram_usage.reserved_bo,
613 NULL, &adev->fw_vram_usage.va);
614}
615
616/**
617 * amdgpu_fw_reserve_vram_init - create bo vram reservation from fw
618 *
619 * @adev: amdgpu_device pointer
620 *
621 * create bo vram reservation from fw.
622 */
623int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev)
624{
625 struct ttm_operation_ctx ctx = { false, false };
626 int r = 0;
627 int i;
628 u64 vram_size = adev->mc.visible_vram_size;
629 u64 offset = adev->fw_vram_usage.start_offset;
630 u64 size = adev->fw_vram_usage.size;
631 struct amdgpu_bo *bo;
632
633 adev->fw_vram_usage.va = NULL;
634 adev->fw_vram_usage.reserved_bo = NULL;
635
636 if (adev->fw_vram_usage.size > 0 &&
637 adev->fw_vram_usage.size <= vram_size) {
638
639 r = amdgpu_bo_create(adev, adev->fw_vram_usage.size,
640 PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
641 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED |
642 AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, NULL, NULL, 0,
643 &adev->fw_vram_usage.reserved_bo);
644 if (r)
645 goto error_create;
646
647 r = amdgpu_bo_reserve(adev->fw_vram_usage.reserved_bo, false);
648 if (r)
649 goto error_reserve;
650
651 /* remove the original mem node and create a new one at the
652 * request position
653 */
654 bo = adev->fw_vram_usage.reserved_bo;
655 offset = ALIGN(offset, PAGE_SIZE);
656 for (i = 0; i < bo->placement.num_placement; ++i) {
657 bo->placements[i].fpfn = offset >> PAGE_SHIFT;
658 bo->placements[i].lpfn = (offset + size) >> PAGE_SHIFT;
659 }
660
661 ttm_bo_mem_put(&bo->tbo, &bo->tbo.mem);
662 r = ttm_bo_mem_space(&bo->tbo, &bo->placement,
663 &bo->tbo.mem, &ctx);
664 if (r)
665 goto error_pin;
666
667 r = amdgpu_bo_pin_restricted(adev->fw_vram_usage.reserved_bo,
668 AMDGPU_GEM_DOMAIN_VRAM,
669 adev->fw_vram_usage.start_offset,
670 (adev->fw_vram_usage.start_offset +
671 adev->fw_vram_usage.size), NULL);
672 if (r)
673 goto error_pin;
674 r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo,
675 &adev->fw_vram_usage.va);
676 if (r)
677 goto error_kmap;
678
679 amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo);
680 }
681 return r;
682
683error_kmap:
684 amdgpu_bo_unpin(adev->fw_vram_usage.reserved_bo);
685error_pin:
686 amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo);
687error_reserve:
688 amdgpu_bo_unref(&adev->fw_vram_usage.reserved_bo);
689error_create:
690 adev->fw_vram_usage.va = NULL;
691 adev->fw_vram_usage.reserved_bo = NULL;
692 return r;
693}
694
695/** 600/**
696 * amdgpu_device_resize_fb_bar - try to resize FB BAR 601 * amdgpu_device_resize_fb_bar - try to resize FB BAR
697 * 602 *