Linux IOMMU Development
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Pranjal Shrivastava <praan@google.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	"Robin Murphy" <robin.murphy@arm.com>,
	Mostafa Saleh <smostafa@google.com>, <iommu@lists.linux.dev>,
	Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH v4 2/3] iommu/arm-smmu-v3: Log better event records
Date: Fri, 18 Oct 2024 19:06:49 -0700	[thread overview]
Message-ID: <ZxMUOfH7GoY71FxD@Asurada-Nvidia> (raw)
In-Reply-To: <20241018180022.807928-3-praan@google.com>

On Fri, Oct 18, 2024 at 06:00:21PM +0000, Pranjal Shrivastava wrote:
> +static void arm_smmu_dump_event(struct arm_smmu_event *evt, struct ratelimit_state *rs)
> +{
> +       struct arm_smmu_device *smmu = evt->smmu;
> +       char title[100] = {0};
> +       char mastr[100] = {0};
> +       char addrs[100] = {0};
> +       char flags[100] = {0};
> +       char other[50] = {0};
> +
> +       if (!__ratelimit(rs))
> +               return;
> +
> +       snprintf(title, 100, "Unexpected event received: %s\n", event_str[evt->id]);
> +       snprintf(mastr, 100, "\tmaster: %s sid: 0x%08x.0x%05x\n",
> +                evt->master_name, evt->sid, evt->ssid);

Likely I mentioned in the cover-letter, maybe "sid.ssid:"?

> +       switch (evt->id) {
> +       case EVT_ID_TRANSLATION_FAULT:
> +       case EVT_ID_ADDR_SIZE_FAULT:
> +       case EVT_ID_ACCESS_FAULT:
> +       case EVT_ID_PERMISSION_FAULT:
> +               snprintf(addrs, 100, "\tiova = %#llx ipa = %#llx\n", evt->iova, evt->ipa);
> +               snprintf(other, 50, "\tSTAG = %#x Stall = %#x\n", evt->stag, evt->stall);
> +               snprintf(flags, 100, "\t%s%s%s%s%s%s\n",
> +                        evt->privileged ? "Priv | " : "Unpriv | ",
> +                        evt->instruction ? "Inst | " : "Data | ",
> +                        evt->read ? "Read | " : "Write | ",
> +                        evt->s2 ? "S2 | " : "S1 | ", event_class_str[evt->class],
> +                        evt->ttrnw_valid ? (evt->ttrnw ? "| TTD Read" : "| TTD Write") : "");

Should the last one be "TTD Read |" : "TTD Write|"?
Otherwise, it would be "S2 || TTD Read" combined.

>  static void arm_smmu_get_event_from_raw(struct arm_smmu_device *smmu,
>                                         struct arm_smmu_event *event)
>  {
> +       struct arm_smmu_master *master;
> +
>         /* Pick out the good stuff */
>         event->id = FIELD_GET(EVTQ_0_ID, event->raw[0]);
>         event->sid = FIELD_GET(EVTQ_0_SID, event->raw[0]);
> @@ -1833,12 +1917,24 @@ static void arm_smmu_get_event_from_raw(struct arm_smmu_device *smmu,
>         event->class = FIELD_GET(EVTQ_1_CLASS, event->raw[1]);
>         event->iova = FIELD_GET(EVTQ_2_ADDR, event->raw[2]);
>         event->ipa = FIELD_GET(EVTQ_3_IPA, event->raw[3]);
> +       event->ttrnw = FIELD_GET(EVTQ_1_TT_READ, event->raw[1]);
> +       event->ttrnw_valid = false;
>         event->smmu = smmu;
> +       event->dev = NULL;
> +
> +       if (event->id == EVT_ID_PERMISSION_FAULT)
> +               event->ttrnw_valid = (event->class == EVTQ_1_CLASS_TT);
> +
> +       mutex_lock(&smmu->streams_mutex);
> +       master = arm_smmu_find_master(smmu, event->sid);
> +       if (master)
> +               event->dev = get_device(master->dev);

Here, get_device is called upon a valid master...

>  static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
>  {
> -       int i, ret;
>         struct arm_smmu_event evt;
>         struct arm_smmu_device *smmu = dev;
>         struct arm_smmu_queue *q = &smmu->evtq.q;
> @@ -1850,15 +1946,10 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
>                 while (!queue_remove_raw(q, evt.raw)) {
> 
>                         arm_smmu_get_event_from_raw(smmu, &evt);
> -                       ret = arm_smmu_handle_evt(&evt);
> -                       if (!ret || !__ratelimit(&rs))
> -                               continue;
> -
> -                       dev_info(smmu->dev, "event 0x%02x received:\n", evt.id);
> -                       for (i = 0; i < EVTQ_ENT_DWORDS; ++i)
> -                               dev_info(smmu->dev, "\t0x%016llx\n",
> -                                       (unsigned long long)evt.raw[i]);
> +                       if (arm_smmu_handle_evt(&evt))
> +                               arm_smmu_dump_event(&evt, &rs);
> 
> +                       put_device(evt.dev);

then, here it puts unconditionally.

Maybe we do need a memset(0) to the event, then here
			if (evet.dev)
				put_device(evt.dev);

Thanks
Nicolin

  reply	other threads:[~2024-10-19  2:07 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 18:00 [PATCH v4 0/3] iommu/arm-smmu-v3: Parse out event records Pranjal Shrivastava
2024-10-18 18:00 ` [PATCH v4 1/3] iommu/arm-smmu-v3: Introduce struct arm_smmu_event Pranjal Shrivastava
2024-10-19  1:56   ` Nicolin Chen
2024-10-21  6:20     ` Pranjal Shrivastava
2024-10-24 13:11   ` Will Deacon
2024-10-24 14:20     ` Pranjal Shrivastava
2024-10-24 17:02     ` Pranjal Shrivastava
2024-10-24 17:03       ` Jason Gunthorpe
2024-10-24 17:37         ` Pranjal Shrivastava
2024-10-28 12:23           ` Jason Gunthorpe
2024-10-28 14:46             ` Pranjal Shrivastava
2024-11-04 17:23       ` Daniel Mentz
2024-11-04 18:16         ` Pranjal Shrivastava
2024-11-04 18:19           ` Pranjal Shrivastava
2024-11-01 14:41   ` Robin Murphy
2024-11-01 15:08     ` Pranjal Shrivastava
2024-11-04  5:25       ` Daniel Mentz
2024-11-04  8:31         ` Pranjal Shrivastava
2024-11-07  0:10           ` Daniel Mentz
2024-11-07 14:33             ` Pranjal Shrivastava
2024-11-07  0:16   ` Daniel Mentz
2024-11-07 14:57     ` Pranjal Shrivastava
2024-11-11 22:20       ` Daniel Mentz
2024-11-12  0:52         ` Pranjal Shrivastava
2024-11-12  4:01           ` Daniel Mentz
2024-11-12  8:12             ` Pranjal Shrivastava
2024-10-18 18:00 ` [PATCH v4 2/3] iommu/arm-smmu-v3: Log better event records Pranjal Shrivastava
2024-10-19  2:06   ` Nicolin Chen [this message]
2024-10-19  4:51     ` Nicolin Chen
2024-10-21  6:29       ` Pranjal Shrivastava
2024-10-21  6:26     ` Pranjal Shrivastava
2024-10-21 22:53       ` Nicolin Chen
2024-10-24 13:15   ` Will Deacon
2024-10-24 14:14     ` Pranjal Shrivastava
2024-10-29 18:53       ` Will Deacon
2024-10-29 19:59         ` Pranjal Shrivastava
2024-10-24 19:00     ` Nicolin Chen
2024-10-29 18:49       ` Will Deacon
2024-11-01 15:05   ` Robin Murphy
2024-11-01 16:06     ` Pranjal Shrivastava
2024-11-04  6:36   ` Daniel Mentz
2024-11-04 10:51     ` Pranjal Shrivastava
2024-10-18 18:00 ` [PATCH v4 3/3] iommu/arm-smmu-v3: Avoid redundant master lookup in events Pranjal Shrivastava
2024-10-19  2:08   ` Nicolin Chen
2024-10-19  1:45 ` [PATCH v4 0/3] iommu/arm-smmu-v3: Parse out event records Nicolin Chen
2024-10-21  6:33   ` Pranjal Shrivastava
2024-10-21 22:51     ` Nicolin Chen

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=ZxMUOfH7GoY71FxD@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=praan@google.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