Skip to content

Commit 748706d

Browse files
nicolincjgunthorpe
authored andcommitted
iommu: Turn fault_data to iommufd private pointer
A "fault_data" was added exclusively for the iommufd_fault_iopf_handler() used by IOPF/PRI use cases, along with the attach_handle. Now, the iommufd version of the sw_msi function will reuse the attach_handle and fault_data for a non-fault case. Rename "fault_data" to "iommufd_hwpt" so as not to confine it to a "fault" case. Move it into a union to be the iommufd private pointer. A following patch will move the iova_cookie to the union for dma-iommu too after the iommufd_sw_msi implementation is added. Since we have two unions now, add some simple comments for readability. Link: https://patch.msgid.link/r/ee5039503f28a16590916e9eef28b917e2d1607a.1740014950.git.nicolinc@nvidia.com Signed-off-by: Nicolin Chen <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 96093fe commit 748706d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

drivers/iommu/iommufd/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ int iommufd_fault_iopf_handler(struct iopf_group *group)
329329
struct iommufd_hw_pagetable *hwpt;
330330
struct iommufd_fault *fault;
331331

332-
hwpt = group->attach_handle->domain->fault_data;
332+
hwpt = group->attach_handle->domain->iommufd_hwpt;
333333
fault = hwpt->fault;
334334

335335
spin_lock(&fault->lock);

drivers/iommu/iommufd/hw_pagetable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
406406
}
407407
hwpt->fault = fault;
408408
hwpt->domain->iopf_handler = iommufd_fault_iopf_handler;
409-
hwpt->domain->fault_data = hwpt;
410409
refcount_inc(&fault->obj.users);
411410
iommufd_put_object(ucmd->ictx, &fault->obj);
412411
}
412+
hwpt->domain->iommufd_hwpt = hwpt;
413413

414414
cmd->out_hwpt_id = hwpt->obj.id;
415415
rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));

include/linux/iommu.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ struct iommu_domain {
224224
phys_addr_t msi_addr);
225225
#endif
226226

227-
void *fault_data;
228-
union {
227+
union { /* Pointer usable by owner of the domain */
228+
struct iommufd_hw_pagetable *iommufd_hwpt; /* iommufd */
229+
};
230+
union { /* Fault handler */
229231
struct {
230232
iommu_fault_handler_t handler;
231233
void *handler_token;

0 commit comments

Comments
 (0)