All of lore.kernel.org
 help / color / mirror / Atom feed
* [report] DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
@ 2025-06-18 16:03 Zenghui Yu
  2025-06-18 16:25 ` Thomas Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2025-06-18 16:03 UTC (permalink / raw)
  To: dri-devel, linux-kernel
  Cc: airlied, simona, maarten.lankhorst, mripard, tzimmermann

Hi all,

Running the dmabuf-heap test [*] on mainline kernel triggers the
following splat:

 ------------[ cut here ]------------
 DMA-API: platform vgem: mapping sg segment longer than device claims to
support [len=1048576] [max=65536]
 WARNING: CPU: 7 PID: 1126 at kernel/dma/debug.c:1174
debug_dma_map_sg+0x348/0x3e4
 Modules linked in: vgem drm_shmem_helper drm_kms_helper rfkill drm fuse
backlight sha3_ce sha512_ce ipv6
 CPU: 7 UID: 0 PID: 1126 Comm: dmabuf-heap Kdump: loaded Not tainted
6.16.0-rc2-00024-g9afe652958c3-dirty PREEMPT
 Hardware name: QEMU QEMU Virtual Machine, BIOS
edk2-stable202408-prebuilt.qemu.org 08/13/2024
 pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
 pc : debug_dma_map_sg+0x348/0x3e4
 lr : debug_dma_map_sg+0x348/0x3e4
 sp : ffff800084313a50
 x29: ffff800084313a50 x28: ffff0000c0a62480 x27: 0000000000000001
 x26: ffffffffffffffff x25: 0000000000000000 x24: ffff0000c0985f20
 x23: ffff8000815ab058 x22: 0000000000000001 x21: 0000000000000001
 x20: 0000000000000000 x19: ffff0000c2797010 x18: 0000000000000020
 x17: 0000000000000000 x16: 0000000000000000 x15: 00000000ffffffff
 x14: ffff8000815c6390 x13: 00000000000005bb x12: 00000000000001e9
 x11: fffffffffffe8360 x10: ffff80008161e390 x9 : 00000000fffff000
 x8 : ffff8000815c6390 x7 : ffff80008161e390 x6 : 0000000000000000
 x5 : ffff0001fee21308 x4 : 0000000000000001 x3 : 0000000000000000
 x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000c5ea4600
 Call trace:
  debug_dma_map_sg+0x348/0x3e4 (P)
  __dma_map_sg_attrs+0xbc/0x118
  dma_map_sgtable+0x28/0x44
  system_heap_map_dma_buf+0x2c/0x64
  dma_buf_map_attachment+0x60/0x184
  dma_buf_map_attachment_unlocked+0x3c/0x7c
  drm_gem_prime_import_dev.part.0+0x58/0x130 [drm]
  drm_gem_prime_import+0x48/0xc4 [drm]
  drm_gem_prime_fd_to_handle+0x180/0x220 [drm]
  drm_prime_fd_to_handle_ioctl+0x38/0x44 [drm]
  drm_ioctl_kernel+0xb8/0x12c [drm]
  drm_ioctl+0x204/0x4ec [drm]
  __arm64_sys_ioctl+0xac/0x104
  invoke_syscall+0x48/0x110
  el0_svc_common.constprop.0+0x40/0xe0
  do_el0_svc+0x1c/0x28
  el0_svc+0x34/0x108
  el0t_64_sync_handler+0xc8/0xcc
  el0t_64_sync+0x198/0x19c
 ---[ end trace 0000000000000000 ]---

The kernel is built with arm64's virtconfig and

+CONFIG_DMABUF_HEAPS=y
+CONFIG_DMABUF_HEAPS_SYSTEM=y
+CONFIG_DRM_VGEM=m
+CONFIG_DMA_API_DEBUG=y

[*] linux/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

Thanks,
Zenghui

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

* Re: [report] DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
  2025-06-18 16:03 [report] DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536] Zenghui Yu
@ 2025-06-18 16:25 ` Thomas Zimmermann
  2025-06-19 16:07   ` Zenghui Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Zimmermann @ 2025-06-18 16:25 UTC (permalink / raw)
  To: Zenghui Yu, dri-devel, linux-kernel
  Cc: airlied, simona, maarten.lankhorst, mripard

Hi

Am 18.06.25 um 18:03 schrieb Zenghui Yu:
> Hi all,
>
> Running the dmabuf-heap test [*] on mainline kernel triggers the
> following splat:
>
>   ------------[ cut here ]------------
>   DMA-API: platform vgem: mapping sg segment longer than device claims to
> support [len=1048576] [max=65536]

Thanks for the bug report. We have a possible fix in the latest 
drm-misc-next tree. Does it work if use replace DRM_GEM_SHMEM_DRIVER_OPS 
with DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT at [1]?

[1] 
https://elixir.bootlin.com/linux/v6.16-rc2/source/drivers/gpu/drm/vgem/vgem_drv.c#L118

Best regards
Thomas

>   WARNING: CPU: 7 PID: 1126 at kernel/dma/debug.c:1174
> debug_dma_map_sg+0x348/0x3e4
>   Modules linked in: vgem drm_shmem_helper drm_kms_helper rfkill drm fuse
> backlight sha3_ce sha512_ce ipv6
>   CPU: 7 UID: 0 PID: 1126 Comm: dmabuf-heap Kdump: loaded Not tainted
> 6.16.0-rc2-00024-g9afe652958c3-dirty PREEMPT
>   Hardware name: QEMU QEMU Virtual Machine, BIOS
> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>   pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
>   pc : debug_dma_map_sg+0x348/0x3e4
>   lr : debug_dma_map_sg+0x348/0x3e4
>   sp : ffff800084313a50
>   x29: ffff800084313a50 x28: ffff0000c0a62480 x27: 0000000000000001
>   x26: ffffffffffffffff x25: 0000000000000000 x24: ffff0000c0985f20
>   x23: ffff8000815ab058 x22: 0000000000000001 x21: 0000000000000001
>   x20: 0000000000000000 x19: ffff0000c2797010 x18: 0000000000000020
>   x17: 0000000000000000 x16: 0000000000000000 x15: 00000000ffffffff
>   x14: ffff8000815c6390 x13: 00000000000005bb x12: 00000000000001e9
>   x11: fffffffffffe8360 x10: ffff80008161e390 x9 : 00000000fffff000
>   x8 : ffff8000815c6390 x7 : ffff80008161e390 x6 : 0000000000000000
>   x5 : ffff0001fee21308 x4 : 0000000000000001 x3 : 0000000000000000
>   x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000c5ea4600
>   Call trace:
>    debug_dma_map_sg+0x348/0x3e4 (P)
>    __dma_map_sg_attrs+0xbc/0x118
>    dma_map_sgtable+0x28/0x44
>    system_heap_map_dma_buf+0x2c/0x64
>    dma_buf_map_attachment+0x60/0x184
>    dma_buf_map_attachment_unlocked+0x3c/0x7c
>    drm_gem_prime_import_dev.part.0+0x58/0x130 [drm]
>    drm_gem_prime_import+0x48/0xc4 [drm]
>    drm_gem_prime_fd_to_handle+0x180/0x220 [drm]
>    drm_prime_fd_to_handle_ioctl+0x38/0x44 [drm]
>    drm_ioctl_kernel+0xb8/0x12c [drm]
>    drm_ioctl+0x204/0x4ec [drm]
>    __arm64_sys_ioctl+0xac/0x104
>    invoke_syscall+0x48/0x110
>    el0_svc_common.constprop.0+0x40/0xe0
>    do_el0_svc+0x1c/0x28
>    el0_svc+0x34/0x108
>    el0t_64_sync_handler+0xc8/0xcc
>    el0t_64_sync+0x198/0x19c
>   ---[ end trace 0000000000000000 ]---
>
> The kernel is built with arm64's virtconfig and
>
> +CONFIG_DMABUF_HEAPS=y
> +CONFIG_DMABUF_HEAPS_SYSTEM=y
> +CONFIG_DRM_VGEM=m
> +CONFIG_DMA_API_DEBUG=y
>
> [*] linux/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
>
> Thanks,
> Zenghui

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


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

* Re: [report] DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
  2025-06-18 16:25 ` Thomas Zimmermann
@ 2025-06-19 16:07   ` Zenghui Yu
  2025-06-20  5:17     ` Thomas Zimmermann
  0 siblings, 1 reply; 4+ messages in thread
From: Zenghui Yu @ 2025-06-19 16:07 UTC (permalink / raw)
  To: Thomas Zimmermann
  Cc: dri-devel, linux-kernel, airlied, simona, maarten.lankhorst,
	mripard

Hi Thomas,

On 2025/6/19 00:25, Thomas Zimmermann wrote:
> Hi
> 
> Am 18.06.25 um 18:03 schrieb Zenghui Yu:
> > Hi all,
> >
> > Running the dmabuf-heap test [*] on mainline kernel triggers the
> > following splat:
> >
> >  ------------[ cut here ]------------
> >  DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
> 
> Thanks for the bug report. We have a possible fix in the latest drm-
> misc-next tree. Does it work if use replace DRM_GEM_SHMEM_DRIVER_OPS
> with DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT at [1]?
> 
> [1] https://elixir.bootlin.com/linux/v6.16-rc2/source/drivers/gpu/drm/vgem/vgem_drv.c#L118

Thanks for the heads up! So I applied commit 660cd44659a0
("drm/shmem-helper: Import dmabuf without mapping its sg_table") [*] in
my local tree, together with your suggestion:

diff --git a/drivers/gpu/drm/vgem/vgem_drv.c
b/drivers/gpu/drm/vgem/vgem_drv.c
index 2752ab4f1c97..ba0d4e611bd2 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -115,7 +115,7 @@ static const struct drm_driver vgem_driver = {
 	.num_ioctls 			= ARRAY_SIZE(vgem_ioctls),
 	.fops				= &vgem_driver_fops,

-	DRM_GEM_SHMEM_DRIVER_OPS,
+	DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT,
 	.gem_create_object		= vgem_gem_create_object,

 	.name	= DRIVER_NAME,

The warning message disappeared with that. Thanks again!

[*]
https://gitlab.freedesktop.org/drm/kernel/-/commit/660cd44659a05c5fbfce6d2bb1ce448aa0f35594

Zenghui

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

* Re: [report] DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
  2025-06-19 16:07   ` Zenghui Yu
@ 2025-06-20  5:17     ` Thomas Zimmermann
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Zimmermann @ 2025-06-20  5:17 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: dri-devel, linux-kernel, airlied, simona, maarten.lankhorst,
	mripard

Hi

Am 19.06.25 um 18:07 schrieb Zenghui Yu:
> Hi Thomas,
>
> On 2025/6/19 00:25, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 18.06.25 um 18:03 schrieb Zenghui Yu:
>>> Hi all,
>>>
>>> Running the dmabuf-heap test [*] on mainline kernel triggers the
>>> following splat:
>>>
>>>   ------------[ cut here ]------------
>>>   DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
>> Thanks for the bug report. We have a possible fix in the latest drm-
>> misc-next tree. Does it work if use replace DRM_GEM_SHMEM_DRIVER_OPS
>> with DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT at [1]?
>>
>> [1] https://elixir.bootlin.com/linux/v6.16-rc2/source/drivers/gpu/drm/vgem/vgem_drv.c#L118
> Thanks for the heads up! So I applied commit 660cd44659a0
> ("drm/shmem-helper: Import dmabuf without mapping its sg_table") [*] in
> my local tree, together with your suggestion:
>
> diff --git a/drivers/gpu/drm/vgem/vgem_drv.c
> b/drivers/gpu/drm/vgem/vgem_drv.c
> index 2752ab4f1c97..ba0d4e611bd2 100644
> --- a/drivers/gpu/drm/vgem/vgem_drv.c
> +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> @@ -115,7 +115,7 @@ static const struct drm_driver vgem_driver = {
>   	.num_ioctls 			= ARRAY_SIZE(vgem_ioctls),
>   	.fops				= &vgem_driver_fops,
>
> -	DRM_GEM_SHMEM_DRIVER_OPS,
> +	DRM_GEM_SHMEM_DRIVER_OPS_NO_MAP_SGT,
>   	.gem_create_object		= vgem_gem_create_object,
>
>   	.name	= DRIVER_NAME,
>
> The warning message disappeared with that. Thanks again!

Thanks for testing. I'll attempt to get this change into upstream in the 
near future.

Best regards
Thomas

>
> [*]
> https://gitlab.freedesktop.org/drm/kernel/-/commit/660cd44659a05c5fbfce6d2bb1ce448aa0f35594
>
> Zenghui

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)


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

end of thread, other threads:[~2025-06-20  5:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 16:03 [report] DMA-API: platform vgem: mapping sg segment longer than device claims to support [len=1048576] [max=65536] Zenghui Yu
2025-06-18 16:25 ` Thomas Zimmermann
2025-06-19 16:07   ` Zenghui Yu
2025-06-20  5:17     ` Thomas Zimmermann

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.