Re: [PATCH v5 06/24] iommu/amd: Map vIOMMU VF and VF Control MMIO BARs

From: Suthikulpanit, Suravee

Date: Sun Sep 27 2026 - 21:26:29 EST




On 9/22/2026 1:43 PM, Guixin Liu wrote:
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 7b4cb473019d..79386816807a 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -459,8 +459,10 @@ static void iommu_disable(struct amd_iommu *iommu)
* mapping and unmapping functions for the IOMMU MMIO space. Each AMD IOMMU in
* the system has one.
*/
-static u8 __iomem * __init iommu_map_mmio_space(u64 address, u64 end)
+u8 __iomem * __init iommu_map_mmio_space(u64 address, u64 end)
{
+ u8 __iomem *base;
+
if (!request_mem_region(address, end, "amd_iommu")) {
pr_err("Can not reserve memory region %llx-%llx for mmio\n",
address, end);
@@ -468,10 +470,14 @@ static u8 __iomem * __init iommu_map_mmio_space(u64 address, u64 end)
return NULL;
}
- return (u8 __iomem *)ioremap(address, end);
+ base = ioremap(address, end);
+ if (!base)
+ release_mem_region(address, end);
This release is duplicated with following free_iommu_resources() -> free_iommu_all()
-> free_iommu_one() -> iommu_unmap_mmio_space()

I'll update this in v6.
Thanks,
Suravee