Skip to content

Commit 7623683

Browse files
jpemartinsjgunthorpe
authored andcommitted
iommufd: Add capabilities to IOMMU_GET_HW_INFO
Extend IOMMUFD_CMD_GET_HW_INFO op to query generic iommu capabilities for a given device. Capabilities are IOMMU agnostic and use device_iommu_capable() API passing one of the IOMMU_CAP_*. Enumerate IOMMU_CAP_DIRTY_TRACKING for now in the out_capabilities field returned back to userspace. Link: https://lore.kernel.org/r/20231024135109.73787-9-joao.m.martins@oracle.com Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent b9a60d6 commit 7623683

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/iommu/iommufd/device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,10 @@ int iommufd_get_hw_info(struct iommufd_ucmd *ucmd)
11851185
*/
11861186
cmd->data_len = data_len;
11871187

1188+
cmd->out_capabilities = 0;
1189+
if (device_iommu_capable(idev->dev, IOMMU_CAP_DIRTY_TRACKING))
1190+
cmd->out_capabilities |= IOMMU_HW_CAP_DIRTY_TRACKING;
1191+
11881192
rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
11891193
out_free:
11901194
kfree(data);

include/uapi/linux/iommufd.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,20 @@ enum iommu_hw_info_type {
418418
IOMMU_HW_INFO_TYPE_INTEL_VTD,
419419
};
420420

421+
/**
422+
* enum iommufd_hw_capabilities
423+
* @IOMMU_HW_CAP_DIRTY_TRACKING: IOMMU hardware support for dirty tracking
424+
* If available, it means the following APIs
425+
* are supported:
426+
*
427+
* IOMMU_HWPT_GET_DIRTY_BITMAP
428+
* IOMMU_HWPT_SET_DIRTY_TRACKING
429+
*
430+
*/
431+
enum iommufd_hw_capabilities {
432+
IOMMU_HW_CAP_DIRTY_TRACKING = 1 << 0,
433+
};
434+
421435
/**
422436
* struct iommu_hw_info - ioctl(IOMMU_GET_HW_INFO)
423437
* @size: sizeof(struct iommu_hw_info)
@@ -429,6 +443,8 @@ enum iommu_hw_info_type {
429443
* the iommu type specific hardware information data
430444
* @out_data_type: Output the iommu hardware info type as defined in the enum
431445
* iommu_hw_info_type.
446+
* @out_capabilities: Output the generic iommu capability info type as defined
447+
* in the enum iommu_hw_capabilities.
432448
* @__reserved: Must be 0
433449
*
434450
* Query an iommu type specific hardware information data from an iommu behind
@@ -453,6 +469,7 @@ struct iommu_hw_info {
453469
__aligned_u64 data_uptr;
454470
__u32 out_data_type;
455471
__u32 __reserved;
472+
__aligned_u64 out_capabilities;
456473
};
457474
#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO)
458475

0 commit comments

Comments
 (0)