Skip to content

Commit dc10ba2

Browse files
nicolincjgunthorpe
authored andcommitted
iommufd/fault: Remove iommufd_fault_domain_attach/detach/replace_dev()
There are new attach/detach/replace helpers in device.c taking care of both the attach_handle and the fault specific routines for iopf_enable/disable() and auto response. Clean up these redundant functions in the fault.c file. Link: https://patch.msgid.link/r/3ca94625e9d78270d9a715fa0809414fddd57e58.1738645017.git.nicolinc@nvidia.com Signed-off-by: Nicolin Chen <[email protected]> Reviewed-by: Yi Liu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent fb21b15 commit dc10ba2

File tree

2 files changed

+0
-128
lines changed

2 files changed

+0
-128
lines changed

drivers/iommu/iommufd/fault.c

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,6 @@ void iommufd_fault_iopf_disable(struct iommufd_device *idev)
6060
mutex_unlock(&idev->iopf_lock);
6161
}
6262

63-
static int __fault_domain_attach_dev(struct iommufd_hw_pagetable *hwpt,
64-
struct iommufd_device *idev)
65-
{
66-
struct iommufd_attach_handle *handle;
67-
int ret;
68-
69-
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
70-
if (!handle)
71-
return -ENOMEM;
72-
73-
handle->idev = idev;
74-
ret = iommu_attach_group_handle(hwpt->domain, idev->igroup->group,
75-
&handle->handle);
76-
if (ret)
77-
kfree(handle);
78-
79-
return ret;
80-
}
81-
82-
int iommufd_fault_domain_attach_dev(struct iommufd_hw_pagetable *hwpt,
83-
struct iommufd_device *idev)
84-
{
85-
int ret;
86-
87-
if (!hwpt->fault)
88-
return -EINVAL;
89-
90-
ret = iommufd_fault_iopf_enable(idev);
91-
if (ret)
92-
return ret;
93-
94-
ret = __fault_domain_attach_dev(hwpt, idev);
95-
if (ret)
96-
iommufd_fault_iopf_disable(idev);
97-
98-
return ret;
99-
}
100-
10163
void iommufd_auto_response_faults(struct iommufd_hw_pagetable *hwpt,
10264
struct iommufd_attach_handle *handle)
10365
{
@@ -135,88 +97,6 @@ void iommufd_auto_response_faults(struct iommufd_hw_pagetable *hwpt,
13597
mutex_unlock(&fault->mutex);
13698
}
13799

138-
static struct iommufd_attach_handle *
139-
iommufd_device_get_attach_handle(struct iommufd_device *idev)
140-
{
141-
struct iommu_attach_handle *handle;
142-
143-
handle = iommu_attach_handle_get(idev->igroup->group, IOMMU_NO_PASID, 0);
144-
if (IS_ERR(handle))
145-
return NULL;
146-
147-
return to_iommufd_handle(handle);
148-
}
149-
150-
void iommufd_fault_domain_detach_dev(struct iommufd_hw_pagetable *hwpt,
151-
struct iommufd_device *idev)
152-
{
153-
struct iommufd_attach_handle *handle;
154-
155-
handle = iommufd_device_get_attach_handle(idev);
156-
iommu_detach_group_handle(hwpt->domain, idev->igroup->group);
157-
iommufd_auto_response_faults(hwpt, handle);
158-
iommufd_fault_iopf_disable(idev);
159-
kfree(handle);
160-
}
161-
162-
static int __fault_domain_replace_dev(struct iommufd_device *idev,
163-
struct iommufd_hw_pagetable *hwpt,
164-
struct iommufd_hw_pagetable *old)
165-
{
166-
struct iommufd_attach_handle *handle, *curr = NULL;
167-
int ret;
168-
169-
if (old->fault)
170-
curr = iommufd_device_get_attach_handle(idev);
171-
172-
if (hwpt->fault) {
173-
handle = kzalloc(sizeof(*handle), GFP_KERNEL);
174-
if (!handle)
175-
return -ENOMEM;
176-
177-
handle->idev = idev;
178-
ret = iommu_replace_group_handle(idev->igroup->group,
179-
hwpt->domain, &handle->handle);
180-
} else {
181-
ret = iommu_replace_group_handle(idev->igroup->group,
182-
hwpt->domain, NULL);
183-
}
184-
185-
if (!ret && curr) {
186-
iommufd_auto_response_faults(old, curr);
187-
kfree(curr);
188-
}
189-
190-
return ret;
191-
}
192-
193-
int iommufd_fault_domain_replace_dev(struct iommufd_device *idev,
194-
struct iommufd_hw_pagetable *hwpt,
195-
struct iommufd_hw_pagetable *old)
196-
{
197-
bool iopf_off = !hwpt->fault && old->fault;
198-
bool iopf_on = hwpt->fault && !old->fault;
199-
int ret;
200-
201-
if (iopf_on) {
202-
ret = iommufd_fault_iopf_enable(idev);
203-
if (ret)
204-
return ret;
205-
}
206-
207-
ret = __fault_domain_replace_dev(idev, hwpt, old);
208-
if (ret) {
209-
if (iopf_on)
210-
iommufd_fault_iopf_disable(idev);
211-
return ret;
212-
}
213-
214-
if (iopf_off)
215-
iommufd_fault_iopf_disable(idev);
216-
217-
return 0;
218-
}
219-
220100
void iommufd_fault_destroy(struct iommufd_object *obj)
221101
{
222102
struct iommufd_fault *fault = container_of(obj, struct iommufd_fault, obj);

drivers/iommu/iommufd/iommufd_private.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,14 +496,6 @@ int iommufd_fault_alloc(struct iommufd_ucmd *ucmd);
496496
void iommufd_fault_destroy(struct iommufd_object *obj);
497497
int iommufd_fault_iopf_handler(struct iopf_group *group);
498498

499-
int iommufd_fault_domain_attach_dev(struct iommufd_hw_pagetable *hwpt,
500-
struct iommufd_device *idev);
501-
void iommufd_fault_domain_detach_dev(struct iommufd_hw_pagetable *hwpt,
502-
struct iommufd_device *idev);
503-
int iommufd_fault_domain_replace_dev(struct iommufd_device *idev,
504-
struct iommufd_hw_pagetable *hwpt,
505-
struct iommufd_hw_pagetable *old);
506-
507499
int iommufd_fault_iopf_enable(struct iommufd_device *idev);
508500
void iommufd_fault_iopf_disable(struct iommufd_device *idev);
509501
void iommufd_auto_response_faults(struct iommufd_hw_pagetable *hwpt,

0 commit comments

Comments
 (0)