History

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.

Lu Baolu committed 3 years ago

Commit 60fedb21 parent 92766e12 files · +14 −0Browse files

Unified · Split

2 files
  1. include/linux/iommu.h +5 −0
  2. include/uapi/linux/iommufd.h +9 −0
include/linux/iommu.h+5−0
@@ -228,6 +228,10 @@ struct iommu_iotlb_gather { · 227 unmodified lines
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 { · 23 unmodified lines
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+9−0
@@ -370,4 +370,13 @@ struct iommu_hwpt_alloc { · 369 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t