[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a9725264-8d8a-4970-a519-4ca415ce21ee@amd.com>
Date: Thu, 11 Sep 2025 22:28:52 +0530
From: Vasant Hegde <vasant.hegde@....com>
To: Suravee Suthikulpanit <suravee.suthikulpanit@....com>, jgg@...dia.com,
nicolinc@...dia.com
Cc: linux-kernel@...r.kernel.org, robin.murphy@....com, will@...nel.org,
joro@...tes.org, kevin.tian@...el.com, jsnitsel@...hat.com,
iommu@...ts.linux.dev, santosh.shukla@....com, sairaj.arunkodilkar@....com,
jon.grimm@....com, prashanthpra@...gle.com, wvw@...gle.com,
wnliu@...gle.com, gptran@...gle.com, kpsingh@...gle.com
Subject: Re: [PATCH v4] iommu/amd: Add support for hw_info for iommu
capability query
On 9/5/2025 1:01 AM, Suravee Suthikulpanit wrote:
> AMD IOMMU Extended Feature (EFR) and Extended Feature 2 (EFR2) registers
> specify features supported by each IOMMU hardware instance.
> The IOMMU driver checks each feature-specific bits before enabling
> each feature at run time.
>
> For IOMMUFD, the hypervisor passes the raw value of amd_iommu_efr and
> amd_iommu_efr2 to VMM via iommufd IOMMU_DEVICE_GET_HW_INFO ioctl.
>
> Reviewed-by: Nicolin Chen <nicolinc@...dia.com>
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
> ---
.../...
> diff --git a/drivers/iommu/amd/iommufd.c b/drivers/iommu/amd/iommufd.c
> new file mode 100644
> index 000000000000..72eaaa923d04
> --- /dev/null
> +++ b/drivers/iommu/amd/iommufd.c
> @@ -0,0 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2025 Advanced Micro Devices, Inc.
> + */
> +
> +#include <linux/iommu.h>
> +
> +#include "iommufd.h"
> +#include "amd_iommu.h"
> +#include "amd_iommu_types.h"
> +
> +void *amd_iommufd_hw_info(struct device *dev, u32 *length, u32 *type)
> +{
> + struct iommu_hw_info_amd *hwinfo;
> +
> + if (*type != IOMMU_HW_INFO_TYPE_DEFAULT &&
> + *type != IOMMU_HW_INFO_TYPE_AMD)
> + return ERR_PTR(-EOPNOTSUPP);
> +
> + hwinfo = kzalloc(sizeof(*hwinfo), GFP_KERNEL);
> + if (!hwinfo)
> + return ERR_PTR(-ENOMEM);
> +
> + *length = sizeof(*hwinfo);
> + *type = IOMMU_HW_INFO_TYPE_AMD;
> +
> + hwinfo->efr = amd_iommu_efr;
> + hwinfo->efr2 = amd_iommu_efr2;
> +
> + return hwinfo;
> +}
> diff --git a/drivers/iommu/amd/iommufd.h b/drivers/iommu/amd/iommufd.h
> new file mode 100644
> index 000000000000..8b726482778b
> --- /dev/null
> +++ b/drivers/iommu/amd/iommufd.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (C) 2025 Advanced Micro Devices, Inc.
> + */
> +
> +#ifndef AMD_IOMMUFD_H
> +#define AMD_IOMMUFD_H
> +
> +#if IS_ENABLED(CONFIG_IOMMUFD)
It should be `CONFIG_AMD_IOMMU_IOMMUFD`
Otherwise patch looks good to me.
Reviewed-by: Vasant Hegde <vasant.hegde@....com>
-Vasant
Powered by blists - more mailing lists