Commit 72fe4978 authored by Xianglai Li's avatar Xianglai Li
Browse files

LoongArch: add iommu support

LoongArch inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IB8FYW



------------------------------------------

Added iommu support for loongarch

Signed-off-by: default avatarXianglai Li <lixianglai@loongson.cn>
parent 083374f2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2200,3 +2200,7 @@ CONFIG_FUNCTION_TRACER=y
# CONFIG_STRICT_DEVMEM is not set
CONFIG_UNWINDER_ORC=y
# CONFIG_RUNTIME_TESTING_MENU is not set
CONFIG_LOONGARCH_IOMMU=m
CONFIG_IOMMU_DEFAULT_PASSTHROUGH=y
CONFIG_CMDLINE_EXTEND=y
CONFIG_CMDLINE="vfio_iommu_type1.allow_unsafe_interrupts=1 nokaslr"
+36 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Arch specific extensions to struct device
 *
 * This file is released under the GPLv2
 * Copyright (C) 2020 Loongson Technology Corporation Limited
 */
#ifndef _ASM_LOONGARCH_DEVICE_H
#define _ASM_LOONGARCH_DEVICE_H

struct dev_archdata {
	/* hook for IOMMU specific extension */
	void *iommu;
	struct bus_dma_region *dma_range_map;
	/*
	 * On some old 7A chipset, dma address is different from physical
	 * address, the main difference is that node id. For dma address
	 * node id starts from bit 36, physical node id starts from
	 * bit 44. The remaining address below node id is the same.
	 */
	unsigned long   dma_node_mask;
	unsigned int	dma_node_off;
};

struct pdev_archdata {
};

struct dma_domain {
	struct list_head node;
	const struct dma_map_ops *dma_ops;
	int domain_nr;
};
void add_dma_domain(struct dma_domain *domain);
void del_dma_domain(struct dma_domain *domain);

#endif /* _ASM_LOONGARCH_DEVICE_H*/
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ config KVM
	select SCHED_INFO
	select MMU_NOTIFIER
	select PREEMPT_NOTIFIERS
	select KVM_VFIO
	help
	  Support hosting virtualized guest machines using
	  hardware virtualization extensions. You will need
+14 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ config OF_IOMMU

# IOMMU-agnostic DMA-mapping layer
config IOMMU_DMA
	def_bool ARM64 || IA64 || X86 || S390
	def_bool ARM64 || IA64 || X86 || S390 || LOONGARCH
	select DMA_OPS
	select IOMMU_API
	select IOMMU_IOVA
@@ -527,4 +527,17 @@ config SMMU_BYPASS_DEV
	  E.g:SMMU allow iMR3408/3416 Raid bypass at DMA default domain
	  to support other devices Virtualization through.

# LOONGARCH IOMMU support
config LOONGARCH_IOMMU
	tristate "LOONGARCH IOMMU support"
	select IOMMU_API
	select IOMMU_DEFAULT_PASSTHROUGH
	depends on LOONGARCH
	help
	  With this option you can enable support for LOONGARCH IOMMU hardware in
	  your system. An IOMMU is a hardware component which provides
	  remapping of DMA memory accesses from devices. With an LOONGARCH IOMMU you
	  can isolate the DMA memory of different devices and protect the
	  system from misbehaving device drivers or hardware.

endif # IOMMU_SUPPORT
+2 −0
Original line number Diff line number Diff line
@@ -30,3 +30,5 @@ obj-$(CONFIG_IOMMU_SVA) += iommu-sva.o
obj-$(CONFIG_IOMMU_IOPF) += io-pgfault.o
obj-$(CONFIG_SPRD_IOMMU) += sprd-iommu.o
obj-$(CONFIG_APPLE_DART) += apple-dart.o
obj-$(CONFIG_LOONGARCH_IOMMU) += loongarch_iommu.o
Loading