git: 7896b03fff4d - main - iommu_get_requester(): do not panic if asked about non-pci device

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 13 Oct 2024 22:30:51 UTC
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);
 
 	/*