All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/[amdgpu|radeon]: fix memset on io mem
@ 2020-12-16  5:41 Chen Li
  2020-12-16  7:59 ` Christian König
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Chen Li @ 2020-12-16  5:41 UTC (permalink / raw)
  To: Alex Deucher, "Christian König", dri-devel


When using e8860(gcn1) on arm64, the kernel crashed on drm/radeon:

[   11.240414] pc : __memset+0x4c/0x188
[   11.244101] lr : radeon_uvd_get_create_msg+0x114/0x1d0 [radeon]
[   11.249995] sp : ffff00000d7eb700
[   11.253295] x29: ffff00000d7eb700 x28: ffff8001f632a868
[   11.258585] x27: 0000000000040000 x26: ffff00000de00000
[   11.263875] x25: 0000000000000125 x24: 0000000000000001
[   11.269168] x23: 0000000000000000 x22: 0000000000000005
[   11.274459] x21: ffff00000df24000 x20: ffff8001f74b4000
[   11.279753] x19: 0000000000124000 x18: 0000000000000020
[   11.285043] x17: 0000000000000000 x16: 0000000000000000
[   11.290336] x15: ffff000009309000 x14: ffffffffffffffff
[   11.290340] x13: ffff0000094b6f88 x12: ffff0000094b6bd2
[   11.290343] x11: ffff00000d7eb700 x10: ffff00000d7eb700
[   11.306246] x9 : ffff00000d7eb700 x8 : ffff00000df2402c
[   11.306254] x7 : 0000000000000000 x6 : ffff0000094b626a
[   11.306257] x5 : 0000000000000000 x4 : 0000000000000004
[   11.306262] x3 : ffffffffffffffff x2 : 0000000000000fd4
[   11.306265] x1 : 0000000000000000 x0 : ffff00000df2402c
[   11.306272] Call trace:
[   11.306316]  __memset+0x4c/0x188
[   11.306638]  uvd_v1_0_ib_test+0x70/0x1c0 [radeon]
[   11.306758]  radeon_ib_ring_tests+0x54/0xe0 [radeon]
[   11.309961] IPv6: ADDRCONF(NETDEV_UP): enp5s0f0: link is not ready
[   11.354628]  radeon_device_init+0x53c/0xbdc [radeon]
[   11.354693]  radeon_driver_load_kms+0x6c/0x1b0 [radeon]
[   11.364788]  drm_dev_register+0x130/0x1c0
[   11.364794]  drm_get_pci_dev+0x8c/0x14c
[   11.372704]  radeon_pci_probe+0xb0/0x110 [radeon]
[   11.372715]  local_pci_probe+0x3c/0xb0
[   11.381129]  pci_device_probe+0x114/0x1b0
[   11.385121]  really_probe+0x23c/0x400
[   11.388757]  driver_probe_device+0xdc/0x130
[   11.392921]  __driver_attach+0x128/0x150
[   11.396826]  bus_for_each_dev+0x70/0xbc
[   11.400643]  driver_attach+0x20/0x2c
[   11.404201]  bus_add_driver+0x160/0x260
[   11.408019]  driver_register+0x74/0x120
[   11.411837]  __pci_register_driver+0x40/0x50
[   11.416149]  radeon_init+0x78/0x1000 [radeon]
[   11.420489]  do_one_initcall+0x54/0x154
[   11.424310]  do_init_module+0x54/0x260
[   11.428041]  load_module+0x1ccc/0x20b0
[   11.431773]  __se_sys_finit_module+0xac/0x10c
[   11.436109]  __arm64_sys_finit_module+0x18/0x20
[   11.440622]  el0_svc_common+0x70/0x164
[   11.444353]  el0_svc_handler+0x2c/0x80
[   11.448084]  el0_svc+0x8/0xc
[   11.450954] Code: d65f03c0 cb0803e4 f2400c84 54000080 (a9001d07)

Obviously, the __memset call is generated by gcc(8.3.1). It optimizes
this for loop into memset. But this may break, because dest here is
cpu_addr mapped to io mem. So, just invoke `memset_io` directly, which
do solve the problem here.

Signed-off-by: chenli <chenli@uniontech.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 6 ++----
 drivers/gpu/drm/radeon/radeon_uvd.c     | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 7c5b60e53482..4dccde7a9e83 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -1187,8 +1187,7 @@ int amdgpu_uvd_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
 	msg[8] = cpu_to_le32(0x00000440);
 	msg[9] = cpu_to_le32(0x00000000);
 	msg[10] = cpu_to_le32(0x01b37000);
-	for (i = 11; i < 1024; ++i)
-		msg[i] = cpu_to_le32(0x0);
+	memset_io(&msg[i], 0x0, 1013 * sizeof(uint32_t));
 
 	return amdgpu_uvd_send_msg(ring, bo, true, fence);
 }
@@ -1212,8 +1211,7 @@ int amdgpu_uvd_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
 	msg[1] = cpu_to_le32(0x00000002);
 	msg[2] = cpu_to_le32(handle);
 	msg[3] = cpu_to_le32(0x00000000);
-	for (i = 4; i < 1024; ++i)
-		msg[i] = cpu_to_le32(0x0);
+	memset_io(&msg[i], 0x0, 1020 * sizeof(uint32_t));
 
 	return amdgpu_uvd_send_msg(ring, bo, direct, fence);
 }
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 57fb3eb3a4b4..2e2e737c4706 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -802,8 +802,7 @@ int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,
 	msg[8] = cpu_to_le32(0x00000440);
 	msg[9] = cpu_to_le32(0x00000000);
 	msg[10] = cpu_to_le32(0x01b37000);
-	for (i = 11; i < 1024; ++i)
-		msg[i] = cpu_to_le32(0x0);
+	memset_io(&msg[i], 0x0, 1013 * sizeof(uint32_t));
 
 	r = radeon_uvd_send_msg(rdev, ring, addr, fence);
 	radeon_bo_unreserve(rdev->uvd.vcpu_bo);
@@ -831,8 +830,7 @@ int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,
 	msg[1] = cpu_to_le32(0x00000002);
 	msg[2] = cpu_to_le32(handle);
 	msg[3] = cpu_to_le32(0x00000000);
-	for (i = 4; i < 1024; ++i)
-		msg[i] = cpu_to_le32(0x0);
+	memset_io(&msg[i], 0x0, 1020 * sizeof(uint32_t));
 
 	r = radeon_uvd_send_msg(rdev, ring, addr, fence);
 	radeon_bo_unreserve(rdev->uvd.vcpu_bo);
-- 
2.29.2



_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 26+ messages in thread
* Re: [PATCH] drm/[amdgpu|radeon]: fix memset on io mem
@ 2020-12-16 12:12 kernel test robot
  0 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2020-12-16 12:12 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7205 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <877dpiz4sf.wl-chenli@uniontech.com>
References: <877dpiz4sf.wl-chenli@uniontech.com>
TO: Chen Li <chenli@uniontech.com>
TO: Alex Deucher <alexander.deucher@amd.com>
TO: "Christian König" <christian.koenig@amd.com>
TO: dri-devel(a)lists.freedesktop.org

Hi Chen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.10 next-20201215]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Chen-Li/drm-amdgpu-radeon-fix-memset-on-io-mem/20201216-165835
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d01e7f10dae29eba0f9ada82b65d24e035d5b2f9
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
config: x86_64-randconfig-m001-20201216 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/gpu/drm/radeon/radeon_uvd.c:805 radeon_uvd_get_create_msg() error: uninitialized symbol 'i'.
drivers/gpu/drm/radeon/radeon_uvd.c:833 radeon_uvd_get_destroy_msg() error: uninitialized symbol 'i'.

Old smatch warnings:
drivers/gpu/drm/radeon/radeon_uvd.c:568 radeon_uvd_cs_msg() warn: ignoring unreachable code.

vim +/i +805 drivers/gpu/drm/radeon/radeon_uvd.c

f2ba57b5eab8817 Christian König 2013-04-08  771  
3cf8bb1ad1b8266 Jérome Glisse   2016-03-16  772  /*
3cf8bb1ad1b8266 Jérome Glisse   2016-03-16  773   * multiple fence commands without any stream commands in between can
3cf8bb1ad1b8266 Jérome Glisse   2016-03-16  774   * crash the vcpu so just try to emmit a dummy create/destroy msg to
3cf8bb1ad1b8266 Jérome Glisse   2016-03-16  775   * avoid this
3cf8bb1ad1b8266 Jérome Glisse   2016-03-16  776   */
f2ba57b5eab8817 Christian König 2013-04-08  777  int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,
f2ba57b5eab8817 Christian König 2013-04-08  778  			      uint32_t handle, struct radeon_fence **fence)
f2ba57b5eab8817 Christian König 2013-04-08  779  {
feba9b0bcf492ba Christian König 2014-08-22  780  	/* we use the last page of the vcpu bo for the UVD message */
feba9b0bcf492ba Christian König 2014-08-22  781  	uint64_t offs = radeon_bo_size(rdev->uvd.vcpu_bo) -
feba9b0bcf492ba Christian König 2014-08-22  782  		RADEON_GPU_PAGE_SIZE;
f2ba57b5eab8817 Christian König 2013-04-08  783  
feba9b0bcf492ba Christian König 2014-08-22  784  	uint32_t *msg = rdev->uvd.cpu_addr + offs;
feba9b0bcf492ba Christian König 2014-08-22  785  	uint64_t addr = rdev->uvd.gpu_addr + offs;
f2ba57b5eab8817 Christian König 2013-04-08  786  
feba9b0bcf492ba Christian König 2014-08-22  787  	int r, i;
f2ba57b5eab8817 Christian König 2013-04-08  788  
feba9b0bcf492ba Christian König 2014-08-22  789  	r = radeon_bo_reserve(rdev->uvd.vcpu_bo, true);
feba9b0bcf492ba Christian König 2014-08-22  790  	if (r)
f2ba57b5eab8817 Christian König 2013-04-08  791  		return r;
f2ba57b5eab8817 Christian König 2013-04-08  792  
f2ba57b5eab8817 Christian König 2013-04-08  793  	/* stitch together an UVD create msg */
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  794  	msg[0] = cpu_to_le32(0x00000de4);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  795  	msg[1] = cpu_to_le32(0x00000000);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  796  	msg[2] = cpu_to_le32(handle);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  797  	msg[3] = cpu_to_le32(0x00000000);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  798  	msg[4] = cpu_to_le32(0x00000000);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  799  	msg[5] = cpu_to_le32(0x00000000);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  800  	msg[6] = cpu_to_le32(0x00000000);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  801  	msg[7] = cpu_to_le32(0x00000780);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  802  	msg[8] = cpu_to_le32(0x00000440);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  803  	msg[9] = cpu_to_le32(0x00000000);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  804  	msg[10] = cpu_to_le32(0x01b37000);
201257d71c519be Chen Li         2020-12-16 @805  	memset_io(&msg[i], 0x0, 1013 * sizeof(uint32_t));
f2ba57b5eab8817 Christian König 2013-04-08  806  
feba9b0bcf492ba Christian König 2014-08-22  807  	r = radeon_uvd_send_msg(rdev, ring, addr, fence);
feba9b0bcf492ba Christian König 2014-08-22  808  	radeon_bo_unreserve(rdev->uvd.vcpu_bo);
feba9b0bcf492ba Christian König 2014-08-22  809  	return r;
f2ba57b5eab8817 Christian König 2013-04-08  810  }
f2ba57b5eab8817 Christian König 2013-04-08  811  
f2ba57b5eab8817 Christian König 2013-04-08  812  int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,
f2ba57b5eab8817 Christian König 2013-04-08  813  			       uint32_t handle, struct radeon_fence **fence)
f2ba57b5eab8817 Christian König 2013-04-08  814  {
feba9b0bcf492ba Christian König 2014-08-22  815  	/* we use the last page of the vcpu bo for the UVD message */
feba9b0bcf492ba Christian König 2014-08-22  816  	uint64_t offs = radeon_bo_size(rdev->uvd.vcpu_bo) -
feba9b0bcf492ba Christian König 2014-08-22  817  		RADEON_GPU_PAGE_SIZE;
f2ba57b5eab8817 Christian König 2013-04-08  818  
feba9b0bcf492ba Christian König 2014-08-22  819  	uint32_t *msg = rdev->uvd.cpu_addr + offs;
feba9b0bcf492ba Christian König 2014-08-22  820  	uint64_t addr = rdev->uvd.gpu_addr + offs;
f2ba57b5eab8817 Christian König 2013-04-08  821  
feba9b0bcf492ba Christian König 2014-08-22  822  	int r, i;
f2ba57b5eab8817 Christian König 2013-04-08  823  
feba9b0bcf492ba Christian König 2014-08-22  824  	r = radeon_bo_reserve(rdev->uvd.vcpu_bo, true);
feba9b0bcf492ba Christian König 2014-08-22  825  	if (r)
f2ba57b5eab8817 Christian König 2013-04-08  826  		return r;
f2ba57b5eab8817 Christian König 2013-04-08  827  
f2ba57b5eab8817 Christian König 2013-04-08  828  	/* stitch together an UVD destroy msg */
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  829  	msg[0] = cpu_to_le32(0x00000de4);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  830  	msg[1] = cpu_to_le32(0x00000002);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  831  	msg[2] = cpu_to_le32(handle);
9b1be4dc02bb6b9 Alex Deucher    2013-06-07  832  	msg[3] = cpu_to_le32(0x00000000);
201257d71c519be Chen Li         2020-12-16 @833  	memset_io(&msg[i], 0x0, 1020 * sizeof(uint32_t));
f2ba57b5eab8817 Christian König 2013-04-08  834  
feba9b0bcf492ba Christian König 2014-08-22  835  	r = radeon_uvd_send_msg(rdev, ring, addr, fence);
feba9b0bcf492ba Christian König 2014-08-22  836  	radeon_bo_unreserve(rdev->uvd.vcpu_bo);
feba9b0bcf492ba Christian König 2014-08-22  837  	return r;
f2ba57b5eab8817 Christian König 2013-04-08  838  }
55b51c88c5167ba Christian König 2013-04-18  839  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33007 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-12-20 11:10 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16  5:41 [PATCH] drm/[amdgpu|radeon]: fix memset on io mem Chen Li
2020-12-16  7:59 ` Christian König
2020-12-16 13:48   ` Chen Li
2020-12-16 14:19     ` Christian König
2020-12-17  1:07       ` Chen Li
2020-12-17 10:25         ` Christian König
2020-12-17 13:37           ` Chen Li
2020-12-17 14:16             ` Christian König
2020-12-18  3:51               ` Chen Li
2020-12-18  8:10                 ` Christian König
2020-12-18  8:52                   ` Chen Li
2020-12-18 10:41                     ` Christian König
2020-12-17 13:45           ` Robin Murphy
2020-12-17 14:02             ` Christian König
2020-12-17 14:18               ` Lucas Stach
2020-12-18 14:17               ` Robin Murphy
2020-12-18 14:33                 ` Christian König
2020-12-18 15:19                   ` Robin Murphy
2020-12-18  6:14             ` Chen Li
2020-12-18 14:42               ` Robin Murphy
2020-12-16 12:52 ` [kbuild] " Dan Carpenter
2020-12-16 12:52   ` Dan Carpenter
2020-12-16 12:52   ` Dan Carpenter
2020-12-16 13:00 ` kernel test robot
2020-12-16 13:00   ` kernel test robot
2020-12-16 12:12 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.