Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2107724a authored by Swathi Sridhar's avatar Swathi Sridhar Committed by Suren Baghdasaryan
Browse files

ANDROID: GKI: 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.

Bug: 145617272
Signed-off-by: default avatarSwathi Sridhar <swatsrid@codeaurora.org>

[surenb: cherry picked from commit:
903192a5 "mm: Support setting removed_dma_ops in arch_setup_dma_ops"]
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
Change-Id: Ibc1028391ba90cbdd5c5826022b5015d9e261c09
parent c9a57405
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <linux/dma-contiguous.h>
#include <linux/vmalloc.h>
#include <linux/swiotlb.h>
#include <linux/dma-removed.h>
#include <linux/pci.h>

#include <asm/cacheflush.h>
@@ -941,8 +942,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)
	if (!dev->dma_ops) {
		if (dev->removed_mem)
			set_dma_ops(dev, &removed_dma_ops);
		else
			dev->dma_ops = &arm64_swiotlb_dma_ops;
	}

	dev->archdata.dma_coherent = coherent;
	__iommu_setup_dma_ops(dev, dma_base, size, iommu);
+8 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_DMA_REMOVED_H
#define __LINUX_DMA_REMOVED_H

extern const struct dma_map_ops removed_dma_ops;

#endif /*  __LINUX_DMA_REMOVED_H */