Commit da2f9920 authored by Christian König's avatar Christian König Committed by Alex Deucher
Browse files

drm/amdgpu: cleanup visible vram size handling



Centralize the limit handling and validation in one place instead
of spreading that around in different hw generations.

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarLuben Tuikov <luben.tuikov@amd.com>
Acked-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 7ccfd79f
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -201,6 +201,7 @@ uint64_t amdgpu_gmc_agp_addr(struct ttm_buffer_object *bo)
void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
			      u64 base)
			      u64 base)
{
{
	uint64_t vis_limit = (uint64_t)amdgpu_vis_vram_limit << 20;
	uint64_t limit = (uint64_t)amdgpu_vram_limit << 20;
	uint64_t limit = (uint64_t)amdgpu_vram_limit << 20;


	mc->vram_start = base;
	mc->vram_start = base;
@@ -208,6 +209,12 @@ void amdgpu_gmc_vram_location(struct amdgpu_device *adev, struct amdgpu_gmc *mc,
	if (limit && limit < mc->real_vram_size)
	if (limit && limit < mc->real_vram_size)
		mc->real_vram_size = limit;
		mc->real_vram_size = limit;


	if (vis_limit && vis_limit < mc->visible_vram_size)
		mc->visible_vram_size = vis_limit;

	if (mc->real_vram_size < mc->visible_vram_size)
		mc->visible_vram_size = mc->real_vram_size;

	if (mc->xgmi.num_physical_nodes == 0) {
	if (mc->xgmi.num_physical_nodes == 0) {
		mc->fb_start = mc->vram_start;
		mc->fb_start = mc->vram_start;
		mc->fb_end = mc->vram_end;
		mc->fb_end = mc->vram_end;
+0 −7
Original line number Original line Diff line number Diff line
@@ -1718,7 +1718,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
{
{
	uint64_t gtt_size;
	uint64_t gtt_size;
	int r;
	int r;
	u64 vis_vram_limit;


	mutex_init(&adev->mman.gtt_window_lock);
	mutex_init(&adev->mman.gtt_window_lock);


@@ -1741,12 +1740,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
		return r;
		return r;
	}
	}


	/* Reduce size of CPU-visible VRAM if requested */
	vis_vram_limit = (u64)amdgpu_vis_vram_limit * 1024 * 1024;
	if (amdgpu_vis_vram_limit > 0 &&
	    vis_vram_limit <= adev->gmc.visible_vram_size)
		adev->gmc.visible_vram_size = vis_vram_limit;

	/* Change the size here instead of the init above so only lpfn is affected */
	/* Change the size here instead of the init above so only lpfn is affected */
	amdgpu_ttm_set_buffer_funcs_status(adev, false);
	amdgpu_ttm_set_buffer_funcs_status(adev, false);
#ifdef CONFIG_64BIT
#ifdef CONFIG_64BIT
+0 −3
Original line number Original line Diff line number Diff line
@@ -847,10 +847,7 @@ static int gmc_v10_0_mc_init(struct amdgpu_device *adev)
	}
	}
#endif
#endif


	/* In case the PCI BAR is larger than the actual amount of vram */
	adev->gmc.visible_vram_size = adev->gmc.aper_size;
	adev->gmc.visible_vram_size = adev->gmc.aper_size;
	if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
		adev->gmc.visible_vram_size = adev->gmc.real_vram_size;


	/* set the gart size */
	/* set the gart size */
	if (amdgpu_gart_size == -1) {
	if (amdgpu_gart_size == -1) {
+0 −3
Original line number Original line Diff line number Diff line
@@ -389,10 +389,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
	}
	}
#endif
#endif


	/* In case the PCI BAR is larger than the actual amount of vram */
	adev->gmc.visible_vram_size = adev->gmc.aper_size;
	adev->gmc.visible_vram_size = adev->gmc.aper_size;
	if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
		adev->gmc.visible_vram_size = adev->gmc.real_vram_size;


	/* set the gart size */
	/* set the gart size */
	if (amdgpu_gart_size == -1) {
	if (amdgpu_gart_size == -1) {
+0 −3
Original line number Original line Diff line number Diff line
@@ -587,10 +587,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
	}
	}
#endif
#endif


	/* In case the PCI BAR is larger than the actual amount of vram */
	adev->gmc.visible_vram_size = adev->gmc.aper_size;
	adev->gmc.visible_vram_size = adev->gmc.aper_size;
	if (adev->gmc.visible_vram_size > adev->gmc.real_vram_size)
		adev->gmc.visible_vram_size = adev->gmc.real_vram_size;


	/* set the gart size */
	/* set the gart size */
	if (amdgpu_gart_size == -1) {
	if (amdgpu_gart_size == -1) {
Loading