[PATCH 1/4] drm/amdgpu/gmc: add a way to force a particular placement for GART

Christian König christian.koenig at amd.com
Tue Sep 19 06:10:36 UTC 2023


Am 14.09.23 um 20:21 schrieb 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.

Ah, somehow that patch arrived delayed in my inbox.

>
> 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 |  7 +++++++
>   2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> index c7793db6d098..c41321c456fe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
> @@ -286,11 +286,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;
> +	}

I'm not very keen of this because it doesn't really handle the problem, 
but rather just works around it.

Ideally we would use the kernels resource management functions for the 
internal address space and declare everything which is reserved as such.

Christian.

>   
>   	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 fdc25cd559b6..caa15639d3d5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
> @@ -197,6 +197,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/
> @@ -333,6 +339,7 @@ struct amdgpu_gmc {
>   	u64 MC_VM_MX_L1_TLB_CNTL;
>   
>   	u64 noretry_flags;
> +	enum amdgpu_gart_placement gart_placement;
>   };
>   
>   #define amdgpu_gmc_flush_gpu_tlb(adev, vmid, vmhub, type) ((adev)->gmc.gmc_funcs->flush_gpu_tlb((adev), (vmid), (vmhub), (type)))



More information about the amd-gfx mailing list