drm/amdgpu: cleanup initializing gtt_size
authorChristian König <christian.koenig@amd.com>
Mon, 26 Jun 2017 09:37:49 +0000 (11:37 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 14 Jul 2017 15:05:53 +0000 (11:05 -0400)
Stop spreading the code over all GMC generations.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c

index 20e0ed9..df63823 100644 (file)
@@ -559,6 +559,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);
index a57abc1..982b1cc 100644 (file)
 /*
  * 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
  *
index c1a124a..5f7750c 100644 (file)
@@ -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;
index 575d725..388b52f 100644 (file)
@@ -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;
index 6379177..d148d1c 100644 (file)
@@ -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;
index c6394ea..dbb43d9 100644 (file)
@@ -494,15 +494,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;