dma-buf: dma-heap set device max_segment_size to DMA_BIT_MASK(32)

With CONFIG_DMA_API_DEBUG_SG enabled built:

[   14.668444][  T369] ------------[ cut here ]------------
[   14.668476][  T369] DMA-API: dma_heap system-uncached: mapping sg segment longer than device claims to support [len=1048576] [max=65536]
[   14.668508][  T369] WARNING: CPU: 1 PID: 369 at kernel/dma/debug.c:1173 debug_dma_map_sg+0x1d4/0x3f8
[   14.668517][  T369] Modules linked in:
[   14.668533][  T369] CPU: 1 PID: 369 Comm: HwBinder:364_2 Not tainted 5.10.43 #53
[   14.668542][  T369] Hardware name: Rockchip RK3588 EVB2 LP4 V10 Board (DT)
[   14.668553][  T369] pstate: 60400009 (nZCv daif +PAN -UAO -TCO BTYPE=--)
[   14.668564][  T369] pc : debug_dma_map_sg+0x1d4/0x3f8
[   14.668574][  T369] lr : debug_dma_map_sg+0x1d4/0x3f8
[   14.668582][  T369] sp : ffffffc015cb3a90
[   14.668591][  T369] x29: ffffffc015cb3ab0 x28: ffffff8003557000
[   14.668605][  T369] x27: 0000000000000011 x26: 0000000000010000
[   14.668619][  T369] x25: ffffffffffffffff x24: ffffffc015cb3c90
[   14.668632][  T369] x23: ffffff80057fec00 x22: ffffff80055c1c00
[   14.668646][  T369] x21: ffffffc011fbf000 x20: 0000000000000011
[   14.668660][  T369] x19: ffffffc011dd9000 x18: ffffffc015ce5050
[   14.668673][  T369] x17: 0000000000000000 x16: 00000000000000d8
[   14.668686][  T369] x15: 0000000000000004 x14: 0000000000003fff
[   14.668699][  T369] x13: ffffffc011e5c9e8 x12: 0000000000000003
[   14.668712][  T369] x11: 00000000ffffbfff x10: 00000000ffffffff
[   14.668725][  T369] x9 : 20e580535cacc400 x8 : 20e580535cacc400
[   14.668738][  T369] x7 : 3d6e656c5b207472 x6 : ffffffc01205b610
[   14.668751][  T369] x5 : ffffffffffffffff x4 : 0000000000000000
[   14.668765][  T369] x3 : ffffffc011b27378 x2 : 0000000000000000
[   14.668777][  T369] x1 : 0000000000000001 x0 : 0000000000000074
[   14.668791][  T369] Call trace:
[   14.668802][  T369]  debug_dma_map_sg+0x1d4/0x3f8
[   14.668814][  T369]  dma_map_sg_attrs+0x7c/0xcc
[   14.668828][  T369]  system_heap_do_allocate+0x78c/0x7d4
[   14.668839][  T369]  system_uncached_heap_allocate+0x18/0x28
[   14.668850][  T369]  dma_heap_ioctl+0x140/0x1f0
[   14.668862][  T369]  __arm64_sys_ioctl+0x94/0xd0
[   14.668875][  T369]  el0_svc_common+0xa4/0x180
[   14.668885][  T369]  do_el0_svc+0x28/0x88
[   14.668897][  T369]  el0_svc+0x14/0x24
[   14.668906][  T369]  el0_sync_handler+0x88/0xec
[   14.668917][  T369]  el0_sync+0x1a8/0x1c0
[   14.668925][  T369] ---[ end trace acb8f73633a08943 ]---

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Change-Id: I551ae9da257c1337e857de8a21931594f8d25d3c
This commit is contained in:
Jianqun Xu 2021-11-24 08:55:27 +08:00 committed by Tao Huang
commit 146b4dc1de

View file

@ -358,6 +358,22 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
goto err2;
}
if (IS_ENABLED(CONFIG_NO_GKI)) {
heap->heap_dev->dma_parms = kzalloc(sizeof(*heap->heap_dev->dma_parms), GFP_KERNEL);
if (!heap->heap_dev->dma_parms) {
err_ret = ERR_PTR(-ENOMEM);
goto err3;
}
ret = dma_set_max_seg_size(heap->heap_dev, (unsigned int)DMA_BIT_MASK(32));
if (ret) {
pr_err("dma_heap: Unable to set seg size\n");
kfree(heap->heap_dev->dma_parms);
err_ret = ERR_PTR(ret);
goto err3;
}
}
/* Make sure it doesn't disappear on us */
heap->heap_dev = get_device(heap->heap_dev);
@ -368,6 +384,8 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
return heap;
err3:
device_destroy(dma_heap_class, heap->heap_devt);
err2:
cdev_del(&heap->heap_cdev);
err1: