Skip to content

Commit 3dfa64a

Browse files
LuBaolujoergroedel
authored andcommitted
iommu: Make iommu_report_device_fault() return void
As the iommu_report_device_fault() has been converted to auto-respond a page fault if it fails to enqueue it, there's no need to return a code in any case. Make it return void. Suggested-by: Jason Gunthorpe <[email protected]> Signed-off-by: Lu Baolu <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent b554e39 commit 3dfa64a

File tree

4 files changed

+19
-34
lines changed

4 files changed

+19
-34
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ arm_smmu_find_master(struct arm_smmu_device *smmu, u32 sid)
14551455
/* IRQ and event handlers */
14561456
static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
14571457
{
1458-
int ret;
1458+
int ret = 0;
14591459
u32 perm = 0;
14601460
struct arm_smmu_master *master;
14611461
bool ssid_valid = evt[0] & EVTQ_0_SSV;
@@ -1511,7 +1511,7 @@ static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
15111511
goto out_unlock;
15121512
}
15131513

1514-
ret = iommu_report_device_fault(master->dev, &fault_evt);
1514+
iommu_report_device_fault(master->dev, &fault_evt);
15151515
out_unlock:
15161516
mutex_unlock(&smmu->streams_mutex);
15171517
return ret;

drivers/iommu/intel/svm.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,11 @@ static int prq_to_iommu_prot(struct page_req_dsc *req)
561561
return prot;
562562
}
563563

564-
static int intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
565-
struct page_req_dsc *desc)
564+
static void intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
565+
struct page_req_dsc *desc)
566566
{
567567
struct iopf_fault event = { };
568568

569-
if (!dev || !dev_is_pci(dev))
570-
return -ENODEV;
571-
572569
/* Fill in event data for device specific processing */
573570
event.fault.type = IOMMU_FAULT_PAGE_REQ;
574571
event.fault.prm.addr = (u64)desc->addr << VTD_PAGE_SHIFT;
@@ -601,7 +598,7 @@ static int intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
601598
event.fault.prm.private_data[0] = ktime_to_ns(ktime_get());
602599
}
603600

604-
return iommu_report_device_fault(dev, &event);
601+
iommu_report_device_fault(dev, &event);
605602
}
606603

607604
static void handle_bad_prq_event(struct intel_iommu *iommu,
@@ -704,12 +701,10 @@ static irqreturn_t prq_event_thread(int irq, void *d)
704701
if (!pdev)
705702
goto bad_req;
706703

707-
if (intel_svm_prq_report(iommu, &pdev->dev, req))
708-
handle_bad_prq_event(iommu, req, QI_RESP_INVALID);
709-
else
710-
trace_prq_report(iommu, &pdev->dev, req->qw_0, req->qw_1,
711-
req->priv_data[0], req->priv_data[1],
712-
iommu->prq_seq_number++);
704+
intel_svm_prq_report(iommu, &pdev->dev, req);
705+
trace_prq_report(iommu, &pdev->dev, req->qw_0, req->qw_1,
706+
req->priv_data[0], req->priv_data[1],
707+
iommu->prq_seq_number++);
713708
pci_dev_put(pdev);
714709
prq_advance:
715710
head = (head + sizeof(*req)) & PRQ_RING_MASK;

drivers/iommu/io-pgfault.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,26 +176,22 @@ static struct iopf_group *iopf_group_alloc(struct iommu_fault_param *iopf_param,
176176
* freed after the device has stopped generating page faults (or the iommu
177177
* hardware has been set to block the page faults) and the pending page faults
178178
* have been flushed.
179-
*
180-
* Return: 0 on success and <0 on error.
181179
*/
182-
int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
180+
void iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
183181
{
184182
struct iommu_fault *fault = &evt->fault;
185183
struct iommu_fault_param *iopf_param;
186184
struct iopf_group abort_group = {};
187185
struct iopf_group *group;
188-
int ret;
189186

190187
iopf_param = iopf_get_dev_fault_param(dev);
191188
if (WARN_ON(!iopf_param))
192-
return -ENODEV;
189+
return;
193190

194191
if (!(fault->prm.flags & IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE)) {
195-
ret = report_partial_fault(iopf_param, fault);
192+
report_partial_fault(iopf_param, fault);
196193
iopf_put_dev_fault_param(iopf_param);
197194
/* A request that is not the last does not need to be ack'd */
198-
return ret;
199195
}
200196

201197
/*
@@ -207,33 +203,28 @@ int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
207203
* leaving, otherwise partial faults will be stuck.
208204
*/
209205
group = iopf_group_alloc(iopf_param, evt, &abort_group);
210-
if (group == &abort_group) {
211-
ret = -ENOMEM;
206+
if (group == &abort_group)
212207
goto err_abort;
213-
}
214208

215209
group->domain = get_domain_for_iopf(dev, fault);
216-
if (!group->domain) {
217-
ret = -EINVAL;
210+
if (!group->domain)
218211
goto err_abort;
219-
}
220212

221213
/*
222214
* On success iopf_handler must call iopf_group_response() and
223215
* iopf_free_group()
224216
*/
225-
ret = group->domain->iopf_handler(group);
226-
if (ret)
217+
if (group->domain->iopf_handler(group))
227218
goto err_abort;
228-
return 0;
219+
220+
return;
229221

230222
err_abort:
231223
iopf_group_response(group, IOMMU_PAGE_RESP_FAILURE);
232224
if (group == &abort_group)
233225
__iopf_free_group(group);
234226
else
235227
iopf_free_group(group);
236-
return ret;
237228
}
238229
EXPORT_SYMBOL_GPL(iommu_report_device_fault);
239230

include/linux/iommu.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ struct iopf_queue *iopf_queue_alloc(const char *name);
15451545
void iopf_queue_free(struct iopf_queue *queue);
15461546
int iopf_queue_discard_partial(struct iopf_queue *queue);
15471547
void iopf_free_group(struct iopf_group *group);
1548-
int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt);
1548+
void iommu_report_device_fault(struct device *dev, struct iopf_fault *evt);
15491549
void iopf_group_response(struct iopf_group *group,
15501550
enum iommu_page_response_code status);
15511551
#else
@@ -1583,10 +1583,9 @@ static inline void iopf_free_group(struct iopf_group *group)
15831583
{
15841584
}
15851585

1586-
static inline int
1586+
static inline void
15871587
iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
15881588
{
1589-
return -ENODEV;
15901589
}
15911590

15921591
static inline void iopf_group_response(struct iopf_group *group,

0 commit comments

Comments
 (0)