Skip to content

Commit 60fedb2

Browse files
LuBaolujgunthorpe
authored andcommitted
iommu: Add new iommu op to get iommu hardware information
Introduce a new iommu op to get the IOMMU hardware capabilities for iommufd. This information will be used by any vIOMMU driver which is owned by userspace. This op chooses to make the special parameters opaque to the core. This suits the current usage model where accessing any of the IOMMU device special parameters does require a userspace driver that matches the kernel driver. If a need for common parameters, implemented similarly by several drivers, arises then there's room in the design to grow a generic parameter set as well. No wrapper API is added as it is supposed to be used by iommufd only. Different IOMMU hardware would have different hardware information. So the information reported differs as well. To let the external user understand the difference, enum iommu_hw_info_type is defined. For the iommu drivers that are capable to report hardware information, it should have a unique iommu_hw_info_type and return to caller. For the driver doesn't report hardware information, caller just uses IOMMU_HW_INFO_TYPE_NONE if a type is required. Link: https://lore.kernel.org/r/20230818101033.4100-3-yi.l.liu@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Co-developed-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 92766e1 commit 60fedb2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/linux/iommu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ struct iommu_iotlb_gather {
228228
/**
229229
* struct iommu_ops - iommu ops and capabilities
230230
* @capable: check capability
231+
* @hw_info: report iommu hardware information. The data buffer returned by this
232+
* op is allocated in the iommu driver and freed by the caller after
233+
* use. The information type is one of enum iommu_hw_info_type defined
234+
* in include/uapi/linux/iommufd.h.
231235
* @domain_alloc: allocate iommu domain
232236
* @probe_device: Add device to iommu driver handling
233237
* @release_device: Remove device from iommu driver handling
@@ -257,6 +261,7 @@ struct iommu_iotlb_gather {
257261
*/
258262
struct iommu_ops {
259263
bool (*capable)(struct device *dev, enum iommu_cap);
264+
void *(*hw_info)(struct device *dev, u32 *length, u32 *type);
260265

261266
/* Domain allocation and freeing by the iommu driver */
262267
struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);

include/uapi/linux/iommufd.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,13 @@ struct iommu_hwpt_alloc {
370370
__u32 __reserved;
371371
};
372372
#define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC)
373+
374+
/**
375+
* enum iommu_hw_info_type - IOMMU Hardware Info Types
376+
* @IOMMU_HW_INFO_TYPE_NONE: Used by the drivers that do not report hardware
377+
* info
378+
*/
379+
enum iommu_hw_info_type {
380+
IOMMU_HW_INFO_TYPE_NONE,
381+
};
373382
#endif

0 commit comments

Comments
 (0)