aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-01-22 05:25:48 -0500
committerAlex Deucher <alexander.deucher@amd.com>2018-02-19 14:18:48 -0500
commit6f05c4e9d1a1a743eca76ddbad788386d7bb534e (patch)
treee0a0fcc298614661f925a0cfc8db73acf54c14d0 /drivers/gpu
parentc1f2fb6b6371980dfdaea1ceba7269ccac6fda3f (diff)
drm/amdgpu: move static CSA address to top of address space v2
Move the CSA area to the top of the VA space to avoid clashing with HMM/ATC in the lower range on GFX9. v2: wrong sign noticed by Roger, rebase on CSA_VADDR cleanup, handle VA hole on GFX9 as well. Signed-off-by: Christian König <christian.koenig@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Acked-by: Monk Liu <monk.liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c24
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c4
4 files changed, 26 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index e7dfb7b44b4b..b832651d2137 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -24,6 +24,18 @@
24#include "amdgpu.h" 24#include "amdgpu.h"
25#define MAX_KIQ_REG_WAIT 100000000 /* in usecs */ 25#define MAX_KIQ_REG_WAIT 100000000 /* in usecs */
26 26
27uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev)
28{
29 uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
30
31 addr -= AMDGPU_VA_RESERVED_SIZE;
32
33 if (addr >= AMDGPU_VA_HOLE_START)
34 addr |= AMDGPU_VA_HOLE_END;
35
36 return addr;
37}
38
27bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev) 39bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev)
28{ 40{
29 /* By now all MMIO pages except mailbox are blocked */ 41 /* By now all MMIO pages except mailbox are blocked */
@@ -55,14 +67,14 @@ void amdgpu_free_static_csa(struct amdgpu_device *adev) {
55 67
56/* 68/*
57 * amdgpu_map_static_csa should be called during amdgpu_vm_init 69 * amdgpu_map_static_csa should be called during amdgpu_vm_init
58 * it maps virtual address "AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE" 70 * it maps virtual address amdgpu_csa_vaddr() to this VM, and each command
59 * to this VM, and each command submission of GFX should use this virtual 71 * submission of GFX should use this virtual address within META_DATA init
60 * address within META_DATA init package to support SRIOV gfx preemption. 72 * package to support SRIOV gfx preemption.
61 */ 73 */
62
63int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, 74int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
64 struct amdgpu_bo_va **bo_va) 75 struct amdgpu_bo_va **bo_va)
65{ 76{
77 uint64_t csa_addr = amdgpu_csa_vaddr(adev) & AMDGPU_VA_HOLE_MASK;
66 struct ww_acquire_ctx ticket; 78 struct ww_acquire_ctx ticket;
67 struct list_head list; 79 struct list_head list;
68 struct amdgpu_bo_list_entry pd; 80 struct amdgpu_bo_list_entry pd;
@@ -90,7 +102,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
90 return -ENOMEM; 102 return -ENOMEM;
91 } 103 }
92 104
93 r = amdgpu_vm_alloc_pts(adev, (*bo_va)->base.vm, AMDGPU_CSA_VADDR, 105 r = amdgpu_vm_alloc_pts(adev, (*bo_va)->base.vm, csa_addr,
94 AMDGPU_CSA_SIZE); 106 AMDGPU_CSA_SIZE);
95 if (r) { 107 if (r) {
96 DRM_ERROR("failed to allocate pts for static CSA, err=%d\n", r); 108 DRM_ERROR("failed to allocate pts for static CSA, err=%d\n", r);
@@ -99,7 +111,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
99 return r; 111 return r;
100 } 112 }
101 113
102 r = amdgpu_vm_bo_map(adev, *bo_va, AMDGPU_CSA_VADDR, 0, AMDGPU_CSA_SIZE, 114 r = amdgpu_vm_bo_map(adev, *bo_va, csa_addr, 0, AMDGPU_CSA_SIZE,
103 AMDGPU_PTE_READABLE | AMDGPU_PTE_WRITEABLE | 115 AMDGPU_PTE_READABLE | AMDGPU_PTE_WRITEABLE |
104 AMDGPU_PTE_EXECUTABLE); 116 AMDGPU_PTE_EXECUTABLE);
105 117
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index 6a83425aa9ed..880ac113a3a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
@@ -251,8 +251,7 @@ struct amdgpu_virt {
251 uint32_t gim_feature; 251 uint32_t gim_feature;
252}; 252};
253 253
254#define AMDGPU_CSA_SIZE (8 * 1024) 254#define AMDGPU_CSA_SIZE (8 * 1024)
255#define AMDGPU_CSA_VADDR (AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE)
256 255
257#define amdgpu_sriov_enabled(adev) \ 256#define amdgpu_sriov_enabled(adev) \
258((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV) 257((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)
@@ -279,6 +278,8 @@ static inline bool is_virtual_machine(void)
279} 278}
280 279
281struct amdgpu_vm; 280struct amdgpu_vm;
281
282uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev);
282bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev); 283bool amdgpu_virt_mmio_blocked(struct amdgpu_device *adev);
283int amdgpu_allocate_static_csa(struct amdgpu_device *adev); 284int amdgpu_allocate_static_csa(struct amdgpu_device *adev);
284int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, 285int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index 960c35cc2e9c..1207f361f28b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -7132,11 +7132,11 @@ static void gfx_v8_0_ring_emit_ce_meta(struct amdgpu_ring *ring)
7132 } ce_payload = {}; 7132 } ce_payload = {};
7133 7133
7134 if (ring->adev->virt.chained_ib_support) { 7134 if (ring->adev->virt.chained_ib_support) {
7135 ce_payload_addr = AMDGPU_CSA_VADDR + 7135 ce_payload_addr = amdgpu_csa_vaddr(ring->adev) +
7136 offsetof(struct vi_gfx_meta_data_chained_ib, ce_payload); 7136 offsetof(struct vi_gfx_meta_data_chained_ib, ce_payload);
7137 cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2; 7137 cnt_ce = (sizeof(ce_payload.chained) >> 2) + 4 - 2;
7138 } else { 7138 } else {
7139 ce_payload_addr = AMDGPU_CSA_VADDR + 7139 ce_payload_addr = amdgpu_csa_vaddr(ring->adev) +
7140 offsetof(struct vi_gfx_meta_data, ce_payload); 7140 offsetof(struct vi_gfx_meta_data, ce_payload);
7141 cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2; 7141 cnt_ce = (sizeof(ce_payload.regular) >> 2) + 4 - 2;
7142 } 7142 }
@@ -7160,7 +7160,7 @@ static void gfx_v8_0_ring_emit_de_meta(struct amdgpu_ring *ring)
7160 struct vi_de_ib_state_chained_ib chained; 7160 struct vi_de_ib_state_chained_ib chained;
7161 } de_payload = {}; 7161 } de_payload = {};
7162 7162
7163 csa_addr = AMDGPU_CSA_VADDR; 7163 csa_addr = amdgpu_csa_vaddr(ring->adev);
7164 gds_addr = csa_addr + 4096; 7164 gds_addr = csa_addr + 4096;
7165 if (ring->adev->virt.chained_ib_support) { 7165 if (ring->adev->virt.chained_ib_support) {
7166 de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr); 7166 de_payload.chained.gds_backup_addrlo = lower_32_bits(gds_addr);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
index eb095964689c..e5d5341c459a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -3865,7 +3865,7 @@ static void gfx_v9_0_ring_emit_ce_meta(struct amdgpu_ring *ring)
3865 int cnt; 3865 int cnt;
3866 3866
3867 cnt = (sizeof(ce_payload) >> 2) + 4 - 2; 3867 cnt = (sizeof(ce_payload) >> 2) + 4 - 2;
3868 csa_addr = AMDGPU_CSA_VADDR; 3868 csa_addr = amdgpu_csa_vaddr(ring->adev);
3869 3869
3870 amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt)); 3870 amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, cnt));
3871 amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) | 3871 amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
@@ -3883,7 +3883,7 @@ static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring)
3883 uint64_t csa_addr, gds_addr; 3883 uint64_t csa_addr, gds_addr;
3884 int cnt; 3884 int cnt;
3885 3885
3886 csa_addr = AMDGPU_CSA_VADDR; 3886 csa_addr = amdgpu_csa_vaddr(ring->adev);
3887 gds_addr = csa_addr + 4096; 3887 gds_addr = csa_addr + 4096;
3888 de_payload.gds_backup_addrlo = lower_32_bits(gds_addr); 3888 de_payload.gds_backup_addrlo = lower_32_bits(gds_addr);
3889 de_payload.gds_backup_addrhi = upper_32_bits(gds_addr); 3889 de_payload.gds_backup_addrhi = upper_32_bits(gds_addr);