PDB0 block size 12 covers one 8GB entry. A GART start aligned only to 4GB can land in the middle of that entry. Align the sysvm GART start to 8GB, and use SZ_4G and SZ_8G in place of the local size constants.
Signed-off-by: Zhigang Luo <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c index 04cf02dd22ac..8a62f4f3aace 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c @@ -25,6 +25,7 @@ */ #include <linux/io-64-nonatomic-lo-hi.h> +#include <linux/sizes.h> #ifdef CONFIG_X86 #include <asm/hypervisor.h> #endif @@ -41,8 +42,6 @@ #include <drm/drm_drv.h> #include <drm/ttm/ttm_tt.h> -static const u64 four_gb = 0x100000000ULL; - bool amdgpu_gmc_is_pdb0_enabled(struct amdgpu_device *adev) { return adev->gmc.xgmi.connected_to_cpu || amdgpu_virt_xgmi_migrate_enabled(adev); @@ -261,8 +260,8 @@ void amdgpu_gmc_sysvm_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc u64 hive_vram_end = mc->xgmi.node_segment_size * mc->xgmi.num_physical_nodes - 1; mc->vram_start = mc->xgmi.node_segment_size * mc->xgmi.physical_node_id; mc->vram_end = mc->vram_start + mc->xgmi.node_segment_size - 1; - /* node_segment_size may not 4GB aligned on SRIOV, align up is needed. */ - mc->gart_start = ALIGN(hive_vram_end + 1, four_gb); + /* Round up to a PDB0 entry so GART starts on the page-table PDE. */ + mc->gart_start = ALIGN(hive_vram_end + 1, SZ_8G); mc->gart_end = mc->gart_start + mc->gart_size - 1; if (amdgpu_virt_xgmi_migrate_enabled(adev)) { /* set mc->vram_start to 0 to switch the returned GPU address of @@ -313,7 +312,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc, * the GART base on a 4GB boundary as well. */ size_bf = mc->fb_start; - size_af = max_mc_address + 1 - ALIGN(mc->fb_end + 1, four_gb); + size_af = max_mc_address + 1 - ALIGN(mc->fb_end + 1, SZ_4G); if (mc->gart_size > max(size_bf, size_af)) { dev_warn(adev->dev, "limiting GART\n"); @@ -328,7 +327,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc, if (size_bf >= mc->gart_size) mc->gart_start = 0; else - mc->gart_start = ALIGN(mc->fb_end, four_gb); + mc->gart_start = ALIGN(mc->fb_end, SZ_4G); break; case AMDGPU_GART_PLACEMENT_BEST_FIT: default: @@ -340,7 +339,7 @@ void amdgpu_gmc_gart_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc, break; } - mc->gart_start &= ~(four_gb - 1); + mc->gart_start &= ~(SZ_4G - 1); mc->gart_end = mc->gart_start + mc->gart_size - 1; dev_info(adev->dev, "GART: %lluM 0x%016llX - 0x%016llX\n", mc->gart_size >> 20, mc->gart_start, mc->gart_end); -- 2.43.0
