Skip to content

Commit 3f02a9d

Browse files
LuBaolujoergroedel
authored andcommitted
iommu: Merge iommu_fault_event and iopf_fault
The iommu_fault_event and iopf_fault data structures store the same information about an iopf fault. They are also used in the same way. Merge these two data structures into a single one to make the code more concise and easier to maintain. Signed-off-by: Lu Baolu <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Yi Liu <[email protected]> Tested-by: Yan Zhao <[email protected]> Tested-by: Longfang Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 1ff25d7 commit 3f02a9d

File tree

6 files changed

+17
-34
lines changed

6 files changed

+17
-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
@@ -922,7 +922,7 @@ static int arm_smmu_cmdq_batch_submit(struct arm_smmu_device *smmu,
922922
}
923923

924924
static int arm_smmu_page_response(struct device *dev,
925-
struct iommu_fault_event *unused,
925+
struct iopf_fault *unused,
926926
struct iommu_page_response *resp)
927927
{
928928
struct arm_smmu_cmdq_ent cmd = {0};
@@ -1465,7 +1465,7 @@ static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
14651465
struct arm_smmu_master *master;
14661466
bool ssid_valid = evt[0] & EVTQ_0_SSV;
14671467
u32 sid = FIELD_GET(EVTQ_0_SID, evt[0]);
1468-
struct iommu_fault_event fault_evt = { };
1468+
struct iopf_fault fault_evt = { };
14691469
struct iommu_fault *flt = &fault_evt.fault;
14701470

14711471
switch (FIELD_GET(EVTQ_0_ID, evt[0])) {

drivers/iommu/intel/iommu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ struct iommu_domain *intel_nested_domain_alloc(struct iommu_domain *parent,
10791079
void intel_svm_check(struct intel_iommu *iommu);
10801080
int intel_svm_enable_prq(struct intel_iommu *iommu);
10811081
int intel_svm_finish_prq(struct intel_iommu *iommu);
1082-
int intel_svm_page_response(struct device *dev, struct iommu_fault_event *evt,
1082+
int intel_svm_page_response(struct device *dev, struct iopf_fault *evt,
10831083
struct iommu_page_response *msg);
10841084
struct iommu_domain *intel_svm_domain_alloc(void);
10851085
void intel_svm_remove_dev_pasid(struct device *dev, ioasid_t pasid);

drivers/iommu/intel/svm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,13 +565,12 @@ static int prq_to_iommu_prot(struct page_req_dsc *req)
565565
static int intel_svm_prq_report(struct intel_iommu *iommu, struct device *dev,
566566
struct page_req_dsc *desc)
567567
{
568-
struct iommu_fault_event event;
568+
struct iopf_fault event = { };
569569

570570
if (!dev || !dev_is_pci(dev))
571571
return -ENODEV;
572572

573573
/* Fill in event data for device specific processing */
574-
memset(&event, 0, sizeof(struct iommu_fault_event));
575574
event.fault.type = IOMMU_FAULT_PAGE_REQ;
576575
event.fault.prm.addr = (u64)desc->addr << VTD_PAGE_SHIFT;
577576
event.fault.prm.pasid = desc->pasid;
@@ -743,7 +742,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
743742
}
744743

745744
int intel_svm_page_response(struct device *dev,
746-
struct iommu_fault_event *evt,
745+
struct iopf_fault *evt,
747746
struct iommu_page_response *msg)
748747
{
749748
struct device_domain_info *info = dev_iommu_priv_get(dev);

drivers/iommu/io-pgfault.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ struct iopf_queue {
2525
struct mutex lock;
2626
};
2727

28-
struct iopf_fault {
29-
struct iommu_fault fault;
30-
struct list_head list;
31-
};
32-
3328
struct iopf_group {
3429
struct iopf_fault last_fault;
3530
struct list_head faults;

drivers/iommu/iommu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,10 +1341,10 @@ EXPORT_SYMBOL_GPL(iommu_group_put);
13411341
*
13421342
* Return 0 on success, or an error.
13431343
*/
1344-
int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt)
1344+
int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
13451345
{
13461346
struct dev_iommu *param = dev->iommu;
1347-
struct iommu_fault_event *evt_pending = NULL;
1347+
struct iopf_fault *evt_pending = NULL;
13481348
struct iommu_fault_param *fparam;
13491349
int ret = 0;
13501350

@@ -1357,7 +1357,7 @@ int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt)
13571357

13581358
if (evt->fault.type == IOMMU_FAULT_PAGE_REQ &&
13591359
(evt->fault.prm.flags & IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE)) {
1360-
evt_pending = kmemdup(evt, sizeof(struct iommu_fault_event),
1360+
evt_pending = kmemdup(evt, sizeof(struct iopf_fault),
13611361
GFP_KERNEL);
13621362
if (!evt_pending) {
13631363
ret = -ENOMEM;
@@ -1386,7 +1386,7 @@ int iommu_page_response(struct device *dev,
13861386
{
13871387
bool needs_pasid;
13881388
int ret = -EINVAL;
1389-
struct iommu_fault_event *evt;
1389+
struct iopf_fault *evt;
13901390
struct iommu_fault_page_request *prm;
13911391
struct dev_iommu *param = dev->iommu;
13921392
const struct iommu_ops *ops = dev_iommu_ops(dev);

include/linux/iommu.h

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct iommu_domain_ops;
4040
struct iommu_dirty_ops;
4141
struct notifier_block;
4242
struct iommu_sva;
43-
struct iommu_fault_event;
4443
struct iommu_dma_cookie;
4544
struct iopf_queue;
4645

@@ -121,6 +120,11 @@ struct iommu_page_response {
121120
u32 code;
122121
};
123122

123+
struct iopf_fault {
124+
struct iommu_fault fault;
125+
/* node for pending lists */
126+
struct list_head list;
127+
};
124128

125129
/* iommu fault flags */
126130
#define IOMMU_FAULT_READ 0x0
@@ -553,7 +557,7 @@ struct iommu_ops {
553557
int (*dev_disable_feat)(struct device *dev, enum iommu_dev_features f);
554558

555559
int (*page_response)(struct device *dev,
556-
struct iommu_fault_event *evt,
560+
struct iopf_fault *evt,
557561
struct iommu_page_response *msg);
558562

559563
int (*def_domain_type)(struct device *dev);
@@ -654,20 +658,6 @@ struct iommu_device {
654658
u32 max_pasids;
655659
};
656660

657-
/**
658-
* struct iommu_fault_event - Generic fault event
659-
*
660-
* Can represent recoverable faults such as a page requests or
661-
* unrecoverable faults such as DMA or IRQ remapping faults.
662-
*
663-
* @fault: fault descriptor
664-
* @list: pending fault event list, used for tracking responses
665-
*/
666-
struct iommu_fault_event {
667-
struct iommu_fault fault;
668-
struct list_head list;
669-
};
670-
671661
/**
672662
* struct iommu_fault_param - per-device IOMMU fault data
673663
* @lock: protect pending faults list
@@ -802,8 +792,7 @@ extern struct iommu_group *iommu_group_get(struct device *dev);
802792
extern struct iommu_group *iommu_group_ref_get(struct iommu_group *group);
803793
extern void iommu_group_put(struct iommu_group *group);
804794

805-
extern int iommu_report_device_fault(struct device *dev,
806-
struct iommu_fault_event *evt);
795+
extern int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt);
807796
extern int iommu_page_response(struct device *dev,
808797
struct iommu_page_response *msg);
809798

@@ -1213,7 +1202,7 @@ static inline void iommu_group_put(struct iommu_group *group)
12131202
}
12141203

12151204
static inline
1216-
int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt)
1205+
int iommu_report_device_fault(struct device *dev, struct iopf_fault *evt)
12171206
{
12181207
return -ENODEV;
12191208
}

0 commit comments

Comments
 (0)