Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Oct 2024 22:30:51 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 7896b03fff4d - main - iommu_get_requester(): do not panic if asked about non-pci device
Message-ID:  <202410132230.49DMUpuW040114@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=7896b03fff4d9c2e9c35ecf1dce2e0d672467a5a

commit 7896b03fff4d9c2e9c35ecf1dce2e0d672467a5a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-13 10:04:32 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-13 22:30:26 +0000

    iommu_get_requester(): do not panic if asked about non-pci device
    
    For now, return zero rid and the device itself.  Add a comment noting
    that eventually ACPI HID can be used to calculate rid for some more
    devices.
    
    Sponsored by:   Advanced Micro Devices (AMD)
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/dev/iommu/busdma_iommu.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c
index 7a0ca39172f3..4d295ed7c6b2 100644
--- a/sys/dev/iommu/busdma_iommu.c
+++ b/sys/dev/iommu/busdma_iommu.c
@@ -126,6 +126,12 @@ iommu_get_requester(device_t dev, uint16_t *rid)
 	pci_class = devclass_find("pci");
 	l = requester = dev;
 
+	pci = device_get_parent(dev);
+	if (pci == NULL || device_get_devclass(pci) != pci_class) {
+		*rid = 0;	/* XXXKIB: Could be ACPI HID */
+		return (requester);
+	}
+
 	*rid = pci_get_rid(dev);
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410132230.49DMUpuW040114>