From: Pranjal Shrivastava <praan@google.com>
To: Yigit Oguz <yigitogu@amazon.de>
Cc: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
baolu.lu@linux.intel.com, dwmw2@infradead.org,
suravee.suthikulpanit@amd.com, 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>
Subject: Re: [PATCH 3/3] iommu/amd: Add vendor:device ID to AMD IOMMU event logs
Date: Thu, 7 May 2026 19:52:49 +0000 [thread overview]
Message-ID: <afztkdvuWFn-42Pr@google.com> (raw)
In-Reply-To: <20260506150541.60467-4-yigitogu@amazon.de>
On Wed, May 06, 2026 at 03:05:39PM +0000, Yigit Oguz wrote:
> Add amd_iommu_devid_str() helper that formats PCI device identity as
> SSSS:BB:DD.F VVVV:DDDD by looking up the pci_dev via
> pci_get_domain_bus_and_slot. Falls back to SSSS:BB:DD.F when the
> device is not found.
>
> Before:
> AMD-Vi: Event logged [IO_PAGE_FAULT device=0000:41:00.0 domain=0x000a
> address=0xe0000000 flags=0x0020]
>
> After:
> AMD-Vi: Event logged [IO_PAGE_FAULT device=0000:41:00.0 8086:1533 domain=0x000a
> address=0xe0000000 flags=0x0020]
>
> Signed-off-by: Yigit Oguz <yigitogu@amazon.de>
> Signed-off-by: Lilit Janpoladyan <lilitj@amazon.com>
> Assisted-by: Claude:claude-4.6-opus
> ---
> drivers/iommu/amd/iommu.c | 94 ++++++++++++++++++++++++---------------
> 1 file changed, 58 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 01171361f9bc..441b4a7e85d5 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -779,11 +779,34 @@ static void dump_command(unsigned long phys_addr)
> pr_err("CMD[%d]: %08x\n", i, cmd->data[i]);
> }
>
> +#define AMD_IOMMU_DEVID_SIZE 48
> +
> +static void amd_iommu_devid_str(struct amd_iommu *iommu, u16 devid, char *buf,
> + size_t size)
> +{
> + struct pci_dev *pdev;
> +
> + pdev = pci_get_domain_bus_and_slot(iommu->pci_seg->id,
> + PCI_BUS_NUM(devid), devid & 0xff);
> + if (pdev) {
> + snprintf(buf, size, "%04x:%02x:%02x.%x %04x:%04x",
> + iommu->pci_seg->id, PCI_BUS_NUM(devid),
> + PCI_SLOT(devid), PCI_FUNC(devid),
> + pdev->vendor, pdev->device);
> + pci_dev_put(pdev);
From a quick glance it looks like we call this in bottom halves, which
looks fine.
> + } else {
> + snprintf(buf, size, "%04x:%02x:%02x.%x",
> + iommu->pci_seg->id, PCI_BUS_NUM(devid),
> + PCI_SLOT(devid), PCI_FUNC(devid));
> + }
> +}
> +
> static void amd_iommu_report_rmp_hw_error(struct amd_iommu *iommu, volatile u32 *event)
> {
> struct iommu_dev_data *dev_data = NULL;
> int devid, vmg_tag, flags;
> struct pci_dev *pdev;
> + char devid_str[AMD_IOMMU_DEVID_SIZE];
> u64 spa;
>
> devid = (event[0] >> EVENT_DEVID_SHIFT) & EVENT_DEVID_MASK;
> @@ -796,15 +819,16 @@ static void amd_iommu_report_rmp_hw_error(struct amd_iommu *iommu, volatile u32
> if (pdev)
> dev_data = dev_iommu_priv_get(&pdev->dev);
>
> + amd_iommu_devid_str(iommu, devid, devid_str, sizeof(devid_str));
Will this iterate the global pci dev list for EVERY event? I'm wondering
if we could improve that somehow?
[------------- >8 ---------------]
Thanks,
Praan
next prev parent reply other threads:[~2026-05-07 19:52 UTC|newest]
Thread overview: 8+ 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 ` [PATCH 1/3] iommu/arm-smmu-v3: Print PCI vendor:device ID in SMMU translation " Yigit Oguz
2026-05-07 17:01 ` Pranjal Shrivastava
2026-05-06 15:05 ` [PATCH 2/3] iommu/vt-d: Add PCI segment and vendor:device ID to DMAR " Yigit Oguz
2026-05-07 19:21 ` Pranjal Shrivastava
2026-05-06 15:05 ` [PATCH 3/3] iommu/amd: Add vendor:device ID to AMD IOMMU event logs Yigit Oguz
2026-05-07 19:52 ` Pranjal Shrivastava [this message]
2026-05-08 10:45 ` [PATCH 0/3] iommu: Add PCI vendor:device ID to IOMMU fault logs Robin Murphy
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=afztkdvuWFn-42Pr@google.com \
--to=praan@google.com \
--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 \
--cc=yigitogu@amazon.de \
/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