Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/core: Set DMA parameters correctly

The dma_set_max_seg_size() call in setup_dma_device() does not have any
effect since device->dev.dma_parms is NULL. Fix this by initializing
device->dev.dma_parms first.

Link: https://lore.kernel.org/r/20191025225830.257535-5-bvanassche@acm.org
Fixes: d10bcf947a3e ("RDMA/umem: Combine contiguous PAGE_SIZE regions in SGEs")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Bart Van Assche and committed by
Jason Gunthorpe
c9121262 a401fb81

+14 -2
+14 -2
drivers/infiniband/core/device.c
··· 1196 1196 WARN_ON_ONCE(!parent); 1197 1197 device->dma_device = parent; 1198 1198 } 1199 - /* Setup default max segment size for all IB devices */ 1200 - dma_set_max_seg_size(device->dma_device, SZ_2G); 1201 1199 1200 + if (!device->dev.dma_parms) { 1201 + if (parent) { 1202 + /* 1203 + * The caller did not provide DMA parameters, so 1204 + * 'parent' probably represents a PCI device. The PCI 1205 + * core sets the maximum segment size to 64 1206 + * KB. Increase this parameter to 2 GB. 1207 + */ 1208 + device->dev.dma_parms = parent->dma_parms; 1209 + dma_set_max_seg_size(device->dma_device, SZ_2G); 1210 + } else { 1211 + WARN_ON_ONCE(true); 1212 + } 1213 + } 1202 1214 } 1203 1215 1204 1216 /*