aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-08-27 12:22:31 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-09-10 23:41:24 -0400
commitad9a5b78f585e9a9bd5ad06dfaf1269659a99f43 (patch)
tree3353b464a93fb9c6a0531a77815f3f838ae4b7f5 /drivers/gpu/drm/amd/amdgpu
parentbcdc9fd634d1f0949774690e9e79ffdfc5d094c8 (diff)
drm/amdgpu: correctly sign extend 48bit addresses v3
Correct sign extend the GMC addresses to 48bit. v2: sign extending turned out easier than thought. v3: clean up the defines and move them into amdgpu_gmc.h as well Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h26
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c7
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h13
9 files changed, 44 insertions, 32 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index 8bee9a0a1dec..db9872f83d03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -135,7 +135,7 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
135 .num_queue_per_pipe = adev->gfx.mec.num_queue_per_pipe, 135 .num_queue_per_pipe = adev->gfx.mec.num_queue_per_pipe,
136 .gpuvm_size = min(adev->vm_manager.max_pfn 136 .gpuvm_size = min(adev->vm_manager.max_pfn
137 << AMDGPU_GPU_PAGE_SHIFT, 137 << AMDGPU_GPU_PAGE_SHIFT,
138 AMDGPU_VA_HOLE_START), 138 AMDGPU_GMC_HOLE_START),
139 .drm_render_minor = adev->ddev->render->index 139 .drm_render_minor = adev->ddev->render->index
140 }; 140 };
141 141
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 04a2733b5ccc..135d9d8c9506 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -835,7 +835,7 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
835 if (chunk->chunk_id != AMDGPU_CHUNK_ID_IB) 835 if (chunk->chunk_id != AMDGPU_CHUNK_ID_IB)
836 continue; 836 continue;
837 837
838 va_start = chunk_ib->va_start & AMDGPU_VA_HOLE_MASK; 838 va_start = chunk_ib->va_start & AMDGPU_GMC_HOLE_MASK;
839 r = amdgpu_cs_find_mapping(p, va_start, &aobj, &m); 839 r = amdgpu_cs_find_mapping(p, va_start, &aobj, &m);
840 if (r) { 840 if (r) {
841 DRM_ERROR("IB va_start is invalid\n"); 841 DRM_ERROR("IB va_start is invalid\n");
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 71792d820ae0..d30a0838851b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -572,16 +572,16 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
572 return -EINVAL; 572 return -EINVAL;
573 } 573 }
574 574
575 if (args->va_address >= AMDGPU_VA_HOLE_START && 575 if (args->va_address >= AMDGPU_GMC_HOLE_START &&
576 args->va_address < AMDGPU_VA_HOLE_END) { 576 args->va_address < AMDGPU_GMC_HOLE_END) {
577 dev_dbg(&dev->pdev->dev, 577 dev_dbg(&dev->pdev->dev,
578 "va_address 0x%LX is in VA hole 0x%LX-0x%LX\n", 578 "va_address 0x%LX is in VA hole 0x%LX-0x%LX\n",
579 args->va_address, AMDGPU_VA_HOLE_START, 579 args->va_address, AMDGPU_GMC_HOLE_START,
580 AMDGPU_VA_HOLE_END); 580 AMDGPU_GMC_HOLE_END);
581 return -EINVAL; 581 return -EINVAL;
582 } 582 }
583 583
584 args->va_address &= AMDGPU_VA_HOLE_MASK; 584 args->va_address &= AMDGPU_GMC_HOLE_MASK;
585 585
586 if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) { 586 if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) {
587 dev_dbg(&dev->pdev->dev, "invalid flags combination 0x%08X\n", 587 dev_dbg(&dev->pdev->dev, "invalid flags combination 0x%08X\n",
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 588a62f7aebc..d84ef1634eb2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -30,6 +30,19 @@
30 30
31#include "amdgpu_irq.h" 31#include "amdgpu_irq.h"
32 32
33/* VA hole for 48bit addresses on Vega10 */
34#define AMDGPU_GMC_HOLE_START 0x0000800000000000ULL
35#define AMDGPU_GMC_HOLE_END 0xffff800000000000ULL
36
37/*
38 * Hardware is programmed as if the hole doesn't exists with start and end
39 * address values.
40 *
41 * This mask is used to remove the upper 16bits of the VA and so come up with
42 * the linear addr value.
43 */
44#define AMDGPU_GMC_HOLE_MASK 0x0000ffffffffffffULL
45
33struct firmware; 46struct firmware;
34 47
35/* 48/*
@@ -133,6 +146,19 @@ static inline bool amdgpu_gmc_vram_full_visible(struct amdgpu_gmc *gmc)
133 return (gmc->real_vram_size == gmc->visible_vram_size); 146 return (gmc->real_vram_size == gmc->visible_vram_size);
134} 147}
135 148
149/**
150 * amdgpu_gmc_sign_extend - sign extend the given gmc address
151 *
152 * @addr: address to extend
153 */
154static inline uint64_t amdgpu_gmc_sign_extend(uint64_t addr)
155{
156 if (addr >= AMDGPU_GMC_HOLE_START)
157 addr |= AMDGPU_GMC_HOLE_END;
158
159 return addr;
160}
161
136void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level, 162void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
137 uint64_t *addr, uint64_t *flags); 163 uint64_t *addr, uint64_t *flags);
138uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo); 164uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index ad7978bab5fc..86e8772b6852 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -655,11 +655,11 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
655 655
656 dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE; 656 dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
657 dev_info.virtual_address_max = 657 dev_info.virtual_address_max =
658 min(vm_size, AMDGPU_VA_HOLE_START); 658 min(vm_size, AMDGPU_GMC_HOLE_START);
659 659
660 if (vm_size > AMDGPU_VA_HOLE_START) { 660 if (vm_size > AMDGPU_GMC_HOLE_START) {
661 dev_info.high_va_offset = AMDGPU_VA_HOLE_END; 661 dev_info.high_va_offset = AMDGPU_GMC_HOLE_END;
662 dev_info.high_va_max = AMDGPU_VA_HOLE_END | vm_size; 662 dev_info.high_va_max = AMDGPU_GMC_HOLE_END | vm_size;
663 } 663 }
664 dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE); 664 dev_info.virtual_address_alignment = max((int)PAGE_SIZE, AMDGPU_GPU_PAGE_SIZE);
665 dev_info.pte_fragment_size = (1 << adev->vm_manager.fragment_size) * AMDGPU_GPU_PAGE_SIZE; 665 dev_info.pte_fragment_size = (1 << adev->vm_manager.fragment_size) * AMDGPU_GPU_PAGE_SIZE;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index b5f20b42439e..0cbf651a88a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -1368,7 +1368,7 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
1368 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_VRAM && 1368 WARN_ON_ONCE(bo->tbo.mem.mem_type == TTM_PL_VRAM &&
1369 !(bo->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)); 1369 !(bo->flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS));
1370 1370
1371 return bo->tbo.offset; 1371 return amdgpu_gmc_sign_extend(bo->tbo.offset);
1372} 1372}
1373 1373
1374/** 1374/**
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 38856365580d..f2f358aa0597 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -28,9 +28,7 @@ uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev)
28 uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT; 28 uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
29 29
30 addr -= AMDGPU_VA_RESERVED_SIZE; 30 addr -= AMDGPU_VA_RESERVED_SIZE;
31 31 addr = amdgpu_gmc_sign_extend(addr);
32 if (addr >= AMDGPU_VA_HOLE_START)
33 addr |= AMDGPU_VA_HOLE_END;
34 32
35 return addr; 33 return addr;
36} 34}
@@ -73,7 +71,7 @@ void amdgpu_free_static_csa(struct amdgpu_device *adev) {
73int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, 71int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
74 struct amdgpu_bo_va **bo_va) 72 struct amdgpu_bo_va **bo_va)
75{ 73{
76 uint64_t csa_addr = amdgpu_csa_vaddr(adev) & AMDGPU_VA_HOLE_MASK; 74 uint64_t csa_addr = amdgpu_csa_vaddr(adev) & AMDGPU_GMC_HOLE_MASK;
77 struct ww_acquire_ctx ticket; 75 struct ww_acquire_ctx ticket;
78 struct list_head list; 76 struct list_head list;
79 struct amdgpu_bo_list_entry pd; 77 struct amdgpu_bo_list_entry pd;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 1f79a0ddc78a..3163351508cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -492,7 +492,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
492 if (level == adev->vm_manager.root_level) { 492 if (level == adev->vm_manager.root_level) {
493 ats_entries = amdgpu_vm_level_shift(adev, level); 493 ats_entries = amdgpu_vm_level_shift(adev, level);
494 ats_entries += AMDGPU_GPU_PAGE_SHIFT; 494 ats_entries += AMDGPU_GPU_PAGE_SHIFT;
495 ats_entries = AMDGPU_VA_HOLE_START >> ats_entries; 495 ats_entries = AMDGPU_GMC_HOLE_START >> ats_entries;
496 ats_entries = min(ats_entries, entries); 496 ats_entries = min(ats_entries, entries);
497 entries -= ats_entries; 497 entries -= ats_entries;
498 } else { 498 } else {
@@ -722,7 +722,7 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,
722 eaddr = saddr + size - 1; 722 eaddr = saddr + size - 1;
723 723
724 if (vm->pte_support_ats) 724 if (vm->pte_support_ats)
725 ats = saddr < AMDGPU_VA_HOLE_START; 725 ats = saddr < AMDGPU_GMC_HOLE_START;
726 726
727 saddr /= AMDGPU_GPU_PAGE_SIZE; 727 saddr /= AMDGPU_GPU_PAGE_SIZE;
728 eaddr /= AMDGPU_GPU_PAGE_SIZE; 728 eaddr /= AMDGPU_GPU_PAGE_SIZE;
@@ -2016,7 +2016,8 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
2016 struct amdgpu_bo_va_mapping, list); 2016 struct amdgpu_bo_va_mapping, list);
2017 list_del(&mapping->list); 2017 list_del(&mapping->list);
2018 2018
2019 if (vm->pte_support_ats && mapping->start < AMDGPU_VA_HOLE_START) 2019 if (vm->pte_support_ats &&
2020 mapping->start < AMDGPU_GMC_HOLE_START)
2020 init_pte_value = AMDGPU_PTE_DEFAULT_ATC; 2021 init_pte_value = AMDGPU_PTE_DEFAULT_ATC;
2021 2022
2022 r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm, 2023 r = amdgpu_vm_bo_update_mapping(adev, NULL, NULL, vm,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 6ea162ca296a..e275ee7c1bc1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -101,19 +101,6 @@ struct amdgpu_bo_list_entry;
101/* hardcode that limit for now */ 101/* hardcode that limit for now */
102#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20) 102#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20)
103 103
104/* VA hole for 48bit addresses on Vega10 */
105#define AMDGPU_VA_HOLE_START 0x0000800000000000ULL
106#define AMDGPU_VA_HOLE_END 0xffff800000000000ULL
107
108/*
109 * Hardware is programmed as if the hole doesn't exists with start and end
110 * address values.
111 *
112 * This mask is used to remove the upper 16bits of the VA and so come up with
113 * the linear addr value.
114 */
115#define AMDGPU_VA_HOLE_MASK 0x0000ffffffffffffULL
116
117/* max vmids dedicated for process */ 104/* max vmids dedicated for process */
118#define AMDGPU_VM_MAX_RESERVED_VMID 1 105#define AMDGPU_VM_MAX_RESERVED_VMID 1
119 106