From: Pranjal Shrivastava <praan@google.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: Nicolin Chen <nicolinc@nvidia.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Mostafa Saleh <smostafa@google.com>,
iommu@lists.linux.dev
Subject: Re: [PATCH v3 2/2] iommu/arm-smmu-v3: Adopt arm_smmu_event in handlers
Date: Fri, 11 Oct 2024 11:06:53 +0000 [thread overview]
Message-ID: <ZwkGzWSUIpuhHozl@google.com> (raw)
In-Reply-To: <ZwkB4OTUChexImZd@google.com>
On Fri, Oct 11, 2024 at 10:45:52AM +0000, Pranjal Shrivastava wrote:
> On Fri, Oct 11, 2024 at 11:21:48AM +0100, Robin Murphy wrote:
> > On 2024-10-11 8:55 am, Pranjal Shrivastava wrote:
> > > On Thu, Oct 03, 2024 at 03:53:15PM -0700, Nicolin Chen wrote:
> > > > On Thu, Oct 03, 2024 at 09:34:35PM +0000, Pranjal Shrivastava wrote:
> > > > > > The master and master_name are not that necessary to be in the
> > > > > > arm_smmu_event. I would keep both of them as local variables in
> > > > > > arm_smmu_handle_evt and pass master_name in to dump().
> > > > >
> > > > > Hmm, right or maybe ONLY have the master_name in arm_smmu_event?
> > > >
> > > > Just move both out of arm_smmu_event. Keep the master_name as a
> > > > local variable like the "master". You'd just need to pass it in
> > > > to the dump(). They both are in that same handle_evt().
> > > >
> > >
> > > Ack.
> > >
> > > > > > > Also, shall we rename it to `arm_smmu_read_evt_info` ?
> > > > > >
> > > > > > I'd probably use arm_smmu_event_get_from_raw()? Trying to high-
> > > > > > light struct arm_smmu_event v.s. u64 evt[EVTQ_ENT_DWORDS]. Yet,
> > > > > > no strong feeling about that.
> > > > > >
> > > > >
> > > > > Ack. How about `read_arm_smmu_event` :)
> > > > > Unless, we wanna follow the arm_smmu_<func> convention?
> > > >
> > > > I think it'd be nicer if we do.
> > > >
> > >
> > > Ack. `arm_smmu_get_evt_from_raw` it is!
> >
> > FWIW that sounds needlessly overcomplicated to me - the "raw" event array
> > should be a member of arm_smmu_event itself, since it seems silly to have
> > them separate with one pointing to the other when they have the exact same
> > scope and lifetime anyway. There still shouldn't need to be more than a
> > single logical step to process an evtq record into a finished
> > arm_smmu_event, just that that processing is now going to go a bit further
> > than simply le64_to_cpu().
>
> Hmm, are you suggesting something like queue_remove_raw(q, event->raw)?
> OR do you mean we should have our own queue_parse_evt(q, &event) that
> parses out the raw event into an `arm_smmu_event` record eliminating the
> need for the `arm_smmu_read_evt_info` altogether?
>
> Because we'd still need to store the raw event anyway since we're still
> logging the raw event.
>
> I think we can go with the former, i.e. queue_remove_raw(q, event->raw)
> and then use ``arm_smmu_read_evt_info` to populate other `event` fields
Based on your comment, I was thinking like the attached sample code.
LMK if you were referring to something like that?
>
> > Thanks,
> > Robin.
>
Thanks,
Pranjal
--------------------------------------------------------------------------
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 0636b81eef79..5845793c0a41 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -1929,6 +1929,35 @@ static void arm_smmu_get_event_from_raw(struct arm_smmu_device *smmu, u64 *evt,
event->smmu = smmu;
}
+static int queue_remove_raw(struct arm_smmu_queue *q
+ struct arm_smmu_event *event)
+{
+ int ret;
+
+ ret = queue_remove_raw(q,event->raw);
+ if (ret)
+ return ret;
+
+ /* Parse out the event fields */
+ event->id = FIELD_GET(EVTQ_0_ID, evt[0]);
+ event->sid = FIELD_GET(EVTQ_0_SID, evt[0]);
+ event->ssid_valid = evt[0] & EVTQ_0_SSV;
+ event->ssid = event->ssid_valid ? FIELD_GET(EVTQ_0_SSID, evt[0]) : IOMMU_NO_PASID;
+ event->class = FIELD_GET(EVTQ_1_CLASS, evt[1]);
+ event->iova = FIELD_GET(EVTQ_2_ADDR, evt[2]);
+ event->ipa = FIELD_GET(EVTQ_3_IPA, evt[3]);
+ event->privileged = FIELD_GET(EVTQ_1_PnU, evt[1]);
+ event->instruction = FIELD_GET(EVTQ_1_InD, evt[1]);
+ event->s2 = FIELD_GET(EVTQ_1_S2, evt[1]);
+ event->read = FIELD_GET(EVTQ_1_RnW, evt[1]);
+ event->stag = FIELD_GET(EVTQ_1_STAG, evt[1]);
+ event->stall = evt[1] & EVTQ_1_STALL;
+ event->raw = evt;
+ event->smmu = smmu;
+
+ return 0;
+}
+
static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
{
int ret;
@@ -1941,9 +1970,8 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
u64 evt[EVTQ_ENT_DWORDS];
do {
- while (!queue_remove_raw(q, evt)) {
+ while (!queue_remove_evt(q, &event)) {
- arm_smmu_get_event_from_raw(smmu, evt, &event);
ret = arm_smmu_handle_evt(&event);
if (!ret || !__ratelimit(&rs))
continue;
next prev parent reply other threads:[~2024-10-11 11:07 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 ` [PATCH v3 2/2] iommu/arm-smmu-v3: Adopt arm_smmu_event in handlers Pranjal Shrivastava
2024-09-30 19:32 ` 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 [this message]
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=ZwkGzWSUIpuhHozl@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