Re: [PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu
On Tue, Aug 2, 2016 at 1:19 AM, Ken Wang wrote: > Change-Id: Ibf193cc2d9e20c3aefa1ce8ff24241dfbb6768ff > Signed-off-by: Ken Wang > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++- > drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++- > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++- > 4 files changed, 21 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index da9ee5e..a701b79 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -2450,6 +2450,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_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); > 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, > const u32 *registers, > const u32 array_size); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index d739ecb..4b31a36 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct > drm_global_reference *ref) > 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 amdgpu_ring *ring; > @@ -1003,10 +1004,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) > unsigned i, j; > int r; > > - r = amdgpu_ttm_global_init(adev); > - if (r) { > - return r; > - } > /* No others user of address space so set it to 0 */ > r = ttm_bo_device_init(&adev->mman.bdev, >adev->mman.bo_global_ref.ref.object, > @@ -1403,3 +1400,8 @@ static void amdgpu_ttm_debugfs_fini(struct > amdgpu_device *adev) > > #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); > +} > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > index a3b6048..4d4b57f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > @@ -392,7 +392,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) > * size equal to the 1024 or vram, whichever is larger. > */ > if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = max((1024ULL << 20), > adev->mc.mc_vram_size); > + adev->mc.gtt_size = min(adev->mc.mc_vram_size, > amdgpu_ttm_get_gtt_mem_size(adev)); Shouldn't this be: adev->mc.gtt_size = min(adev->mc.mc_mask - adev->mc.mc_vram_size, amdgpu_ttm_get_gtt_mem_size(adev)); Looking closer at the code, amdgpu_gtt_location() will automatically clamp the gtt size to the available address space to I think the previous patch is fine as is. With mc.gtt_size set to amdgpu_ttm_get_gtt_mem_size(), the previous patch is: Reviewed-by: Alex Deucher > else > adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > > @@ -959,6 +959,11 @@ static int gmc_v7_0_sw_init(void *handle) > return r; > } > > + r = amdgpu_ttm_global_init(adev); > + if (r) { > + return r; > + } > + > r = gmc_v7_0_mc_init(adev); > if (r) > return r; > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > index 84d4f7f..30b3fd8 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > @@ -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. > */ > if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = max((1024ULL << 20), > adev->mc.mc_vram_size); > + adev->mc.gtt_size = min(adev->mc.mc_vram_size, > amdgpu_ttm_get_gtt_mem_size(adev)); > else > adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > > @@ -956,6 +956,11 @@ static int gmc_v8_0_sw_init(void *handle) > return r; > } > > + r = amdgpu_ttm_global_init(adev); > + if (r) { > + return r; > + } > + >
答复: [PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu
Yeah, that's could be an issue, I have changed the logic and send the review again. 发件人: Alex Deucher 发送时间: 2016年8月2日 12:56:07 收件人: Wang, Ken 抄送: amd-gfx list 主题: Re: [PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu On Wed, Jul 27, 2016 at 7:21 AM, Ken Wang wrote: > Change-Id: Ibf193cc2d9e20c3aefa1ce8ff24241dfbb6768ff > Signed-off-by: Ken Wang > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++- > drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++- > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++- > 4 files changed, 21 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 8bef7ec..b84153f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -2432,6 +2432,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_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); > 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, > const u32 *registers, > const u32 array_size); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 145732a..5200381 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct > drm_global_reference *ref) > 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 amdgpu_ring *ring; > @@ -998,10 +999,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) > unsigned i, j; > int r; > > - r = amdgpu_ttm_global_init(adev); > - if (r) { > - return r; > - } > /* No others user of address space so set it to 0 */ > r = ttm_bo_device_init(&adev->mman.bdev, >adev->mman.bo_global_ref.ref.object, > @@ -1398,3 +1395,8 @@ static void amdgpu_ttm_debugfs_fini(struct > amdgpu_device *adev) > > #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); > +} > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > index a3b6048..b6ae925 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > @@ -392,7 +392,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) > * size equal to the 1024 or vram, whichever is larger. > */ > 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); Do we want to limit this to the min(amdgpu_ttm_get_gtt_mem_size, GPU address space - vram)? GPU address space is only 40 bits. You could theoretically have systems with a lot of system memory. Alex > else > adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > > @@ -959,6 +959,11 @@ static int gmc_v7_0_sw_init(void *handle) > return r; > } > > + r = amdgpu_ttm_global_init(adev); > + if (r) { > + return r; > + } > + > r = gmc_v7_0_mc_init(adev); > if (r) > return r; > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > index 02b6872..d46d76b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > @@ -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. > */ > if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = max((10
[PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu
Change-Id: Ibf193cc2d9e20c3aefa1ce8ff24241dfbb6768ff Signed-off-by: Ken Wang --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index da9ee5e..a701b79 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -2450,6 +2450,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_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); 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, const u32 *registers, const u32 array_size); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index d739ecb..4b31a36 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) 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 amdgpu_ring *ring; @@ -1003,10 +1004,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) unsigned i, j; int r; - r = amdgpu_ttm_global_init(adev); - if (r) { - return r; - } /* No others user of address space so set it to 0 */ r = ttm_bo_device_init(&adev->mman.bdev, adev->mman.bo_global_ref.ref.object, @@ -1403,3 +1400,8 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev) #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); +} diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index a3b6048..4d4b57f 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c @@ -392,7 +392,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) * size equal to the 1024 or vram, whichever is larger. */ if (amdgpu_gart_size == -1) - adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size); + adev->mc.gtt_size = min(adev->mc.mc_vram_size, amdgpu_ttm_get_gtt_mem_size(adev)); else adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; @@ -959,6 +959,11 @@ static int gmc_v7_0_sw_init(void *handle) return r; } + r = amdgpu_ttm_global_init(adev); + if (r) { + return r; + } + r = gmc_v7_0_mc_init(adev); if (r) return r; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 84d4f7f..30b3fd8 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -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. */ if (amdgpu_gart_size == -1) - adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size); + adev->mc.gtt_size = min(adev->mc.mc_vram_size, amdgpu_ttm_get_gtt_mem_size(adev)); else adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; @@ -956,6 +956,11 @@ static int gmc_v8_0_sw_init(void *handle) return r; } + r = amdgpu_ttm_global_init(adev); + if (r) { + return r; + } + r = gmc_v8_0_mc_init(adev); if (r) return r; -- 2.7.4 ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu
On Wed, Jul 27, 2016 at 7:21 AM, Ken Wang wrote: > Change-Id: Ibf193cc2d9e20c3aefa1ce8ff24241dfbb6768ff > Signed-off-by: Ken Wang > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++- > drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++- > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++- > 4 files changed, 21 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 8bef7ec..b84153f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -2432,6 +2432,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_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); > 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, > const u32 *registers, > const u32 array_size); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > index 145732a..5200381 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c > @@ -34,6 +34,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct > drm_global_reference *ref) > 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 amdgpu_ring *ring; > @@ -998,10 +999,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) > unsigned i, j; > int r; > > - r = amdgpu_ttm_global_init(adev); > - if (r) { > - return r; > - } > /* No others user of address space so set it to 0 */ > r = ttm_bo_device_init(&adev->mman.bdev, >adev->mman.bo_global_ref.ref.object, > @@ -1398,3 +1395,8 @@ static void amdgpu_ttm_debugfs_fini(struct > amdgpu_device *adev) > > #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); > +} > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > index a3b6048..b6ae925 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > @@ -392,7 +392,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) > * size equal to the 1024 or vram, whichever is larger. > */ > 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); Do we want to limit this to the min(amdgpu_ttm_get_gtt_mem_size, GPU address space - vram)? GPU address space is only 40 bits. You could theoretically have systems with a lot of system memory. Alex > else > adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > > @@ -959,6 +959,11 @@ static int gmc_v7_0_sw_init(void *handle) > return r; > } > > + r = amdgpu_ttm_global_init(adev); > + if (r) { > + return r; > + } > + > r = gmc_v7_0_mc_init(adev); > if (r) > return r; > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > index 02b6872..d46d76b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > @@ -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. > */ > 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 > adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > > @@ -956,6 +956,11 @@ static int gmc_v8_0_sw_init(void *handle) > return r; > } > > + r = amdgpu_ttm_global_init(adev); > + if (r) { > + return r; > + } > + > r = gmc_v8_0_mc_init(adev); > if (r) > return r; > -- > 2.7.4 > > ___ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-
[PATCH 2/2] drm/amdgpu: use the kernel zone memory size as the max remote memory in amdgpu
Change-Id: Ibf193cc2d9e20c3aefa1ce8ff24241dfbb6768ff Signed-off-by: Ken Wang --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 8bef7ec..b84153f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -2432,6 +2432,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_gtt_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); 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, const u32 *registers, const u32 array_size); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 145732a..5200381 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -74,7 +75,7 @@ static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) 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 amdgpu_ring *ring; @@ -998,10 +999,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) unsigned i, j; int r; - r = amdgpu_ttm_global_init(adev); - if (r) { - return r; - } /* No others user of address space so set it to 0 */ r = ttm_bo_device_init(&adev->mman.bdev, adev->mman.bo_global_ref.ref.object, @@ -1398,3 +1395,8 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev) #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); +} diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index a3b6048..b6ae925 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c @@ -392,7 +392,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev) * size equal to the 1024 or vram, whichever is larger. */ 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 adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; @@ -959,6 +959,11 @@ static int gmc_v7_0_sw_init(void *handle) return r; } + r = amdgpu_ttm_global_init(adev); + if (r) { + return r; + } + r = gmc_v7_0_mc_init(adev); if (r) return r; diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 02b6872..d46d76b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c @@ -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. */ 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 adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; @@ -956,6 +956,11 @@ static int gmc_v8_0_sw_init(void *handle) return r; } + r = amdgpu_ttm_global_init(adev); + if (r) { + return r; + } + r = gmc_v8_0_mc_init(adev); if (r) return r; -- 2.7.4 ___ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx