The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=913d04deeddaeb3b2e4545657d688404835b2e1a

commit 913d04deeddaeb3b2e4545657d688404835b2e1a
Author:     Andrew Turner <and...@freebsd.org>
AuthorDate: 2023-04-24 11:47:38 +0000
Commit:     Andrew Turner <and...@freebsd.org>
CommitDate: 2023-04-24 11:47:38 +0000

    Add PCI_ID_OFW_IOMMU to the pci ecam ACPI driver
    
    Teach the pci host generic ACPI attachment about PCI_ID_OFW_IOMMU. This
    will be used by the arm64 smmu IOMMU driver to read the xref and ID
    this interface provides in a bus-agnostic way.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D39182
---
 sys/dev/pci/pci_host_generic_acpi.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/sys/dev/pci/pci_host_generic_acpi.c 
b/sys/dev/pci/pci_host_generic_acpi.c
index 8ef97a3ae1ae..0ac3e7d16a5d 100644
--- a/sys/dev/pci/pci_host_generic_acpi.c
+++ b/sys/dev/pci/pci_host_generic_acpi.c
@@ -412,6 +412,31 @@ generic_pcie_map_id(device_t pci, device_t child, 
uintptr_t *id)
        return (0);
 }
 
+static int
+generic_pcie_get_iommu(device_t pci, device_t child, uintptr_t *id)
+{
+       struct generic_pcie_acpi_softc *sc;
+       struct pci_id_ofw_iommu *iommu;
+       u_int iommu_sid, iommu_xref;
+       uintptr_t rid;
+       int err;
+
+       iommu = (struct pci_id_ofw_iommu *)id;
+
+       sc = device_get_softc(pci);
+       err = pcib_get_id(pci, child, PCI_ID_RID, &rid);
+       if (err != 0)
+               return (err);
+       err = acpi_iort_map_pci_smmuv3(sc->base.ecam, rid, &iommu_xref,
+           &iommu_sid);
+       if (err == 0) {
+               iommu->id = iommu_sid;
+               iommu->xref = iommu_xref;
+       }
+
+       return (err);
+}
+
 static int
 generic_pcie_acpi_alloc_msi(device_t pci, device_t child, int count,
     int maxcount, int *irqs)
@@ -479,11 +504,13 @@ static int
 generic_pcie_acpi_get_id(device_t pci, device_t child, enum pci_id_type type,
     uintptr_t *id)
 {
+       if (type == PCI_ID_OFW_IOMMU)
+               return (generic_pcie_get_iommu(pci, child, id));
 
        if (type == PCI_ID_MSI)
                return (generic_pcie_map_id(pci, child, id));
-       else
-               return (pcib_get_id(pci, child, type, id));
+
+       return (pcib_get_id(pci, child, type, id));
 }
 
 static device_method_t generic_pcie_acpi_methods[] = {

Reply via email to