iommu: msm: Update lazy in compliance with upstream dma ops
During lazy dma_map_sg, only some entries of the caller's sg list
are stored in the msm_iommu_map->sgl. And lazy dma_unmap_sg uses
this incomplete sgl to perform sg_list walk to determine the total
iova size to unmap (all entries/segments are mapped into a single
contiguous iova). Since sg->page_link is missing, the sg_list walk
ends up into null pointer dereference kernel crash:
BUG: Unable to handle kernel NULL pointer dereference at virtual
address 00000018
PC is at iommu_dma_unmap_sg+0x4c/0xdc
[...]
iommu_dma_unmap_sg+0x4c/0xdc
__iommu_unmap_sg_attrs+0x64/0x6c
msm_iommu_map_release+0x154/0x164
msm_dma_buf_freed+0x168/0x3c8
_ion_buffer_destroy+0x30/0x88
ion_buffer_put+0x40/0x50
ion_handle_destroy+0xec/0x10c
ion_handle_put_nolock+0x40/0x50
ion_ioctl+0x2ec/0x4d4
do_vfs_ioctl+0xd0/0x85c
SyS_ioctl+0x90/0xa4
el0_svc_naked+0x24/0x28
Hence, clone/duplicate the caller's sg list into msm_iommu_map->sgl.
Also, update lazy map/unmap_sg to check DMA_ATTR_SKIP_CPU_SYNC to
skip cache maintenance only if asked for.
Change-Id: Idb7bd52d84d27ad0c7873208a3e25129f20d07da
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
[vinmenon@codeaurora.org: removed unrelated CMO change]
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
1 file changed