radeon: use memcpy_to/fromio for UVD fw upload
Subsystems (2)
PATCH 1/1 radeon: use memcpy_to/fromio for UVD fw upload
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is radeon_uvd_resume.
As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commit ba0b2275a678 ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.
Also fix some coding issues reported from sparse.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +17 -13
@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);
@@ -286,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, +le32_to_cpu ((__force __le32 )rdev->uvd_fw->size)); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
@@ -294,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
@@ -791,17 +795,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
@@ -827,9 +831,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
Signature · 1 line
2.31.1
Quoted 10 lines · Chen Li
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
Quoted 5 lines
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Also fix some coding issues reported from sparse.
Can you split the sparse fixes and the mmio fixes into two patches?
Thanks,
Alex
Quoted 82 lines
Signed-off-by Chen Li <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +17
-14@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);@@ -286,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, +le32_to_cpu ((__force __le32 )rdev->uvd_fw->size)); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -294,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }@@ -791,17 +795,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);@@ -827,9 +831,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]); --
Quoted 4 lines
2.31.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
v2 cover use memcpy_to/fromio for UVD fw upload
changelog:
v1->v2: split sparse and memcp/memset fix
Chen Li (2):
radeon: fix coding issues reported from sparse
radeon: use memcpy_to/fromio for UVD fw upload
drivers/gpu/drm/radeon/radeon_uvd.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 2/2 radeon: use memcpy_to/fromio for UVD fw upload
In reply to Chen LiI met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is radeon_uvd_resume.
As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commit ba0b2275a678 ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +4 -2
@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, +le32_to_cpu ((__force __le32 )rdev->uvd_fw->size)); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 1/2 radeon: fix coding issues reported from sparse
In reply to Chen LiAlso fix some coding issue reported from sparse.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +13 -11
@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);
@@ -791,17 +793,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
@@ -827,9 +829,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v2 1/2] radeon: fix coding issues reported from sparse
Am 04.06.21 um 05:02 schrieb Chen Li:
Quoted 3 lines
Also fix some coding issue reported from sparse.
Signed-off-by Chen Li <[email protected]>
Quoted 49 lines
--- drivers/gpu/drm/radeon/radeon_uvd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +10
-8@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);@@ -791,17 +793,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);@@ -827,9 +829,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring, · line 837
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_uvd.c +3
-3/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 04.06.21 um 05:04 schrieb Chen Li:
Quoted 22 lines
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +0
-0
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 293
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_uvd.c +3
-1@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, +le32_to_cpu ((__force __le32 )rdev->uvd_fw->size));
The le32_to_cpu and coding style looks wrong here. The uvd_fw->size is always in CPU byte order and is used as such.
And please keep in mind that architectures where memcpy() on MMIO doesn't work in the kernel usually doesn't work in userspace as well.
So this is actually now necessary a valid workaround.
Christian.
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 304
Quoted 12 lines
drivers/gpu/drm/radeon/radeon_uvd.c +1
-1size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 04.06.21 um 09:53 schrieb Chen Li:
Quoted 22 lines
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +0
-0
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 293
Quoted 7 lines
drivers/gpu/drm/radeon/radeon_uvd.c +3
-1@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, + rdev->uvd_fw->size);
The coding style still looks wrong here, e.g. it is indented to far to the right and data/size can be on one line.
Apart from that the patch is Reviewed-by: Christian König <[email protected]>
Regards,
Christian.
Quoted 12 lines
drivers/gpu/drm/radeon/radeon_uvd.c +1
-1size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
Christian König
maintainerAm 04.06.21 um 10:28 schrieb Chen Li:
Quoted 35 lines
Quoted 20 lines · Christian König
Am 04.06.21 um 09:53 schrieb Chen Li:
Quoted 17 lines
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)Quoted 13 lines
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 293
Quoted 11 lines
drivers/gpu/drm/radeon/radeon_uvd.c +3
-0@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, + rdev->uvd_fw->size);The coding style still looks wrong here, e.g. it is indented to far to the right and data/size can be on one line.
Quoted 4 lines
It's really werid that the patch before being replyed has not this coding style issue and do always indent the same with previous
memcpy(in all of v1, v2 and v3),
you can check at https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fproject%2Fdri-devel%2Fpatch%2F87im2ufhyz.wl-chenli%40uniontech.com%2F&data=04%7C01%7Cchristian.koenig%40amd.com%7C3faf061c19b54a68e72508d92732cd5e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637583921450406148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=b0726ORwyeLQsKVzqjfZEMaU4Vi543szpFYoHekPMIU%3D&reserved=0 Cannot figure out what happened, sorry.I'll take merge them in single line in the next series, thanks.
It's not much of an issue, just make sure that checkpatch.pl doesn't complain.
Christian.
Quoted 6 lines
Quoted 6 lines
Apart from that the patch is Reviewed-by: Christian König <[email protected]>
Regards,
Christian.
Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 303
Quoted 9 lines
drivers/gpu/drm/radeon/radeon_uvd.c +1
-0size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 04.06.21 um 10:43 schrieb Chen Li:
Quoted 8 lines
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
Quoted 6 lines
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>Reviewed-by Christian König
Alex will probably now pick them up for upstreaming.
Christian.
Quoted 18 lines
--- drivers/gpu/drm/radeon/radeon_uvd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +1
-1@@ -288,7 +288,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 302
Quoted 8 lines
drivers/gpu/drm/radeon/radeon_uvd.c +1
-1@@ -296,7 +296,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v3 1/2 radeon: fix coding issues reported from sparse
In reply to Christian KönigAlso fix some coding issues reported from sparse.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +13 -11
@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);
@@ -791,17 +793,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
@@ -827,9 +829,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
v4 cover use memcpy_to/fromio for UVD fw upload
In reply to Christian Königchangelog:
v1->v2: split sparse and memcp/memset fix
v2->v3: fix coding issue and misuse of le32_to_cpu
v3->v4: merge memcpy_toio's arguments to one lineChen Li (2):
radeon: fix coding issues reported from sparse
radeon: use memcpy_to/fromio for UVD fw upload
drivers/gpu/drm/radeon/radeon_uvd.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v3 2/2 radeon: use memcpy_to/fromio for UVD fw upload
In reply to Christian KönigI met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is radeon_uvd_resume.
As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commit ba0b2275a678 ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +4 -2
@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, + rdev->uvd_fw->size); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v4 1/2 radeon: fix coding issues reported from sparse
In reply to Christian KönigAlso fix some coding issues reported from sparse.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +13 -11
@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);
@@ -791,17 +793,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
@@ -827,9 +829,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]);
Signature · 10 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v4 2/2 radeon: use memcpy_to/fromio for UVD fw upload
In reply to Christian KönigI met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is radeon_uvd_resume.
As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commit ba0b2275a678 ("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.
--- drivers/gpu/drm/radeon/radeon_uvd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_uvd.c +2 -2
@@ -288,7 +288,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;
@@ -296,7 +296,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
Signature · 9 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
v3 cover use memcpy_to/fromio for UVD fw upload
In reply to Christian Königchangelog:
v1->v2: split sparse and memcp/memset fix
v2->v3: fix coding issue and misuse of le32_to_cpuChen Li (2):
radeon: fix coding issues reported from sparse
radeon: use memcpy_to/fromio for UVD fw upload
drivers/gpu/drm/radeon/radeon_uvd.c | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
Signature · 8 lines
2.31.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 21 lines · Christian König
Am 04.06.21 um 09:53 schrieb Chen Li:
Quoted 17 lines
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 14 lines
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 293
Quoted 11 lines
drivers/gpu/drm/radeon/radeon_uvd.c +3
-0@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, + rdev->uvd_fw->size);The coding style still looks wrong here, e.g. it is indented to far to the right and data/size can be on one line.
It's really werid that the patch before being replyed has not this coding style issue and do always indent the same with previous memcpy(in all of v1, v2 and v3), you can check at https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Cannot figure out what happened, sorry.
I'll take merge them in single line in the next series, thanks.
Quoted 7 lines
Apart from that the patch is Reviewed-by: Christian König <[email protected]>
Regards,
Christian.
Quoted 12 lines
drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 303
Quoted 9 lines
drivers/gpu/drm/radeon/radeon_uvd.c +1
-0size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 39 lines · Christian König
Am 04.06.21 um 10:28 schrieb Chen Li:
Quoted 35 lines
Quoted 33 lines · Christian König
Am 04.06.21 um 09:53 schrieb Chen Li:
Quoted 22 lines
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +0
-0drivers/gpu/drm/radeon/radeon_uvd.c int radeon_uvd_resume(struct radeon_device *rdev) · line 293
Quoted 6 lines
drivers/gpu/drm/radeon/radeon_uvd.c +3
-0@@ -288,7 +288,9 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, + rdev->uvd_fw->data, + rdev->uvd_fw->size);The coding style still looks wrong here, e.g. it is indented to far to the right and data/size can be on one line.
Quoted 6 lines
Quoted 4 lines
It's really werid that the patch before being replyed has not this coding style issue and do always indent the same with previous
memcpy(in all of v1, v2 and v3),
you can check at https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fproject%2Fdri-devel%2Fpatch%2F87im2ufhyz.wl-chenli%40uniontech.com%2F&data=04%7C01%7Cchristian.koenig%40amd.com%7C3faf061c19b54a68e72508d92732cd5e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637583921450406148%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=b0726ORwyeLQsKVzqjfZEMaU4Vi543szpFYoHekPMIU%3D&reserved=0 Cannot figure out what happened, sorry.I'll take merge them in single line in the next series, thanks.
It's not much of an issue, just make sure that checkpatch.pl doesn't complain.
Yes, have already done checkpatch in all these series.
Quoted 24 lines
Christian.
Quoted 18 lines
Quoted 17 lines
Apart from that the patch is Reviewed-by: Christian König <[email protected]>
Regards,
Christian.Quoted 9 lines
drivers/gpu/drm/radeon/radeon_uvd.c +1
-0size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -296,7 +298,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
AppliedRe: [PATCH v4 1/2] radeon: fix coding issues reported from sparse
In reply to Chen LiApplied. Thanks!
Alex
Quoted 72 lines · Chen Li
Also fix some coding issues reported from sparse.
Signed-off-by Chen Li <[email protected]>Acked-by Christian König <[email protected]>--- drivers/gpu/drm/radeon/radeon_uvd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +13
-12@@ -152,9 +152,11 @@ int radeon_uvd_init(struct radeon_device *rdev) rdev->uvd.fw_header_present = true; - family_id =le32_to_cpu (hdr->ucode_version) &0xff ; - version_major = (le32_to_cpu (hdr->ucode_version) >>24 ) &0xff ; - version_minor = (le32_to_cpu (hdr->ucode_version) >>8 ) &0xff ; + family_id = (__force u32)(hdr->ucode_version) &0xff ; + version_major = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>24 ) &0xff ; + version_minor = (le32_to_cpu ((__force __le32)(hdr->ucode_version)) + >>8 ) &0xff ;DRM_INFO ("Found UVD firmware Version: %u.%u Family ID: %u\n" , version_major, version_minor, family_id);@@ -791,17 +793,17 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD create msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]);writel (0x0 , (void __iomem *)&msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);writel (0x0 , &msg[4 ]);writel (0x0 , &msg[5 ]);writel (0x0 , &msg[6 ]); -writel (cpu_to_le32 (0x00000780 ), &msg[7 ]); -writel (cpu_to_le32 (0x00000440 ), &msg[8 ]); +writel ((__force u32 )cpu_to_le32 (0x00000780 ), &msg[7 ]); +writel ((__force u32 )cpu_to_le32 (0x00000440 ), &msg[8 ]);writel (0x0 , &msg[9 ]); -writel (cpu_to_le32 (0x01b37000 ), &msg[10 ]); +writel ((__force u32 )cpu_to_le32 (0x01b37000 ), &msg[10 ]);for (i =11 ; i <1024 ; ++i)writel (0x0 , &msg[i]);@@ -827,9 +829,9 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,return r;/* stitch together an UVD destroy msg */ -writel (cpu_to_le32 (0x00000de4 ), &msg[0 ]); -writel (cpu_to_le32 (0x00000002 ), &msg[1 ]); -writel (cpu_to_le32 (handle), &msg[2 ]); +writel ((__force u32 )cpu_to_le32 (0x00000de4 ), &msg[0 ]); +writel ((__force u32 )cpu_to_le32 (0x00000002 ), &msg[1 ]); +writel ((__force u32 )cpu_to_le32 (handle), &msg[2 ]);writel (0x0 , &msg[3 ]);for (i =4 ; i <1024 ; ++i)writel (0x0 , &msg[i]); --2.31.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Applied with the RB fixed.
Thanks!
Alex
Quoted 48 lines · Chen Li
I met a gpu addr bug recently and the kernel log tells me the pc is memcpy/memset and link register is
radeon_uvd_resume.As we know, in some architectures, optimized memcpy/memset may not work well on device memory. Trival memcpy_toio/memset_io can fix this problem.
BTW, amdgpu has already done it in:
commitba0b2275a678("drm/amdgpu: use memcpy_to/fromio for UVD fw upload"), that's why it has no this issue on the same gpu and platform.Signed-off-by Chen Li <[email protected]>Reviewed-by Christian König--- drivers/gpu/drm/radeon/radeon_uvd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_uvd.c +2
-3@@ -288,7 +288,7 @@ int radeon_uvd_resume(struct radeon_device *rdev)if (rdev->uvd.vcpu_bo ==NULL )return -EINVAL ; -memcpy (rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); +memcpy_toio ((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); size =radeon_bo_size (rdev->uvd.vcpu_bo); size -= rdev->uvd_fw->size;@@ -296,7 +296,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) ptr = rdev->uvd.cpu_addr; ptr += rdev->uvd_fw->size; -memset (ptr,0 , size); +memset_io ((void __iomem *)ptr,0 , size);return 0 ; } --2.31.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx