[PATCH 1/2] drm/amdgpu/gmc: add a way to force a particular placement for GART
Alex Deucher
alexdeucher at gmail.com
Tue Sep 26 17:30:27 UTC 2023
Ping on this series?
On Thu, Sep 21, 2023 at 5:46 PM Alex Deucher <alexander.deucher at amd.com> wrote:
>
> 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 <alexander.deucher at amd.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index f74a51a93ebb..d1d98488373b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -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.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> index dd0ede75e5d7..fcef057b9213 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -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
>
More information about the amd-gfx
mailing list