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 20e0ed96efbbae74001c10f428be4f30b5b35a7b..df63823ad4dbc3c96e28d919d98a63af139d51a9 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 a57abc1a25fb5fbe6da96410316cc85342363b44..982b1cc11dac65aa9836bfad71dda76da0016cbe 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 c1a124a867754108f0003372792448f4a23ebacd..5f7750c6497e1401e61ca4b5f50e08538bd6513c 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 575d7258374670a9c1fdc8472e55a865183e876f..388b52febc8b676d964b6e99e2ddbe648a6cce1b 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 6379177b9fcb7c75644c2db632be937425283475..d148d1c585b3b7c0c32a4fb24d32d8fcd335ce01 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 c6394ea69f96e1eda54f85234daa0fd67adcd979..dbb43d99e02e6b53f09dd7e21dfa8eddd6e45ec5 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;