drm/xe: Apply upper limit to sg element size
authorNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Tue, 16 May 2023 03:26:53 +0000 (03:26 +0000)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:34:01 +0000 (18:34 -0500)
commit1b1d3710380d5f0517dcaabe1b96b6401f68ec37
tree3c58bafc2a821c4f033e78dfa64be24565965bc4
parent6ed6ba32dba14ef851ecb7190597d6bac77618e2
drm/xe: Apply upper limit to sg element size

The iommu_dma_map_sg() function ensures iova allocation doesn't
cross dma segment boundary. It does so by padding some sg elements.
This can cause overflow, ending up with sg->length being set to 0.
Avoid this by halving the maximum segment size (rounded down to
PAGE_SIZE).

Specify maximum segment size for sg elements by using
sg_alloc_table_from_pages_segment() to allocate sg_table.

v2: Use correct max segment size in dma_set_max_seg_size() call

Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Reviewed-by: Bruce Chang <yu.bruce.chang@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_bo.c
drivers/gpu/drm/xe/xe_bo.h
drivers/gpu/drm/xe/xe_mmio.c
drivers/gpu/drm/xe/xe_vm.c