public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Yigit Oguz <yigitogu@amazon.de>
To: <joro@8bytes.org>, <will@kernel.org>, <robin.murphy@arm.com>,
	<baolu.lu@linux.intel.com>, <dwmw2@infradead.org>,
	<suravee.suthikulpanit@amd.com>
Cc: <jgg@ziepe.ca>, <nicolinc@nvidia.com>, <iommu@lists.linux.dev>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	"Lilit Janpoladyan" <lilitj@amazon.com>,
	Yigit Oguz <yigitogu@amazon.de>
Subject: [PATCH 1/3] iommu/arm-smmu-v3: Print PCI vendor:device ID in SMMU translation fault logs
Date: Wed, 6 May 2026 15:05:37 +0000	[thread overview]
Message-ID: <20260506150541.60467-2-yigitogu@amazon.de> (raw)
In-Reply-To: <20260506150541.60467-1-yigitogu@amazon.de>

From: Lilit Janpoladyan <lilitj@amazon.com>

For translation, address-size, access, and permission faults, look up
the pci_dev from the event and append the PCI vendor:device ID after
the device name, e.g.:

  event: F_TRANSLATION client: 0001:02:02.4 [1d0f:8061] sid: ...

For non-PCI devices or unassigned SIDs the output is unchanged.

Signed-off-by: Lilit Janpoladyan <lilitj@amazon.com>
Signed-off-by: Yigit Oguz <yigitogu@amazon.de>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 29 ++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 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 e8d7dbe495f0..ab1afa36965a 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2213,12 +2213,30 @@ static void arm_smmu_dump_raw_event(struct arm_smmu_device *smmu, u64 *raw,
 
 #define ARM_SMMU_EVT_KNOWN(e)	((e)->id < ARRAY_SIZE(event_str) && event_str[(e)->id])
 #define ARM_SMMU_LOG_EVT_STR(e) ARM_SMMU_EVT_KNOWN(e) ? event_str[(e)->id] : "UNKNOWN"
-#define ARM_SMMU_LOG_CLIENT(e)	(e)->dev ? dev_name((e)->dev) : "(unassigned sid)"
+
+/* "SSSS:BB:DD.F [VVVV:DDDD]\0" — 12 + 1 + 11 + 1 = 25; round to power of 2 */
+#define ARM_SMMU_CLIENT_LEN	32
+
+static const char *arm_smmu_fmt_client(struct arm_smmu_event *e, char *buf, size_t sz)
+{
+	struct pci_dev *p;
+
+	if (!e->dev)
+		return "(unassigned sid)";
+	if (!dev_is_pci(e->dev))
+		return dev_name(e->dev);
+
+	p = to_pci_dev(e->dev);
+	snprintf(buf, sz, "%s [%04x:%04x]", dev_name(e->dev), p->vendor, p->device);
+	return buf;
+}
 
 static void arm_smmu_dump_event(struct arm_smmu_device *smmu, u64 *raw,
 				struct arm_smmu_event *evt,
 				struct ratelimit_state *rs)
 {
+	char clientbuf[ARM_SMMU_CLIENT_LEN];
+
 	if (!__ratelimit(rs))
 		return;
 
@@ -2230,7 +2248,8 @@ static void arm_smmu_dump_event(struct arm_smmu_device *smmu, u64 *raw,
 	case EVT_ID_ACCESS_FAULT:
 	case EVT_ID_PERMISSION_FAULT:
 		dev_err(smmu->dev, "event: %s client: %s sid: %#x ssid: %#x iova: %#llx ipa: %#llx",
-			ARM_SMMU_LOG_EVT_STR(evt), ARM_SMMU_LOG_CLIENT(evt),
+			ARM_SMMU_LOG_EVT_STR(evt),
+			arm_smmu_fmt_client(evt, clientbuf, ARM_SMMU_CLIENT_LEN),
 			evt->sid, evt->ssid, evt->iova, evt->ipa);
 
 		dev_err(smmu->dev, "%s %s %s %s \"%s\"%s%s stag: %#x",
@@ -2247,14 +2266,16 @@ static void arm_smmu_dump_event(struct arm_smmu_device *smmu, u64 *raw,
 	case EVT_ID_CD_FETCH_FAULT:
 	case EVT_ID_VMS_FETCH_FAULT:
 		dev_err(smmu->dev, "event: %s client: %s sid: %#x ssid: %#x fetch_addr: %#llx",
-			ARM_SMMU_LOG_EVT_STR(evt), ARM_SMMU_LOG_CLIENT(evt),
+			ARM_SMMU_LOG_EVT_STR(evt),
+			arm_smmu_fmt_client(evt, clientbuf, ARM_SMMU_CLIENT_LEN),
 			evt->sid, evt->ssid, evt->fetch_addr);
 
 		break;
 
 	default:
 		dev_err(smmu->dev, "event: %s client: %s sid: %#x ssid: %#x",
-			ARM_SMMU_LOG_EVT_STR(evt), ARM_SMMU_LOG_CLIENT(evt),
+			ARM_SMMU_LOG_EVT_STR(evt),
+			arm_smmu_fmt_client(evt, clientbuf, ARM_SMMU_CLIENT_LEN),
 			evt->sid, evt->ssid);
 	}
 }
-- 
2.47.3




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597

  reply	other threads:[~2026-05-06 15:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 15:05 [PATCH 0/3] iommu: Add PCI vendor:device ID to IOMMU fault logs Yigit Oguz
2026-05-06 15:05 ` Yigit Oguz [this message]
2026-05-06 15:05 ` [PATCH 2/3] iommu/vt-d: Add PCI segment and vendor:device ID to DMAR " Yigit Oguz
2026-05-06 15:05 ` [PATCH 3/3] iommu/amd: Add vendor:device ID to AMD IOMMU event logs Yigit Oguz

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=20260506150541.60467-2-yigitogu@amazon.de \
    --to=yigitogu@amazon.de \
    --cc=baolu.lu@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=lilitj@amazon.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.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