slim-msm.c: Check for iommu dev before dma_free_coherent

Add a check for iommu device handler before doing dma_free_coherent
as a part of SSR clean up.
This fixes the kernel page table corruption happening due to wrong
device handler used during freeing the resources during SSR cleanup.
This change ensures we use same dev handle for allocating and
freeing the DMA memory.

Change-Id: Ic42d42446dd9954f9c1fc7d282b03d1fa4bc4980
Signed-off-by: Prudhvi Yarlagadda <pyarlaga@codeaurora.org>
This commit is contained in:
Prudhvi Yarlagadda 2020-03-06 20:02:06 +05:30 committed by Gerrit - the friendly Code Review server
parent d4afd5e4be
commit bdd03e1734

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -243,8 +243,11 @@ int msm_slim_sps_mem_alloc(
void
msm_slim_sps_mem_free(struct msm_slim_ctrl *dev, struct sps_mem_buffer *mem)
{
struct device *dma_dev = dev->iommu_desc.cb_dev ?
dev->iommu_desc.cb_dev : dev->dev;
if (mem->base && mem->phys_base)
dma_free_coherent(dev->dev, mem->size, mem->base,
dma_free_coherent(dma_dev, mem->size, mem->base,
mem->phys_base);
else
dev_err(dev->dev, "cant dma free. they are NULL\n");