drm/amdgpu: reduce reserved VA size
Subsystems (2)
PATCH 1/4 drm/amdgpu: reduce reserved VA size
1MB should be more than enough, currently we use about 8K.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -1
@@ -99,7 +99,7 @@ struct amdgpu_bo_list_entry;#define AMDGPU_MMHUB 1/* hardcode that limit for now */ -#define AMDGPU_VA_RESERVED_SIZE (8ULL << 20) +#define AMDGPU_VA_RESERVED_SIZE (1ULL << 20)/* VA hole for 48bit addresses on Vega10 */ #define AMDGPU_VA_HOLE_START 0x0000800000000000ULL
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180123101554.25390-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/4 drm/amdgpu: apply top reserved VA space to pre Vega10 as well
Reserve VA space at the top for older generations as well.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
@@ -580,11 +580,11 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file dev_info.ids_flags |=AMDGPU_IDS_FLAGS_PREEMPTION ; vm_size = adev->vm_manager.max_pfn *AMDGPU_GPU_PAGE_SIZE ; + vm_size -=AMDGPU_VA_RESERVED_SIZE ; dev_info.virtual_address_offset =AMDGPU_VA_RESERVED_SIZE ; dev_info.virtual_address_max =min (vm_size,AMDGPU_VA_HOLE_START ); - vm_size -=AMDGPU_VA_RESERVED_SIZE ;if (vm_size >AMDGPU_VA_HOLE_START ) { dev_info.high_va_offset =AMDGPU_VA_HOLE_END ; dev_info.high_va_max =AMDGPU_VA_HOLE_END | vm_size;
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +2 -1
@@ -468,7 +468,8 @@ static void gmc_v6_0_set_prt(struct amdgpu_device *adev, bool enable)if (enable) {uint32_t low =AMDGPU_VA_RESERVED_SIZE >>AMDGPU_GPU_PAGE_SHIFT ; -uint32_t high = adev->vm_manager.max_pfn; +uint32_t high = adev->vm_manager.max_pfn - + (AMDGPU_VA_RESERVED_SIZE >>AMDGPU_GPU_PAGE_SHIFT );WREG32 (mmVM_PRT_APERTURE0_LOW_ADDR, low);WREG32 (mmVM_PRT_APERTURE1_LOW_ADDR, low);
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +2 -1
@@ -561,7 +561,8 @@ static void gmc_v7_0_set_prt(struct amdgpu_device *adev, bool enable)if (enable) {uint32_t low =AMDGPU_VA_RESERVED_SIZE >>AMDGPU_GPU_PAGE_SHIFT ; -uint32_t high = adev->vm_manager.max_pfn; +uint32_t high = adev->vm_manager.max_pfn - + (AMDGPU_VA_RESERVED_SIZE >>AMDGPU_GPU_PAGE_SHIFT );WREG32 (mmVM_PRT_APERTURE0_LOW_ADDR, low);WREG32 (mmVM_PRT_APERTURE1_LOW_ADDR, low);
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +2 -1
@@ -761,7 +761,8 @@ static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)if (enable) {uint32_t low =AMDGPU_VA_RESERVED_SIZE >>AMDGPU_GPU_PAGE_SHIFT ; -uint32_t high = adev->vm_manager.max_pfn; +uint32_t high = adev->vm_manager.max_pfn - + (AMDGPU_VA_RESERVED_SIZE >>AMDGPU_GPU_PAGE_SHIFT );WREG32 (mmVM_PRT_APERTURE0_LOW_ADDR, low);WREG32 (mmVM_PRT_APERTURE1_LOW_ADDR, low);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: consistently use AMDGPU_CSA_VADDR
In reply to a message not in the archiveInstead of repeating this multiple times.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +5 -5
@@ -7147,12 +7147,12 @@ static void gfx_v8_0_ring_emit_ce_meta(struct amdgpu_ring *ring) } ce_payload = {};if (ring->adev->virt.chained_ib_support) { - ce_payload_addr =AMDGPU_VA_RESERVED_SIZE -2 *4096 + - offsetof(struct vi_gfx_meta_data_chained_ib , ce_payload); + ce_payload_addr =AMDGPU_CSA_VADDR + + offsetof(struct vi_gfx_meta_data_chained_ib , ce_payload); cnt_ce = (sizeof (ce_payload.chained) >>2 ) +4 -2 ; }else { - ce_payload_addr =AMDGPU_VA_RESERVED_SIZE -2 *4096 + - offsetof(struct vi_gfx_meta_data , ce_payload); + ce_payload_addr =AMDGPU_CSA_VADDR + + offsetof(struct vi_gfx_meta_data , ce_payload); cnt_ce = (sizeof (ce_payload.regular) >>2 ) +4 -2 ; }
@@ -7175,7 +7175,7 @@ static void gfx_v8_0_ring_emit_de_meta(struct amdgpu_ring *ring)struct vi_de_ib_state_chained_ib chained; } de_payload = {}; - csa_addr =AMDGPU_VA_RESERVED_SIZE -2 *4096 ; + csa_addr =AMDGPU_CSA_VADDR ; gds_addr = csa_addr +4096 ;if (ring->adev->virt.chained_ib_support) { de_payload.chained.gds_backup_addrlo =lower_32_bits (gds_addr);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
@@ -3873,7 +3873,7 @@ static void gfx_v9_0_ring_emit_ce_meta(struct amdgpu_ring *ring)int cnt; cnt = (sizeof (ce_payload) >>2 ) +4 -2 ; - csa_addr =AMDGPU_VA_RESERVED_SIZE -2 *4096 ; + csa_addr =AMDGPU_CSA_VADDR ;amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
@@ -3891,7 +3891,7 @@ static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring)uint64_t csa_addr, gds_addr;int cnt; - csa_addr =AMDGPU_VA_RESERVED_SIZE -2 *4096 ; + csa_addr =AMDGPU_CSA_VADDR ; gds_addr = csa_addr +4096 ; de_payload.gds_backup_addrlo =lower_32_bits (gds_addr); de_payload.gds_backup_addrhi =upper_32_bits (gds_addr);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: move static CSA address to top of address space v2
In reply to a message not in the archiveMove 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 24 ++++++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 +++-- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++-- 4 files changed, 26 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +18 -6
@@ -24,6 +24,18 @@#include "amdgpu.h" #define MAX_KIQ_REG_WAIT 100000000/* in usecs */ +uint64_t amdgpu_csa_vaddr (struct amdgpu_device *adev) +{ +uint64_t addr = adev->vm_manager.max_pfn <<AMDGPU_GPU_PAGE_SHIFT ; + + addr -=AMDGPU_VA_RESERVED_SIZE ; + +if (addr >=AMDGPU_VA_HOLE_START ) + addr |=AMDGPU_VA_HOLE_END ; + +return addr; +} +bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev) {/* By now all MMIO pages except mailbox are blocked */
@@ -55,14 +67,14 @@ void amdgpu_free_static_csa(struct amdgpu_device *adev) {/* * amdgpu_map_static_csa should be called during amdgpu_vm_init -* it maps virtual address "AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE" -* to this VM, and each command submission of GFX should use this virtual -* address within META_DATA init package to support SRIOV gfx preemption. +* it maps virtual address amdgpu_csa_vaddr() to this VM, and each command +* submission of GFX should use this virtual address within META_DATA init +* package to support SRIOV gfx preemption. */ -int amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_bo_va **bo_va) { +uint64_t csa_addr =amdgpu_csa_vaddr (adev) &AMDGPU_VA_HOLE_MASK ;struct ww_acquire_ctx ticket;struct list_head list;struct amdgpu_bo_list_entry pd;
@@ -90,7 +102,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,return -ENOMEM ; } - r =amdgpu_vm_alloc_pts (adev, (*bo_va)->base.vm,AMDGPU_CSA_VADDR , + r =amdgpu_vm_alloc_pts (adev, (*bo_va)->base.vm, csa_addr,AMDGPU_CSA_SIZE );if (r) {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,return r; } - r =amdgpu_vm_bo_map (adev, *bo_va,AMDGPU_CSA_VADDR ,0 ,AMDGPU_CSA_SIZE , + r =amdgpu_vm_bo_map (adev, *bo_va, csa_addr,0 ,AMDGPU_CSA_SIZE ,AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE |AMDGPU_PTE_EXECUTABLE );
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +3 -2
@@ -251,8 +251,7 @@ struct amdgpu_virt {uint32_t gim_feature; }; -#define AMDGPU_CSA_SIZE (8 * 1024) -#define AMDGPU_CSA_VADDR (AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE) +#define AMDGPU_CSA_SIZE (8 * 1024)#define amdgpu_sriov_enabled (adev) \ ((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)
@@ -279,6 +278,8 @@ static inline bool is_virtual_machine(void) }struct amdgpu_vm ; + +uint64_t amdgpu_csa_vaddr (struct amdgpu_device *adev);bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev);int amdgpu_allocate_static_csa (struct amdgpu_device *adev); int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -3
@@ -7147,11 +7147,11 @@ static void gfx_v8_0_ring_emit_ce_meta(struct amdgpu_ring *ring) } ce_payload = {};if (ring->adev->virt.chained_ib_support) { - ce_payload_addr =AMDGPU_CSA_VADDR + + ce_payload_addr =amdgpu_csa_vaddr (ring->adev) + offsetof(struct vi_gfx_meta_data_chained_ib , ce_payload); cnt_ce = (sizeof (ce_payload.chained) >>2 ) +4 -2 ; }else { - ce_payload_addr =AMDGPU_CSA_VADDR + + ce_payload_addr =amdgpu_csa_vaddr (ring->adev) + offsetof(struct vi_gfx_meta_data , ce_payload); cnt_ce = (sizeof (ce_payload.regular) >>2 ) +4 -2 ; }
@@ -7175,7 +7175,7 @@ static void gfx_v8_0_ring_emit_de_meta(struct amdgpu_ring *ring)struct vi_de_ib_state_chained_ib chained; } de_payload = {}; - csa_addr =AMDGPU_CSA_VADDR ; + csa_addr =amdgpu_csa_vaddr (ring->adev); gds_addr = csa_addr +4096 ;if (ring->adev->virt.chained_ib_support) { de_payload.chained.gds_backup_addrlo =lower_32_bits (gds_addr);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
@@ -3873,7 +3873,7 @@ static void gfx_v9_0_ring_emit_ce_meta(struct amdgpu_ring *ring)int cnt; cnt = (sizeof (ce_payload) >>2 ) +4 -2 ; - csa_addr =AMDGPU_CSA_VADDR ; + csa_addr =amdgpu_csa_vaddr (ring->adev);amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
@@ -3891,7 +3891,7 @@ static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring)uint64_t csa_addr, gds_addr;int cnt; - csa_addr =AMDGPU_CSA_VADDR ; + csa_addr =amdgpu_csa_vaddr (ring->adev); gds_addr = csa_addr +4096 ; de_payload.gds_backup_addrlo =lower_32_bits (gds_addr); de_payload.gds_backup_addrhi =upper_32_bits (gds_addr);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180123101554.25390-4-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 4/4] drm/amdgpu: move static CSA address to top of address space v2
Patches 1-3:
Patch 4:
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Tuesday, January 23, 2018 5:15:54 AM
To: Liu, Monk; [email protected]
Subject: [PATCH 4/4] 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 24 ++++++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 +++-- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++-- 4 files changed, 26 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +18 -6
@@ -24,6 +24,18 @@#include "amdgpu.h" #define MAX_KIQ_REG_WAIT 100000000/* in usecs */ +uint64_t amdgpu_csa_vaddr (struct amdgpu_device *adev) +{ +uint64_t addr = adev->vm_manager.max_pfn <<AMDGPU_GPU_PAGE_SHIFT ; + + addr -=AMDGPU_VA_RESERVED_SIZE ; + +if (addr >=AMDGPU_VA_HOLE_START ) + addr |=AMDGPU_VA_HOLE_END ; + +return addr; +} +bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev) {/* By now all MMIO pages except mailbox are blocked */
@@ -55,14 +67,14 @@ void amdgpu_free_static_csa(struct amdgpu_device *adev) {/* * amdgpu_map_static_csa should be called during amdgpu_vm_init -* it maps virtual address "AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE" -* to this VM, and each command submission of GFX should use this virtual -* address within META_DATA init package to support SRIOV gfx preemption. +* it maps virtual address amdgpu_csa_vaddr() to this VM, and each command +* submission of GFX should use this virtual address within META_DATA init +* package to support SRIOV gfx preemption. */ -int amdgpu_map_static_csa (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_bo_va **bo_va) { +uint64_t csa_addr =amdgpu_csa_vaddr (adev) &AMDGPU_VA_HOLE_MASK ;struct ww_acquire_ctx ticket;struct list_head list;struct amdgpu_bo_list_entry pd;
@@ -90,7 +102,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,return -ENOMEM ; } - r =amdgpu_vm_alloc_pts (adev, (*bo_va)->base.vm,AMDGPU_CSA_VADDR , + r =amdgpu_vm_alloc_pts (adev, (*bo_va)->base.vm, csa_addr,AMDGPU_CSA_SIZE );if (r) {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,return r; } - r =amdgpu_vm_bo_map (adev, *bo_va,AMDGPU_CSA_VADDR ,0 ,AMDGPU_CSA_SIZE , + r =amdgpu_vm_bo_map (adev, *bo_va, csa_addr,0 ,AMDGPU_CSA_SIZE ,AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE |AMDGPU_PTE_EXECUTABLE );
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +3 -2
@@ -251,8 +251,7 @@ struct amdgpu_virt {uint32_t gim_feature; }; -#define AMDGPU_CSA_SIZE (8 * 1024) -#define AMDGPU_CSA_VADDR (AMDGPU_VA_RESERVED_SIZE - AMDGPU_CSA_SIZE) +#define AMDGPU_CSA_SIZE (8 * 1024)#define amdgpu_sriov_enabled (adev) \ ((adev)->virt.caps & AMDGPU_SRIOV_CAPS_ENABLE_IOV)
@@ -279,6 +278,8 @@ static inline bool is_virtual_machine(void) }struct amdgpu_vm ; + +uint64_t amdgpu_csa_vaddr (struct amdgpu_device *adev);bool amdgpu_virt_mmio_blocked (struct amdgpu_device *adev);int amdgpu_allocate_static_csa (struct amdgpu_device *adev); int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +3 -3
@@ -7147,11 +7147,11 @@ static void gfx_v8_0_ring_emit_ce_meta(struct amdgpu_ring *ring) } ce_payload = {};if (ring->adev->virt.chained_ib_support) { - ce_payload_addr =AMDGPU_CSA_VADDR + + ce_payload_addr =amdgpu_csa_vaddr (ring->adev) + offsetof(struct vi_gfx_meta_data_chained_ib , ce_payload); cnt_ce = (sizeof (ce_payload.chained) >>2 ) +4 -2 ; }else { - ce_payload_addr =AMDGPU_CSA_VADDR + + ce_payload_addr =amdgpu_csa_vaddr (ring->adev) + offsetof(struct vi_gfx_meta_data , ce_payload); cnt_ce = (sizeof (ce_payload.regular) >>2 ) +4 -2 ; }
@@ -7175,7 +7175,7 @@ static void gfx_v8_0_ring_emit_de_meta(struct amdgpu_ring *ring)struct vi_de_ib_state_chained_ib chained; } de_payload = {}; - csa_addr =AMDGPU_CSA_VADDR ; + csa_addr =amdgpu_csa_vaddr (ring->adev); gds_addr = csa_addr +4096 ;if (ring->adev->virt.chained_ib_support) { de_payload.chained.gds_backup_addrlo =lower_32_bits (gds_addr);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -2
@@ -3873,7 +3873,7 @@ static void gfx_v9_0_ring_emit_ce_meta(struct amdgpu_ring *ring)int cnt; cnt = (sizeof (ce_payload) >>2 ) +4 -2 ; - csa_addr =AMDGPU_CSA_VADDR ; + csa_addr =amdgpu_csa_vaddr (ring->adev);amdgpu_ring_write (ring,PACKET3 (PACKET3_WRITE_DATA , cnt)); amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(2) |
@@ -3891,7 +3891,7 @@ static void gfx_v9_0_ring_emit_de_meta(struct amdgpu_ring *ring)uint64_t csa_addr, gds_addr;int cnt; - csa_addr =AMDGPU_CSA_VADDR ; + csa_addr =amdgpu_csa_vaddr (ring->adev); gds_addr = csa_addr +4096 ; de_payload.gds_backup_addrlo =lower_32_bits (gds_addr); de_payload.gds_backup_addrhi =upper_32_bits (gds_addr);
--
2.14.1
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx