aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Redlewski <predlewski@gmail.com>2017-11-10 13:28:01 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-06 12:47:22 -0500
commitc1fe75c9e42c8c598a7fb810ecc4f7be258e700c (patch)
tree3193f160fa5826c52f23f64181dfd00c5925c7ec
parentfa2123dbccdc881fae02aaf8b05758db53d62955 (diff)
drm/amd/amdgpu: fix UVD mc offsets
When UVD bo is created, its size is based on the information from firmware header (ucode_size_bytes). The same value should be be used when programming UVD mc controller offsets, otherwise it can happen that (mmUVD_VCPU_CACHE_OFFSET2 + mmUVD_VCPU_CACHE_SIZE2) will point AMDGPU_GPU_PAGE_SIZE bytes after the UVD bo end. Second issue is that when programming the mmUVD_VCPU_CACHE_SIZE0 register, AMDGPU_UVD_FIRMWARE_OFFSET should be taken into account. If it isn't, (mmUVD_VCPU_CACHE_OFFSET2 + mmUVD_VCPU_CACHE_SIZE2) will always point AMDGPU_UVD_FIRMWARE_OFFSET bytes after the UVD bo end. v2: move firmware size calculation into macro definition v3: align firmware size to the gpu page size Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Piotr Redlewski <predlewski@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h4
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c2
5 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
index 3553b92bf69a..845eea993f75 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
@@ -31,6 +31,10 @@
31#define AMDGPU_UVD_SESSION_SIZE (50*1024) 31#define AMDGPU_UVD_SESSION_SIZE (50*1024)
32#define AMDGPU_UVD_FIRMWARE_OFFSET 256 32#define AMDGPU_UVD_FIRMWARE_OFFSET 256
33 33
34#define AMDGPU_UVD_FIRMWARE_SIZE(adev) \
35 (AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(((const struct common_firmware_header *)(adev)->uvd.fw->data)->ucode_size_bytes) + \
36 8) - AMDGPU_UVD_FIRMWARE_OFFSET)
37
34struct amdgpu_uvd { 38struct amdgpu_uvd {
35 struct amdgpu_bo *vcpu_bo; 39 struct amdgpu_bo *vcpu_bo;
36 void *cpu_addr; 40 void *cpu_addr;
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
index 15771a53038e..b13ae34be1c2 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
@@ -563,7 +563,7 @@ static void uvd_v4_2_mc_resume(struct amdgpu_device *adev)
563 563
564 /* programm the VCPU memory controller bits 0-27 */ 564 /* programm the VCPU memory controller bits 0-27 */
565 addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; 565 addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3;
566 size = AMDGPU_GPU_PAGE_ALIGN(adev->uvd.fw->size + 4) >> 3; 566 size = AMDGPU_UVD_FIRMWARE_SIZE(adev) >> 3;
567 WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr); 567 WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);
568 WREG32(mmUVD_VCPU_CACHE_SIZE0, size); 568 WREG32(mmUVD_VCPU_CACHE_SIZE0, size);
569 569
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
index 3b29aaba783a..a4b0f1d842b7 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
@@ -258,7 +258,7 @@ static void uvd_v5_0_mc_resume(struct amdgpu_device *adev)
258 upper_32_bits(adev->uvd.gpu_addr)); 258 upper_32_bits(adev->uvd.gpu_addr));
259 259
260 offset = AMDGPU_UVD_FIRMWARE_OFFSET; 260 offset = AMDGPU_UVD_FIRMWARE_OFFSET;
261 size = AMDGPU_GPU_PAGE_ALIGN(adev->uvd.fw->size + 4); 261 size = AMDGPU_UVD_FIRMWARE_SIZE(adev);
262 WREG32(mmUVD_VCPU_CACHE_OFFSET0, offset >> 3); 262 WREG32(mmUVD_VCPU_CACHE_OFFSET0, offset >> 3);
263 WREG32(mmUVD_VCPU_CACHE_SIZE0, size); 263 WREG32(mmUVD_VCPU_CACHE_SIZE0, size);
264 264
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index 0c01825a8b9e..0e8b887cf03e 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
@@ -603,7 +603,7 @@ static void uvd_v6_0_mc_resume(struct amdgpu_device *adev)
603 upper_32_bits(adev->uvd.gpu_addr)); 603 upper_32_bits(adev->uvd.gpu_addr));
604 604
605 offset = AMDGPU_UVD_FIRMWARE_OFFSET; 605 offset = AMDGPU_UVD_FIRMWARE_OFFSET;
606 size = AMDGPU_GPU_PAGE_ALIGN(adev->uvd.fw->size + 4); 606 size = AMDGPU_UVD_FIRMWARE_SIZE(adev);
607 WREG32(mmUVD_VCPU_CACHE_OFFSET0, offset >> 3); 607 WREG32(mmUVD_VCPU_CACHE_OFFSET0, offset >> 3);
608 WREG32(mmUVD_VCPU_CACHE_SIZE0, size); 608 WREG32(mmUVD_VCPU_CACHE_SIZE0, size);
609 609
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
index 7b77339feb1a..6d4470626d25 100644
--- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
@@ -616,7 +616,7 @@ static int uvd_v7_0_resume(void *handle)
616 */ 616 */
617static void uvd_v7_0_mc_resume(struct amdgpu_device *adev) 617static void uvd_v7_0_mc_resume(struct amdgpu_device *adev)
618{ 618{
619 uint32_t size = AMDGPU_GPU_PAGE_ALIGN(adev->uvd.fw->size + 4); 619 uint32_t size = AMDGPU_UVD_FIRMWARE_SIZE(adev);
620 uint32_t offset; 620 uint32_t offset;
621 621
622 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { 622 if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {