arm64: mm: Support setting removed_dma_ops in arch_setup_dma_ops

Currently the removed_dma_ops are set only once for dev nodes
which are associated with a reserved-memory region (PIL devices)
in device_init and when the probe of these devices fail,
we end up calling dma_deconfigure which sets the dma_ops to NULL.
Eventually when the probe succeeds, since dma_ops was set to
NULL during probe failure, we end up setting dma_ops to
arm64_swiotlb_dma_ops. Hence in arch_setup_dma_ops, if the
dma_ops is NULL, check to see if there is a reserved memory
associated with the dev and if so set dma_ops to removed_dma_ops
such that the right callback functions are invoked.

Change-Id: Ibc1028391ba90cbdd5c5826022b5015d9e261c09
Signed-off-by: Swathi Sridhar <swatsrid@codeaurora.org>
[sramana@codeaurora.org: Resolve merge conflicts]
Signed-off-by: Srinivas Ramana <sramana@codeaurora.org>
Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org>
This commit is contained in:
Swathi Sridhar
2018-11-07 15:47:36 -08:00
committed by Vijayanand Jitta
parent e80972da27
commit 075169d79b
2 changed files with 30 additions and 2 deletions

View File

@@ -30,6 +30,7 @@
#include <linux/iommu.h>
#include <linux/vmalloc.h>
#include <linux/swiotlb.h>
#include <linux/dma-removed.h>
#include <linux/pci.h>
#include <linux/io.h>
@@ -1081,8 +1082,12 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
{
if (!dev->dma_ops)
dev->dma_ops = &swiotlb_dma_ops;
if (!dev->dma_ops) {
if (dev->removed_mem)
set_dma_ops(dev, &removed_dma_ops);
else
dev->dma_ops = &swiotlb_dma_ops;
}
dev->archdata.dma_coherent = coherent;
__iommu_setup_dma_ops(dev, dma_base, size, iommu);

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef __LINUX_DMA_REMOVED_H
#define __LINUX_DMA_REMOVED_H
extern const struct dma_map_ops removed_dma_ops;
#endif /* __LINUX_DMA_REMOVED_H */