drm/amdgpu/gmc: add a way to force a particular placement for GART
Subsystems (2)
Alex Deucher
maintainerPATCH 1/2 drm/amdgpu/gmc: add a way to force a particular placement for GART
We normally place GART based on the location of VRAM and the available address space around that, but provide an option to force a particular location for hardware that needs it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15 -4
@@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) mc->gart_size =max (size_bf, size_af); } -if ((size_bf >= mc->gart_size && size_bf < size_af) || - (size_af < mc->gart_size)) - mc->gart_start =0 ; -else +switch (mc->gart_placement) { +case AMDGPU_GART_PLACEMENT_HIGH : mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; +case AMDGPU_GART_PLACEMENT_LOW : + mc->gart_start =0 ; +break ; +case AMDGPU_GART_PLACEMENT_BEST_FIT : +default : +if ((size_bf >= mc->gart_size && size_bf < size_af) || + (size_af < mc->gart_size)) + mc->gart_start =0 ; +else + mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; + } mc->gart_start &= ~(four_gb -1 ); mc->gart_end = mc->gart_start + mc->gart_size -1 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +8 -0
@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {#define INVALID_PFN -1 +enum amdgpu_gart_placement { +AMDGPU_GART_PLACEMENT_BEST_FIT =0 , +AMDGPU_GART_PLACEMENT_HIGH , +AMDGPU_GART_PLACEMENT_LOW , +}; +struct amdgpu_gmc {/* FB's physical address in MMIO space (for CPU to * map FB). This is different compared to the agp/
@@ -339,6 +345,8 @@ struct amdgpu_gmc {bool flush_tlb_needs_extra_type_0;bool flush_tlb_needs_extra_type_2;bool flush_pasid_uses_kiq; + +enum amdgpu_gart_placement gart_placement; };#define amdgpu_gmc_emit_flush_gpu_tlb (r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
Signature · 1 line
2.41.0
Alex Deucher
maintainerPATCH 2/2 drm/amdgpu/gmc11: set gart placement GC11
Needed to avoid a hardware issue.
v2: force high for all GC11 parts for consistency (Alex)
---
Confirmed that this fixes the issues seen on SR-IOV.
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +3 -0
@@ -687,6 +687,9 @@ static int gmc_v11_0_mc_init(struct amdgpu_device *adev)else adev->gmc.gart_size = (u64 )amdgpu_gart_size <<20 ; +/* force GART to avoid a hw issue in GC11 */ + adev->gmc.gart_placement =AMDGPU_GART_PLACEMENT_HIGH ; +gmc_v11_0_vram_gtt_location (adev, &adev->gmc);return 0 ;
Signature · 1 line
2.41.0
Ping on this series?
Quoted 71 lines · Alex Deucher
We normally place GART based on the location of VRAM and the available address space around that, but provide an option to force a particular location for hardware that needs it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-4@@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) mc->gart_size =max (size_bf, size_af); } -if ((size_bf >= mc->gart_size && size_bf < size_af) || - (size_af < mc->gart_size)) - mc->gart_start =0 ; -else +switch (mc->gart_placement) { +case AMDGPU_GART_PLACEMENT_HIGH : mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; +case AMDGPU_GART_PLACEMENT_LOW : + mc->gart_start =0 ; +break ; +case AMDGPU_GART_PLACEMENT_BEST_FIT : +default : +if ((size_bf >= mc->gart_size && size_bf < size_af) || + (size_af < mc->gart_size)) + mc->gart_start =0 ; +else + mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; + } mc->gart_start &= ~(four_gb -1 ); mc->gart_end = mc->gart_start + mc->gart_size -1 ;drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +8
-1@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {#define INVALID_PFN -1 +enum amdgpu_gart_placement { +AMDGPU_GART_PLACEMENT_BEST_FIT =0 , +AMDGPU_GART_PLACEMENT_HIGH , +AMDGPU_GART_PLACEMENT_LOW , +}; +struct amdgpu_gmc {/* FB's physical address in MMIO space (for CPU to * map FB). This is different compared to the agp/ @@ -339,6 +345,8 @@ struct amdgpu_gmc {bool flush_tlb_needs_extra_type_0;bool flush_tlb_needs_extra_type_2;bool flush_pasid_uses_kiq; + +enum amdgpu_gart_placement gart_placement; };#define amdgpu_gmc_emit_flush_gpu_tlb (r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) --2.41.0
I'm still not happy with moving the GART fixed to the end. We abandoned this for good reasons.
If we really go this way I would prefer to have this as parameter to the amdgpu_gmc_gart_location() function and not in the gmc structure.
Regards,
Christian.
Am 26.09.23 um 19:30 schrieb Alex Deucher:
Quoted 73 lines
Ping on this series?
Quoted 70 lines · Alex Deucher
We normally place GART based on the location of VRAM and the available address space around that, but provide an option to force a particular location for hardware that needs it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-4@@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) mc->gart_size =max (size_bf, size_af); } -if ((size_bf >= mc->gart_size && size_bf < size_af) || - (size_af < mc->gart_size)) - mc->gart_start =0 ; -else +switch (mc->gart_placement) { +case AMDGPU_GART_PLACEMENT_HIGH : mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; +case AMDGPU_GART_PLACEMENT_LOW : + mc->gart_start =0 ; +break ; +case AMDGPU_GART_PLACEMENT_BEST_FIT : +default : +if ((size_bf >= mc->gart_size && size_bf < size_af) || + (size_af < mc->gart_size)) + mc->gart_start =0 ; +else + mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; + } mc->gart_start &= ~(four_gb -1 ); mc->gart_end = mc->gart_start + mc->gart_size -1 ;drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +8
-1@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {#define INVALID_PFN -1 +enum amdgpu_gart_placement { +AMDGPU_GART_PLACEMENT_BEST_FIT =0 , +AMDGPU_GART_PLACEMENT_HIGH , +AMDGPU_GART_PLACEMENT_LOW , +}; +struct amdgpu_gmc {/* FB's physical address in MMIO space (for CPU to * map FB). This is different compared to the agp/ @@ -339,6 +345,8 @@ struct amdgpu_gmc {bool flush_tlb_needs_extra_type_0;bool flush_tlb_needs_extra_type_2;bool flush_pasid_uses_kiq; + +enum amdgpu_gart_placement gart_placement; };#define amdgpu_gmc_emit_flush_gpu_tlb (r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) --2.41.0
Quoted 3 lines · Christian König
I'm still not happy with moving the GART fixed to the end. We abandoned this for good reasons.
We didn't abandon it, there is still code which decides where to put the gart based on the relative sizes of the address space before and after vram. It really comes down to where the vbios decides to put vram. If it starts somewhere lower in the future, gart will naturally end up higher. Also windows always puts gart above vram.
Quoted 3 lines
If we really go this way I would prefer to have this as parameter to the
amdgpu_gmc_gart_location()function and not in the gmc structure.
I can do that.
Alex
Quoted 79 lines
Regards,
Christian.Am 26.09.23 um 19:30 schrieb Alex Deucher:
Quoted 73 lines
Ping on this series?
Quoted 70 lines · Alex Deucher
We normally place GART based on the location of VRAM and the available address space around that, but provide an option to force a particular location for hardware that needs it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-4@@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) mc->gart_size =max (size_bf, size_af); } -if ((size_bf >= mc->gart_size && size_bf < size_af) || - (size_af < mc->gart_size)) - mc->gart_start =0 ; -else +switch (mc->gart_placement) { +case AMDGPU_GART_PLACEMENT_HIGH : mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; +case AMDGPU_GART_PLACEMENT_LOW : + mc->gart_start =0 ; +break ; +case AMDGPU_GART_PLACEMENT_BEST_FIT : +default : +if ((size_bf >= mc->gart_size && size_bf < size_af) || + (size_af < mc->gart_size)) + mc->gart_start =0 ; +else + mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; + } mc->gart_start &= ~(four_gb -1 ); mc->gart_end = mc->gart_start + mc->gart_size -1 ;drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +8
-1@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {#define INVALID_PFN -1 +enum amdgpu_gart_placement { +AMDGPU_GART_PLACEMENT_BEST_FIT =0 , +AMDGPU_GART_PLACEMENT_HIGH , +AMDGPU_GART_PLACEMENT_LOW , +}; +struct amdgpu_gmc {/* FB's physical address in MMIO space (for CPU to * map FB). This is different compared to the agp/ @@ -339,6 +345,8 @@ struct amdgpu_gmc {bool flush_tlb_needs_extra_type_0;bool flush_tlb_needs_extra_type_2;bool flush_pasid_uses_kiq; + +enum amdgpu_gart_placement gart_placement; };#define amdgpu_gmc_emit_flush_gpu_tlb (r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) --2.41.0
Wang, Yang(Kevin)
Reviewed-by[AMD Official Use Only - General]
Series is
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Wednesday, September 27, 2023 1:30 AM
To: Deucher, Alexander <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
Ping on this series?
Quoted 74 lines · Alex Deucher
We normally place GART based on the location of VRAM and the available address space around that, but provide an option to force a particular location for hardware that needs it.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 19 +++++++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 8 ++++++++ 2 files changed, 23 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +15
-4@@ -287,11 +287,22 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc) mc->gart_size =max (size_bf, size_af); } -if ((size_bf >= mc->gart_size && size_bf < size_af) || - (size_af < mc->gart_size)) - mc->gart_start =0 ; -else +switch (mc->gart_placement) { +case AMDGPU_GART_PLACEMENT_HIGH : mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; +case AMDGPU_GART_PLACEMENT_LOW : + mc->gart_start =0 ; +break ; +case AMDGPU_GART_PLACEMENT_BEST_FIT : +default : +if ((size_bf >= mc->gart_size && size_bf < size_af) || + (size_af < mc->gart_size)) + mc->gart_start =0 ; +else + mc->gart_start = max_mc_address - mc->gart_size +1 ; +break ; + } mc->gart_start &= ~(four_gb -1 ); mc->gart_end = mc->gart_start + mc->gart_size - 1; diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
indexdd0ede75e5d7..fcef057b9213100644drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +9
-0@@ -199,6 +199,12 @@ struct amdgpu_mem_partition_info {#define INVALID_PFN -1 +enum amdgpu_gart_placement { +AMDGPU_GART_PLACEMENT_BEST_FIT =0 , +AMDGPU_GART_PLACEMENT_HIGH , +AMDGPU_GART_PLACEMENT_LOW , +}; +struct amdgpu_gmc {/* FB's physical address in MMIO space (for CPU to * map FB). This is different compared to the agp/ @@ -339,6 +345,8 @@ struct amdgpu_gmc { bool flush_tlb_needs_extra_type_0; bool flush_tlb_needs_extra_type_2; bool flush_pasid_uses_kiq; + +enum amdgpu_gart_placement gart_placement; }; #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr)) --
2.41.0