Re: [PATCH 06/22] iommu/amd: Map vIOMMU VF MMIO and VF Control MMIO regions

Weinan Liu
2026-03-31T05:30:26Z

On Mon, Mar 30, 2026 at 1:43 AM Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> wrote:

> diff --git a/drivers/iommu/amd/viommu.c b/drivers/iommu/amd/viommu.c
> index f4b5f96d4785..887a9eb8122d 100644
> --- a/drivers/iommu/amd/viommu.c
> +++ b/drivers/iommu/amd/viommu.c
> +static int __init viommu_vf_vfcntl_init(struct amd_iommu *iommu)
> +{...
> +       /* Mapping 256MB of VF and 4MB of VF_CNTL BARs */
> +       vf_phys &= ~1ULL;
> +       iommu->vf_base = iommu_map_mmio_space(vf_phys, 0x10000000);
> +       if (!iommu->vf_base) {
> +               pr_err("Can't reserve vf_base\n");
> +               return -ENOMEM;
> +       }
> +
> +       vf_cntl_phys &= ~1ULL;
> +       iommu->vfctrl_base = iommu_map_mmio_space(vf_cntl_phys, 0x400000);
> +
> +       if (!iommu->vfctrl_base) {
If this mapping fails, the previously successful mapping of iommu->vf_base need to be clean up
> +               pr_err("Can't reserve vfctrl_base\n");
> +               return -ENOMEM;
> +       }
> +