aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index 5617cf62c566..79f9ac29019b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -819,12 +819,33 @@ static int gmc_v6_0_late_init(void *handle)
819{ 819{
820 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 820 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
821 821
822 amdgpu_bo_late_init(adev);
823
822 if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS) 824 if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
823 return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0); 825 return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
824 else 826 else
825 return 0; 827 return 0;
826} 828}
827 829
830static unsigned gmc_v6_0_get_vbios_fb_size(struct amdgpu_device *adev)
831{
832 u32 d1vga_control = RREG32(mmD1VGA_CONTROL);
833 unsigned size;
834
835 if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL, D1VGA_MODE_ENABLE)) {
836 size = 9 * 1024 * 1024; /* reserve 8MB for vga emulator and 1 MB for FB */
837 } else {
838 u32 viewport = RREG32(mmVIEWPORT_SIZE);
839 size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
840 REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_WIDTH) *
841 4);
842 }
843 /* return 0 if the pre-OS buffer uses up most of vram */
844 if ((adev->gmc.real_vram_size - size) < (8 * 1024 * 1024))
845 return 0;
846 return size;
847}
848
828static int gmc_v6_0_sw_init(void *handle) 849static int gmc_v6_0_sw_init(void *handle)
829{ 850{
830 int r; 851 int r;
@@ -851,8 +872,6 @@ static int gmc_v6_0_sw_init(void *handle)
851 872
852 adev->gmc.mc_mask = 0xffffffffffULL; 873 adev->gmc.mc_mask = 0xffffffffffULL;
853 874
854 adev->gmc.stolen_size = 256 * 1024;
855
856 adev->need_dma32 = false; 875 adev->need_dma32 = false;
857 dma_bits = adev->need_dma32 ? 32 : 40; 876 dma_bits = adev->need_dma32 ? 32 : 40;
858 r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); 877 r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits));
@@ -878,6 +897,8 @@ static int gmc_v6_0_sw_init(void *handle)
878 if (r) 897 if (r)
879 return r; 898 return r;
880 899
900 adev->gmc.stolen_size = gmc_v6_0_get_vbios_fb_size(adev);
901
881 r = amdgpu_bo_init(adev); 902 r = amdgpu_bo_init(adev);
882 if (r) 903 if (r)
883 return r; 904 return r;