drm/radeon: rework VCE FW size calculation
authorChristian König <christian.koenig@amd.com>
Mon, 11 May 2015 20:01:47 +0000 (22:01 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 May 2015 14:31:20 +0000 (10:31 -0400)
Previously we were completely over allocating, fix this
by actually implementing the size calculation.

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_vce.c
drivers/gpu/drm/radeon/vce_v2_0.c

index 352870cbb8b8c3bd5ac860dac8bc7a418ff51951..5999560d4284976422cf42848f3ccdaf73a35517 100644 (file)
@@ -1709,8 +1709,6 @@ int radeon_uvd_send_upll_ctlreq(struct radeon_device *rdev,
  * VCE
  */
 #define RADEON_MAX_VCE_HANDLES 16
-#define RADEON_VCE_STACK_SIZE  (1024*1024)
-#define RADEON_VCE_HEAP_SIZE   (4*1024*1024)
 
 struct radeon_vce {
        struct radeon_bo        *vcpu_bo;
index a3ca8cd305c5c21541bae20820dbe3366f416706..cb7787fedf1bcc42e0015a75a2dc1f1dbd7312c6 100644 (file)
@@ -974,6 +974,7 @@ int vce_v1_0_init(struct radeon_device *rdev);
 int vce_v1_0_start(struct radeon_device *rdev);
 
 /* vce v2.0 */
+unsigned vce_v2_0_bo_size(struct radeon_device *rdev);
 int vce_v2_0_resume(struct radeon_device *rdev);
 
 #endif
index 0de5711ac508842b2a1d70550c755f0f85cd6d71..5b952bdfa68d34a2e28286158d505b223eefd5f1 100644 (file)
@@ -123,8 +123,7 @@ int radeon_vce_init(struct radeon_device *rdev)
 
        /* allocate firmware, stack and heap BO */
 
-       size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size) +
-              RADEON_VCE_STACK_SIZE + RADEON_VCE_HEAP_SIZE;
+       size = vce_v2_0_bo_size(rdev);
        r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
                             RADEON_GEM_DOMAIN_VRAM, 0, NULL, NULL,
                             &rdev->vce.vcpu_bo);
index fbbe78fbd087ae7c147a43b925f0ac0401c86466..cdeaab7c7b1eaa6f8e4b8e723f6470f55e3a6237 100644 (file)
 #include "radeon_asic.h"
 #include "cikd.h"
 
+#define VCE_V2_0_FW_SIZE       (256 * 1024)
+#define VCE_V2_0_STACK_SIZE    (64 * 1024)
+#define VCE_V2_0_DATA_SIZE     (23552 * RADEON_MAX_VCE_HANDLES)
+
 static void vce_v2_0_set_sw_cg(struct radeon_device *rdev, bool gated)
 {
        u32 tmp;
@@ -140,6 +144,12 @@ static void vce_v2_0_init_cg(struct radeon_device *rdev)
        WREG32(VCE_CLOCK_GATING_B, tmp);
 }
 
+unsigned vce_v2_0_bo_size(struct radeon_device *rdev)
+{
+       WARN_ON(rdev->vce_fw->size > VCE_V2_0_FW_SIZE);
+       return VCE_V2_0_FW_SIZE + VCE_V2_0_STACK_SIZE + VCE_V2_0_DATA_SIZE;
+}
+
 int vce_v2_0_resume(struct radeon_device *rdev)
 {
        uint64_t addr = rdev->vce.gpu_addr;
@@ -159,17 +169,17 @@ int vce_v2_0_resume(struct radeon_device *rdev)
        WREG32(VCE_LMI_VCPU_CACHE_40BIT_BAR, addr >> 8);
 
        addr &= 0xff;
-       size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size);
+       size = VCE_V2_0_FW_SIZE;
        WREG32(VCE_VCPU_CACHE_OFFSET0, addr & 0x7fffffff);
        WREG32(VCE_VCPU_CACHE_SIZE0, size);
 
        addr += size;
-       size = RADEON_VCE_STACK_SIZE;
+       size = VCE_V2_0_STACK_SIZE;
        WREG32(VCE_VCPU_CACHE_OFFSET1, addr & 0x7fffffff);
        WREG32(VCE_VCPU_CACHE_SIZE1, size);
 
        addr += size;
-       size = RADEON_VCE_HEAP_SIZE;
+       size = VCE_V2_0_DATA_SIZE;
        WREG32(VCE_VCPU_CACHE_OFFSET2, addr & 0x7fffffff);
        WREG32(VCE_VCPU_CACHE_SIZE2, size);