From 0e68c512b4522be55084574b9c32d84783c1bd60 Mon Sep 17 00:00:00 2001 From: Xianglai Li Date: Tue, 24 Jun 2025 17:32:27 +0800 Subject: [PATCH] anolis: drivers/iommu: Fix the initialization failure issue of the iommu module ANBZ: #22171 Add the kernel parameter "allow_unsafe_interrupts". Add support for the def_domain_type callback function. Signed-off-by: Xianglai Li Link: https://gitee.com/anolis/cloud-kernel/pulls/5459 --- anolis/cmdline/loongarch64 | 1 + drivers/iommu/loongarch_iommu.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/anolis/cmdline/loongarch64 b/anolis/cmdline/loongarch64 index 2a48fbe19c0d..cc218653e7db 100644 --- a/anolis/cmdline/loongarch64 +++ b/anolis/cmdline/loongarch64 @@ -1,2 +1,3 @@ cgroup.memory=nokmem crashkernel=1024M +vfio_iommu_type1.allow_unsafe_interrupts=1 diff --git a/drivers/iommu/loongarch_iommu.c b/drivers/iommu/loongarch_iommu.c index 170a062c074f..8c5ba580fc75 100644 --- a/drivers/iommu/loongarch_iommu.c +++ b/drivers/iommu/loongarch_iommu.c @@ -596,6 +596,7 @@ static struct iommu_domain *la_iommu_domain_alloc(unsigned int type) switch (type) { case IOMMU_DOMAIN_BLOCKED: + case IOMMU_DOMAIN_IDENTITY: case IOMMU_DOMAIN_UNMANAGED: info = alloc_dom_info(); if (info == NULL) @@ -847,7 +848,9 @@ static int la_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) la_iommu_detach_dev(dev); - if (domain != NULL && domain->type == IOMMU_DOMAIN_BLOCKED) + if (domain != NULL && + (domain->type == IOMMU_DOMAIN_IDENTITY || + domain->type == IOMMU_DOMAIN_BLOCKED)) return 0; if (domain == NULL) @@ -1178,6 +1181,11 @@ static phys_addr_t la_iommu_iova_to_phys(struct iommu_domain *domain, return phys; } +static int la_iommu_def_domain_type(struct device *dev) +{ + return IOMMU_DOMAIN_IDENTITY; +} + const struct iommu_ops la_iommu_ops = { .capable = la_iommu_capable, .domain_alloc = la_iommu_domain_alloc, @@ -1185,6 +1193,7 @@ const struct iommu_ops la_iommu_ops = { .release_device = la_iommu_remove_device, .device_group = la_iommu_device_group, .pgsize_bitmap = LA_IOMMU_PGSIZE, + .def_domain_type = la_iommu_def_domain_type, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = la_iommu_attach_dev, -- Gitee