Commit a693e050 authored by Ken Wang's avatar Ken Wang Committed by Alex Deucher

drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu

Signed-off-by: default avatarKen Wang <Qingqing.Wang@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent ecf6a637
...@@ -2428,6 +2428,8 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, ...@@ -2428,6 +2428,8 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base); void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base);
void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); void amdgpu_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc);
void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size);
u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev);
int amdgpu_ttm_global_init(struct amdgpu_device *adev);
void amdgpu_program_register_sequence(struct amdgpu_device *adev, void amdgpu_program_register_sequence(struct amdgpu_device *adev,
const u32 *registers, const u32 *registers,
const u32 array_size); const u32 array_size);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <ttm/ttm_placement.h> #include <ttm/ttm_placement.h>
#include <ttm/ttm_module.h> #include <ttm/ttm_module.h>
#include <ttm/ttm_page_alloc.h> #include <ttm/ttm_page_alloc.h>
#include <ttm/ttm_memory.h>
#include <drm/drmP.h> #include <drm/drmP.h>
#include <drm/amdgpu_drm.h> #include <drm/amdgpu_drm.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
...@@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) ...@@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref)
ttm_mem_global_release(ref->object); ttm_mem_global_release(ref->object);
} }
static int amdgpu_ttm_global_init(struct amdgpu_device *adev) int amdgpu_ttm_global_init(struct amdgpu_device *adev)
{ {
struct drm_global_reference *global_ref; struct drm_global_reference *global_ref;
struct amdgpu_ring *ring; struct amdgpu_ring *ring;
...@@ -987,10 +988,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -987,10 +988,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
unsigned i, j; unsigned i, j;
int r; int r;
r = amdgpu_ttm_global_init(adev);
if (r) {
return r;
}
/* No others user of address space so set it to 0 */ /* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&adev->mman.bdev, r = ttm_bo_device_init(&adev->mman.bdev,
adev->mman.bo_global_ref.ref.object, adev->mman.bo_global_ref.ref.object,
...@@ -1449,3 +1446,8 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev) ...@@ -1449,3 +1446,8 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev)
#endif #endif
} }
u64 amdgpu_ttm_get_gtt_mem_size(struct amdgpu_device *adev)
{
return ttm_get_kernel_zone_memory_size(adev->mman.mem_global_ref.object);
}
...@@ -393,7 +393,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) ...@@ -393,7 +393,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
* size equal to the 1024 or vram, whichever is larger. * size equal to the 1024 or vram, whichever is larger.
*/ */
if (amdgpu_gart_size == -1) if (amdgpu_gart_size == -1)
adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size); adev->mc.gtt_size = amdgpu_ttm_get_gtt_mem_size(adev);
else else
adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
...@@ -953,6 +953,11 @@ static int gmc_v7_0_sw_init(void *handle) ...@@ -953,6 +953,11 @@ static int gmc_v7_0_sw_init(void *handle)
return r; return r;
} }
r = amdgpu_ttm_global_init(adev);
if (r) {
return r;
}
r = gmc_v7_0_mc_init(adev); r = gmc_v7_0_mc_init(adev);
if (r) if (r)
return r; return r;
......
...@@ -469,7 +469,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) ...@@ -469,7 +469,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
* size equal to the 1024 or vram, whichever is larger. * size equal to the 1024 or vram, whichever is larger.
*/ */
if (amdgpu_gart_size == -1) if (amdgpu_gart_size == -1)
adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size); adev->mc.gtt_size = amdgpu_ttm_get_gtt_mem_size(adev);
else else
adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
...@@ -949,6 +949,11 @@ static int gmc_v8_0_sw_init(void *handle) ...@@ -949,6 +949,11 @@ static int gmc_v8_0_sw_init(void *handle)
return r; return r;
} }
r = amdgpu_ttm_global_init(adev);
if (r) {
return r;
}
r = gmc_v8_0_mc_init(adev); r = gmc_v8_0_mc_init(adev);
if (r) if (r)
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment