From f3856e68811a32389fbb8f50d334f7409a6dd2e7 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Fri, 17 Jul 2020 14:51:51 +0000 Subject: [PATCH] Add acpi_iort_map_pci_smmuv3(). This new function allows us to find the SMMU instance assigned for a particular PCI RID. Reviewed by: andrew Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D25687 --- sys/arm64/acpica/acpi_iort.c | 21 ++++++++++++++++++++- sys/dev/acpica/acpivar.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/arm64/acpica/acpi_iort.c b/sys/arm64/acpica/acpi_iort.c index 8ed02bda0438..878441d8b3ba 100644 --- a/sys/arm64/acpica/acpi_iort.c +++ b/sys/arm64/acpica/acpi_iort.c @@ -160,7 +160,7 @@ iort_entry_lookup(struct iort_node *node, u_int id, u_int *outid) if (i == node->nentries) return (NULL); if ((entry->flags & ACPI_IORT_ID_SINGLE_MAPPING) == 0) - *outid = entry->outbase + (id - entry->base); + *outid = entry->outbase + (id - entry->base); else *outid = entry->outbase; return (entry->out_node); @@ -564,3 +564,22 @@ acpi_iort_map_pci_msi(u_int seg, u_int rid, u_int *xref, u_int *devid) *xref = node->entries.its[0].xref; return (0); } + +int +acpi_iort_map_pci_smmuv3(u_int seg, u_int rid, u_int *xref, u_int *sid) +{ + ACPI_IORT_SMMU_V3 *smmu; + struct iort_node *node; + + node = iort_pci_rc_map(seg, rid, ACPI_IORT_NODE_SMMU_V3, sid); + if (node == NULL) + return (ENOENT); + + /* This should be an SMMU node. */ + KASSERT(node->type == ACPI_IORT_NODE_SMMU_V3, ("bad node")); + + smmu = (ACPI_IORT_SMMU_V3 *)&node->data.smmu_v3; + *xref = smmu->BaseAddress; + + return (0); +} diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index f13a569de8f7..69890f153011 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -556,6 +556,7 @@ int acpi_get_domain(device_t dev, device_t child, int *domain); * ARM specific ACPI interfaces, relating to IORT table. */ int acpi_iort_map_pci_msi(u_int seg, u_int rid, u_int *xref, u_int *devid); +int acpi_iort_map_pci_smmuv3(u_int seg, u_int rid, u_int *xref, u_int *devid); int acpi_iort_its_lookup(u_int its_id, u_int *xref, int *pxm); #endif #endif /* _KERNEL */