From: Pranjal Shrivastava <praan@google.com>
To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>
Cc: Mostafa Saleh <smostafa@google.com>,
Nicolin Chen <nicolinc@nvidia.com>,
iommu@lists.linux.dev, Pranjal Shrivastava <praan@google.com>
Subject: [PATCH v3 2/2] iommu/arm-smmu-v3: Adopt arm_smmu_event in handlers
Date: Sat, 28 Sep 2024 00:51:43 +0000 [thread overview]
Message-ID: <20240928005143.2378938-3-praan@google.com> (raw)
In-Reply-To: <20240928005143.2378938-1-praan@google.com>
Modify the event handler routines to leverage `struct arm_smmu_event`.
Log the event within the `arm_smmu_handle_evt` routine.
Signed-off-by: Pranjal Shrivastava <praan@google.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 35 ++++++++++-----------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 2b2949bd2d26..3c326f3a038a 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -1845,17 +1845,14 @@ static void arm_smmu_dump_event(struct arm_smmu_device *smmu,
}
/* IRQ and event handlers */
-static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
+static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, struct arm_smmu_event *event)
{
int ret = 0;
u32 perm = 0;
- struct arm_smmu_master *master;
- bool ssid_valid = evt[0] & EVTQ_0_SSV;
- u32 sid = FIELD_GET(EVTQ_0_SID, evt[0]);
struct iopf_fault fault_evt = { };
struct iommu_fault *flt = &fault_evt.fault;
- switch (FIELD_GET(EVTQ_0_ID, evt[0])) {
+ switch (event->id) {
case EVT_ID_TRANSLATION_FAULT:
case EVT_ID_ADDR_SIZE_FAULT:
case EVT_ID_ACCESS_FAULT:
@@ -1865,42 +1862,45 @@ static int arm_smmu_handle_evt(struct arm_smmu_device *smmu, u64 *evt)
return -EOPNOTSUPP;
}
- if (!(evt[1] & EVTQ_1_STALL))
+ if (!event->stall)
return -EOPNOTSUPP;
- if (evt[1] & EVTQ_1_RnW)
+ if (event->read)
perm |= IOMMU_FAULT_PERM_READ;
else
perm |= IOMMU_FAULT_PERM_WRITE;
- if (evt[1] & EVTQ_1_InD)
+ if (event->instruction)
perm |= IOMMU_FAULT_PERM_EXEC;
- if (evt[1] & EVTQ_1_PnU)
+ if (event->privileged)
perm |= IOMMU_FAULT_PERM_PRIV;
flt->type = IOMMU_FAULT_PAGE_REQ;
flt->prm = (struct iommu_fault_page_request) {
.flags = IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE,
- .grpid = FIELD_GET(EVTQ_1_STAG, evt[1]),
+ .grpid = FIELD_GET(EVTQ_1_STAG, event->raw[1]),
.perm = perm,
- .addr = FIELD_GET(EVTQ_2_ADDR, evt[2]),
+ .addr = event->iova,
};
- if (ssid_valid) {
+ if (event->ssid_valid) {
flt->prm.flags |= IOMMU_FAULT_PAGE_REQUEST_PASID_VALID;
- flt->prm.pasid = FIELD_GET(EVTQ_0_SSID, evt[0]);
+ flt->prm.pasid = event->ssid;
}
mutex_lock(&smmu->streams_mutex);
- master = arm_smmu_find_master(smmu, sid);
- if (!master) {
+ event->master = arm_smmu_find_master(smmu, event->sid);
+ if (!event->master) {
ret = -EINVAL;
+ event->master_name = "(unassigned sid)";
goto out_unlock;
}
- ret = iommu_report_device_fault(master->dev, &fault_evt);
+ ret = iommu_report_device_fault(event->master->dev, &fault_evt);
out_unlock:
+ if (ret)
+ arm_smmu_dump_event(smmu, event);
mutex_unlock(&smmu->streams_mutex);
return ret;
}
@@ -1949,11 +1949,10 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
while (!queue_remove_raw(q, evt)) {
arm_smmu_get_evt_info(smmu, evt, &event);
- ret = arm_smmu_handle_evt(smmu, evt);
+ ret = arm_smmu_handle_evt(smmu, &event);
if (!ret || !__ratelimit(&rs))
continue;
- arm_smmu_dump_event(smmu, &event);
cond_resched();
}
--
2.46.1.824.gd892dcdcdd-goog
next prev parent reply other threads:[~2024-09-28 0:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-28 0:51 [PATCH v3 0/2] Parse out event records Pranjal Shrivastava
2024-09-28 0:51 ` [PATCH v3 1/2] iommu/arm-smmu-v3: Print better events records Pranjal Shrivastava
2024-09-30 19:15 ` Nicolin Chen
2024-10-01 20:52 ` Pranjal Shrivastava
2024-10-01 23:04 ` Nicolin Chen
2024-10-02 13:57 ` Jason Gunthorpe
2024-10-02 16:55 ` Nicolin Chen
2024-10-02 17:10 ` Jason Gunthorpe
2024-10-02 17:22 ` Nicolin Chen
2024-10-03 21:26 ` Pranjal Shrivastava
2024-10-03 22:50 ` Nicolin Chen
2024-10-11 7:53 ` Pranjal Shrivastava
2024-10-11 10:02 ` Pranjal Shrivastava
2024-09-28 0:51 ` Pranjal Shrivastava [this message]
2024-09-30 19:32 ` [PATCH v3 2/2] iommu/arm-smmu-v3: Adopt arm_smmu_event in handlers Nicolin Chen
2024-10-01 21:02 ` Pranjal Shrivastava
2024-10-01 22:59 ` Nicolin Chen
2024-10-03 21:34 ` Pranjal Shrivastava
2024-10-03 22:53 ` Nicolin Chen
2024-10-11 7:55 ` Pranjal Shrivastava
2024-10-11 10:21 ` Robin Murphy
2024-10-11 10:45 ` Pranjal Shrivastava
2024-10-11 11:06 ` Pranjal Shrivastava
2024-10-11 12:59 ` Robin Murphy
2024-10-11 20:31 ` Pranjal Shrivastava
2024-10-15 18:34 ` Pranjal Shrivastava
2024-10-15 20:03 ` Robin Murphy
2024-10-17 8:06 ` Pranjal Shrivastava
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240928005143.2378938-3-praan@google.com \
--to=praan@google.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=smostafa@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox