]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu: Turn fault_data to iommufd private pointer
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 20 Feb 2025 01:31:40 +0000 (17:31 -0800)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 21 Feb 2025 14:49:05 +0000 (10:49 -0400)
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 <nicolinc@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/fault.c
drivers/iommu/iommufd/hw_pagetable.c
include/linux/iommu.h

index 931a3fbe6e32cadc7d0886be41a7749f51c4da60..c48d72c9668ca370223ae64a39630161ad43d3b8 100644 (file)
@@ -329,7 +329,7 @@ int iommufd_fault_iopf_handler(struct iopf_group *group)
        struct iommufd_hw_pagetable *hwpt;
        struct iommufd_fault *fault;
 
-       hwpt = group->attach_handle->domain->fault_data;
+       hwpt = group->attach_handle->domain->iommufd_hwpt;
        fault = hwpt->fault;
 
        spin_lock(&fault->lock);
index 598be26a14e28e93fe86934e16c341dc48d60793..2641d50f46cf17cbc659ee8b632d77ad9e01eb2a 100644 (file)
@@ -406,10 +406,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd)
                }
                hwpt->fault = fault;
                hwpt->domain->iopf_handler = iommufd_fault_iopf_handler;
-               hwpt->domain->fault_data = hwpt;
                refcount_inc(&fault->obj.users);
                iommufd_put_object(ucmd->ictx, &fault->obj);
        }
+       hwpt->domain->iommufd_hwpt = hwpt;
 
        cmd->out_hwpt_id = hwpt->obj.id;
        rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
index 761c5e186de964b417c0693d770ae6374be35bd3..e93d2e918599f837529e8864873835ff7dca2b22 100644 (file)
@@ -224,8 +224,10 @@ struct iommu_domain {
                      phys_addr_t msi_addr);
 #endif
 
-       void *fault_data;
-       union {
+       union { /* Pointer usable by owner of the domain */
+               struct iommufd_hw_pagetable *iommufd_hwpt; /* iommufd */
+       };
+       union { /* Fault handler */
                struct {
                        iommu_fault_handler_t handler;
                        void *handler_token;