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.
v2: Switch to passing the placement via parameter
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++++++- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 8 files changed, 31 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +17 -5
@@ -269,7 +269,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc* If GART size is bigger than space left then we ajust GART size. * Thus function will never fails. */ -void amdgpu_gmc_gart_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc) +void amdgpu_gmc_gart_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc, +enum amdgpu_gart_placement gart_placement) {const uint64_t four_gb =0x100000000ULL ;u64 size_af, size_bf;
@@ -287,11 +288,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 (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/
@@ -391,7 +397,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mcvoid amdgpu_gmc_vram_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc,u64 base);void amdgpu_gmc_gart_location (struct amdgpu_device *adev, -struct amdgpu_gmc *mc); +struct amdgpu_gmc *mc, +enum amdgpu_gart_placement gart_placement);void amdgpu_gmc_agp_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc); void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
@@ -670,7 +670,7 @@ static void gmc_v10_0_vram_gtt_location(struct amdgpu_device *adev, base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev))amdgpu_gmc_agp_location (adev, mc);
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
@@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev, base = adev->mmhub.funcs->get_fb_location (adev);amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev) || (amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (11 ,5 ,0 )))amdgpu_gmc_agp_location (adev, mc);
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1 -1
@@ -212,7 +212,7 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }static void gmc_v6_0_mc_program (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
@@ -240,7 +240,7 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }/**
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -414,7 +414,7 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }/**
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -1611,7 +1611,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev,amdgpu_gmc_sysvm_location (adev, mc); }else {amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev))amdgpu_gmc_agp_location (adev, mc); }
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)
v3: rebase
--- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
@@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev, base = adev->mmhub.funcs->get_fb_location (adev);amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_HIGH );if (!amdgpu_sriov_vf (adev) || (amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (11 ,5 ,0 )))amdgpu_gmc_agp_location (adev, mc);
Signature · 1 line
2.41.0
Ping on this series? Fixes an issue for SR-IOV in stress tests.
Alex
Quoted 168 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.
v2: Switch to passing the placement via parameter
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++++++- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 8 files changed, 31 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +17
-5@@ -269,7 +269,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc* If GART size is bigger than space left then we ajust GART size. * Thus function will never fails. */ -void amdgpu_gmc_gart_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc) +void amdgpu_gmc_gart_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc, +enum amdgpu_gart_placement gart_placement) {const uint64_t four_gb =0x100000000ULL ;u64 size_af, size_bf;@@ -287,11 +288,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 (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/ @@ -391,7 +397,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mcvoid amdgpu_gmc_vram_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc,u64 base);void amdgpu_gmc_gart_location (struct amdgpu_device *adev, -struct amdgpu_gmc *mc); +struct amdgpu_gmc *mc, +enum amdgpu_gart_placement gart_placement);void amdgpu_gmc_agp_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc); void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-1@@ -670,7 +670,7 @@ static void gmc_v10_0_vram_gtt_location(struct amdgpu_device *adev, base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev))amdgpu_gmc_agp_location (adev, mc);drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1
-1@@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev, base = adev->mmhub.funcs->get_fb_location (adev);amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev) || (amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (11 ,5 ,0 )))amdgpu_gmc_agp_location (adev, mc);drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1
-1@@ -212,7 +212,7 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }static void gmc_v6_0_mc_program (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1
-1@@ -240,7 +240,7 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }/** drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1
-1@@ -414,7 +414,7 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }/** drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-2@@ -1611,7 +1611,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev,amdgpu_gmc_sysvm_location (adev, mc); }else {amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev))amdgpu_gmc_agp_location (adev, mc); } --2.41.0
As discussed on yesterdays call feel free to add my rb to the series.
Christian.
Am 28.09.23 um 15:23 schrieb Alex Deucher:
Quoted 172 lines
Ping on this series? Fixes an issue for SR-IOV in stress tests.
Alex
Quoted 167 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.
v2: Switch to passing the placement via parameter
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 22 +++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 9 ++++++++- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 8 files changed, 31 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +17
-5@@ -269,7 +269,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc* If GART size is bigger than space left then we ajust GART size. * Thus function will never fails. */ -void amdgpu_gmc_gart_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc) +void amdgpu_gmc_gart_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc, +enum amdgpu_gart_placement gart_placement) {const uint64_t four_gb =0x100000000ULL ;u64 size_af, size_bf;@@ -287,11 +288,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 (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/ @@ -391,7 +397,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mcvoid amdgpu_gmc_vram_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc,u64 base);void amdgpu_gmc_gart_location (struct amdgpu_device *adev, -struct amdgpu_gmc *mc); +struct amdgpu_gmc *mc, +enum amdgpu_gart_placement gart_placement);void amdgpu_gmc_agp_location (struct amdgpu_device *adev,struct amdgpu_gmc *mc); void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-1@@ -670,7 +670,7 @@ static void gmc_v10_0_vram_gtt_location(struct amdgpu_device *adev, base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size;amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev))amdgpu_gmc_agp_location (adev, mc);drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1
-1@@ -634,7 +634,7 @@ static void gmc_v11_0_vram_gtt_location(struct amdgpu_device *adev, base = adev->mmhub.funcs->get_fb_location (adev);amdgpu_gmc_vram_location (adev, &adev->gmc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev) || (amdgpu_ip_version (adev,GC_HWIP ,0 ) <IP_VERSION (11 ,5 ,0 )))amdgpu_gmc_agp_location (adev, mc);drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1
-1@@ -212,7 +212,7 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }static void gmc_v6_0_mc_program (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1
-1@@ -240,7 +240,7 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }/** drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1
-1@@ -414,7 +414,7 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, base <<=24 ;amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT ); }/** drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1
-2@@ -1611,7 +1611,7 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev,amdgpu_gmc_sysvm_location (adev, mc); }else {amdgpu_gmc_vram_location (adev, mc, base); -amdgpu_gmc_gart_location (adev, mc); +amdgpu_gmc_gart_location (adev, mc,AMDGPU_GART_PLACEMENT_BEST_FIT );if (!amdgpu_sriov_vf (adev))amdgpu_gmc_agp_location (adev, mc); } --2.41.0