> -----Original Message----- > From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf > Of Christian König > Sent: Monday, June 26, 2017 9:40 AM > To: amd-gfx at lists.freedesktop.org > Cc: john at fastquake.com; Kuehling, Felix > Subject: [PATCH 1/3] drm/amdgpu: cleanup initializing gtt_size > > From: Christian König <christian.koenig at amd.com> > > Stop spreading the code over all GMC generations. > > Signed-off-by: Christian König <christian.koenig at amd.com> Reviewed-by: Alex Deucher <alexander.deucher at amd.com> > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + > drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 20 > ++++++++++++++++++++ > drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 10 +--------- > drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 10 +--------- > drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 10 +--------- > drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 10 +--------- > 6 files changed, 25 insertions(+), 36 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > index 7624294..ab1dad2 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -561,6 +561,7 @@ struct amdgpu_gart { > const struct amdgpu_gart_funcs *gart_funcs; > }; > > +void amdgpu_gart_set_defaults(struct amdgpu_device *adev); > int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev); > void amdgpu_gart_table_ram_free(struct amdgpu_device *adev); > int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > index ccef3cf..8877015 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c > @@ -52,6 +52,26 @@ > /* > * Common GART table functions. > */ > + > +/** > + * amdgpu_gart_set_defaults - set the default gtt_size > + * > + * @adev: amdgpu_device pointer > + * > + * Set the default gtt_size based on parameters and available VRAM. > + */ > +void amdgpu_gart_set_defaults(struct amdgpu_device *adev) > +{ > + /* unless the user had overridden it, set the gart > + * size equal to the 1024 or vram, whichever is larger. > + */ > + if (amdgpu_gart_size == -1) > + adev->mc.gtt_size = > max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > + adev->mc.mc_vram_size); > + else > + adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > +} > + > /** > * amdgpu_gart_table_ram_alloc - allocate system ram for gart page table > * > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c > index 35655a1..5cc3f39 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c > @@ -321,15 +321,7 @@ static int gmc_v6_0_mc_init(struct amdgpu_device > *adev) > adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * > 1024ULL * 1024ULL; > adev->mc.visible_vram_size = adev->mc.aper_size; > > - /* unless the user had overridden it, set the gart > - * size equal to the 1024 or vram, whichever is larger. > - */ > - if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = > max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > - adev->mc.mc_vram_size); > - else > - adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > - > + amdgpu_gart_set_defaults(adev); > gmc_v6_0_vram_gtt_location(adev, &adev->mc); > > return 0; > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > index 83c21a1..15f2c0f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c > @@ -373,15 +373,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device > *adev) > if (adev->mc.visible_vram_size > adev->mc.real_vram_size) > adev->mc.visible_vram_size = adev->mc.real_vram_size; > > - /* unless the user had overridden it, set the gart > - * size equal to the 1024 or vram, whichever is larger. > - */ > - if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = > max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > - adev->mc.mc_vram_size); > - else > - adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > - > + amdgpu_gart_set_defaults(adev); > gmc_v7_0_vram_gtt_location(adev, &adev->mc); > > return 0; > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > index c92af24..213af65 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c > @@ -535,15 +535,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device > *adev) > if (adev->mc.visible_vram_size > adev->mc.real_vram_size) > adev->mc.visible_vram_size = adev->mc.real_vram_size; > > - /* unless the user had overridden it, set the gart > - * size equal to the 1024 or vram, whichever is larger. > - */ > - if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = > max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > - adev->mc.mc_vram_size); > - else > - adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > - > + amdgpu_gart_set_defaults(adev); > gmc_v8_0_vram_gtt_location(adev, &adev->mc); > > return 0; > diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c > b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c > index 7c6188b..128989e 100644 > --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c > @@ -495,15 +495,7 @@ static int gmc_v9_0_mc_init(struct amdgpu_device > *adev) > if (adev->mc.visible_vram_size > adev->mc.real_vram_size) > adev->mc.visible_vram_size = adev->mc.real_vram_size; > > - /* unless the user had overridden it, set the gart > - * size equal to the 1024 or vram, whichever is larger. > - */ > - if (amdgpu_gart_size == -1) > - adev->mc.gtt_size = > max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), > - adev->mc.mc_vram_size); > - else > - adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20; > - > + amdgpu_gart_set_defaults(adev); > gmc_v9_0_vram_gtt_location(adev, &adev->mc); > > return 0; > -- > 2.7.4 > > _______________________________________________ > amd-gfx mailing list > amd-gfx at lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx