Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm Add support for multiple GICv3 ITS domains.



details:   https://anonhg.NetBSD.org/src/rev/119b9eb8b03b
branches:  trunk
changeset: 744801:119b9eb8b03b
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Feb 13 00:02:21 2020 +0000

description:
Add support for multiple GICv3 ITS domains.

diffstat:

 sys/arch/arm/acpi/acpi_iort.c        |  47 +++++++++++++++++++++++++++++++++--
 sys/arch/arm/acpi/acpi_iort.h        |   3 +-
 sys/arch/arm/acpi/acpi_pci_machdep.c |  14 +++++++++-
 sys/arch/arm/acpi/gicv3_acpi.c       |  14 +++------
 sys/arch/arm/include/pci_machdep.h   |   5 +++-
 sys/arch/arm/pci/pci_msi_machdep.c   |  28 ++++++++++++++++++---
 6 files changed, 91 insertions(+), 20 deletions(-)

diffs (269 lines):

diff -r a31ca26bde33 -r 119b9eb8b03b sys/arch/arm/acpi/acpi_iort.c
--- a/sys/arch/arm/acpi/acpi_iort.c     Wed Feb 12 22:34:51 2020 +0000
+++ b/sys/arch/arm/acpi/acpi_iort.c     Thu Feb 13 00:02:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_iort.c,v 1.2 2020/02/07 00:35:00 jmcneill Exp $ */
+/* $NetBSD: acpi_iort.c,v 1.3 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.2 2020/02/07 00:35:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.3 2020/02/13 00:02:21 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -99,7 +99,7 @@
                                do {
                                        node = acpi_iort_find_ref(iort, node, &devid);
                                } while (node != NULL);
-                               aprint_debug("ACPI: IORT remapped devid %#x -> %#x\n", odevid, devid);
+                               aprint_debug("ACPI: IORT mapped devid %#x -> devid %#x\n", odevid, devid);
                                return devid;
                        }
                }
@@ -108,3 +108,44 @@
 
        return devid;
 }
+
+uint32_t
+acpi_iort_its_id_map(u_int seg, uint32_t devid)
+{
+       ACPI_TABLE_IORT *iort;
+       ACPI_IORT_NODE *node;
+       ACPI_IORT_ROOT_COMPLEX *root;
+       ACPI_IORT_ITS_GROUP *its_group;
+       uint32_t offset, n;
+       ACPI_STATUS rv;
+
+       rv = AcpiGetTable(ACPI_SIG_IORT, 0, (ACPI_TABLE_HEADER **)&iort);
+       if (ACPI_FAILURE(rv))
+               return 0;
+
+       offset = iort->NodeOffset;
+       for (n = 0; n < iort->NodeCount; n++) {
+               node = ACPI_ADD_PTR(ACPI_IORT_NODE, iort, offset);
+               if (node->Type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
+                       root = (ACPI_IORT_ROOT_COMPLEX *)node->NodeData;
+                       if (root->PciSegmentNumber == seg) {
+                               const uint32_t odevid = devid;
+                               do {
+                                       node = acpi_iort_find_ref(iort, node, &devid);
+                                       if (node != NULL && node->Type == ACPI_IORT_NODE_ITS_GROUP) {
+                                               its_group = (ACPI_IORT_ITS_GROUP *)node->NodeData;
+                                               if (its_group->ItsCount == 0)
+                                                       return 0;
+                                               aprint_debug("ACPI: IORT mapped devid %#x -> ITS %#x\n",
+                                                   odevid, its_group->Identifiers[0]);
+                                               return its_group->Identifiers[0];
+                                       }
+                               } while (node != NULL);
+                               return 0;
+                       }
+               }
+               offset += node->Length;
+       }
+
+       return 0;
+}
diff -r a31ca26bde33 -r 119b9eb8b03b sys/arch/arm/acpi/acpi_iort.h
--- a/sys/arch/arm/acpi/acpi_iort.h     Wed Feb 12 22:34:51 2020 +0000
+++ b/sys/arch/arm/acpi/acpi_iort.h     Thu Feb 13 00:02:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_iort.h,v 1.1 2018/12/08 15:04:40 jmcneill Exp $ */
+/* $NetBSD: acpi_iort.h,v 1.2 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,5 +33,6 @@
 #define _ARM_ACPI_ACPI_IORT_H
 
 uint32_t       acpi_iort_pci_root_map(u_int, uint32_t);
+uint32_t       acpi_iort_its_id_map(u_int, uint32_t);
 
 #endif /* !_ARM_ACPI_ACPI_IORT_H */
diff -r a31ca26bde33 -r 119b9eb8b03b sys/arch/arm/acpi/acpi_pci_machdep.c
--- a/sys/arch/arm/acpi/acpi_pci_machdep.c      Wed Feb 12 22:34:51 2020 +0000
+++ b/sys/arch/arm/acpi/acpi_pci_machdep.c      Thu Feb 13 00:02:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.15 2020/02/01 13:26:43 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.16 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.15 2020/02/01 13:26:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.16 2020/02/13 00:02:21 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -113,6 +113,7 @@
 static void    acpi_pci_md_decompose_tag(void *, pcitag_t, int *, int *, int *);
 static u_int   acpi_pci_md_get_segment(void *);
 static uint32_t        acpi_pci_md_get_devid(void *, uint32_t);
+static uint32_t        acpi_pci_md_get_frameid(void *, uint32_t);
 static pcireg_t        acpi_pci_md_conf_read(void *, pcitag_t, int);
 static void    acpi_pci_md_conf_write(void *, pcitag_t, int, pcireg_t);
 static int     acpi_pci_md_conf_hook(void *, int, int, int, pcireg_t);
@@ -137,6 +138,7 @@
        .pc_decompose_tag = acpi_pci_md_decompose_tag,
        .pc_get_segment = acpi_pci_md_get_segment,
        .pc_get_devid = acpi_pci_md_get_devid,
+       .pc_get_frameid = acpi_pci_md_get_frameid,
        .pc_conf_read = acpi_pci_md_conf_read,
        .pc_conf_write = acpi_pci_md_conf_write,
        .pc_conf_hook = acpi_pci_md_conf_hook,
@@ -287,6 +289,14 @@
        return acpi_iort_pci_root_map(ap->ap_seg, devid);
 }
 
+static uint32_t
+acpi_pci_md_get_frameid(void *v, uint32_t devid)
+{
+       struct acpi_pci_context * const ap = v;
+
+       return acpi_iort_its_id_map(ap->ap_seg, devid);
+}
+
 static pcireg_t
 acpi_pci_md_conf_read(void *v, pcitag_t tag, int offset)
 {
diff -r a31ca26bde33 -r 119b9eb8b03b sys/arch/arm/acpi/gicv3_acpi.c
--- a/sys/arch/arm/acpi/gicv3_acpi.c    Wed Feb 12 22:34:51 2020 +0000
+++ b/sys/arch/arm/acpi/gicv3_acpi.c    Thu Feb 13 00:02:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_acpi.c,v 1.6 2020/01/17 16:58:57 jmcneill Exp $ */
+/* $NetBSD: gicv3_acpi.c,v 1.7 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_acpi.c,v 1.6 2020/01/17 16:58:57 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_acpi.c,v 1.7 2020/02/13 00:02:21 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -288,7 +288,6 @@
 static ACPI_STATUS
 gicv3_acpi_map_gits(ACPI_SUBTABLE_HEADER *hdrp, void *aux)
 {
-       static bool its_attached;
        struct gicv3_acpi_softc * const sc = aux;
        ACPI_MADT_GENERIC_TRANSLATOR *gits;
        bus_space_handle_t bsh;
@@ -304,13 +303,10 @@
                return AE_OK;
        }
 
-       aprint_normal_dev(sc->sc_gic.sc_dev, "ITS #%d at 0x%" PRIx64 "%s\n",
-           gits->TranslationId, gits->BaseAddress, its_attached ? " (disabled)" : "");
+       aprint_normal_dev(sc->sc_gic.sc_dev, "ITS #%d at 0x%" PRIx64 "\n",
+           gits->TranslationId, gits->BaseAddress);
 
-       if (its_attached == false) {
-               gicv3_its_init(&sc->sc_gic, bsh, gits->BaseAddress, gits->TranslationId);
-               its_attached = true;
-       }
+       gicv3_its_init(&sc->sc_gic, bsh, gits->BaseAddress, gits->TranslationId);
 
        return AE_OK;
 }
diff -r a31ca26bde33 -r 119b9eb8b03b sys/arch/arm/include/pci_machdep.h
--- a/sys/arch/arm/include/pci_machdep.h        Wed Feb 12 22:34:51 2020 +0000
+++ b/sys/arch/arm/include/pci_machdep.h        Thu Feb 13 00:02:21 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.h,v 1.17 2018/12/08 15:04:40 jmcneill Exp $        */
+/*     $NetBSD: pci_machdep.h,v 1.18 2020/02/13 00:02:21 jmcneill Exp $        */
 
 /*
  * Modified for arm32 by Mark Brinicombe
@@ -93,6 +93,7 @@
                            int *, int *);
        u_int           (*pc_get_segment)(void *);
        uint32_t        (*pc_get_devid)(void *, uint32_t);
+       uint32_t        (*pc_get_frameid)(void *, uint32_t);
        pcireg_t        (*pc_conf_read)(void *, pcitag_t, int);
        void            (*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
 
@@ -151,6 +152,8 @@
     ((c)->pc_get_segment ? (*(c)->pc_get_segment)((c)->pc_conf_v) : 0)
 #define pci_get_devid(c, d)                                            \
     ((c)->pc_get_devid ? (*(c)->pc_get_devid)((c)->pc_conf_v, (d)) : (d))
+#define pci_get_frameid(c, d)                                          \
+    ((c)->pc_get_frameid ? (*(c)->pc_get_frameid)((c)->pc_conf_v, (d)) : 0)
 #define        pci_conf_read(c, t, r)                                          \
     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
 #define        pci_conf_write(c, t, r, v)                                      \
diff -r a31ca26bde33 -r 119b9eb8b03b sys/arch/arm/pci/pci_msi_machdep.c
--- a/sys/arch/arm/pci/pci_msi_machdep.c        Wed Feb 12 22:34:51 2020 +0000
+++ b/sys/arch/arm/pci/pci_msi_machdep.c        Thu Feb 13 00:02:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_msi_machdep.c,v 1.7 2019/08/03 12:55:46 jmcneill Exp $ */
+/* $NetBSD: pci_msi_machdep.c,v 1.8 2020/02/13 00:02:21 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.7 2019/08/03 12:55:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.8 2020/02/13 00:02:21 jmcneill Exp $");
 
 #include <sys/kernel.h>
 #include <sys/kmem.h>
@@ -59,6 +59,26 @@
        return NULL;
 }
 
+static struct arm_pci_msi *
+arm_pci_msi_lookup(const struct pci_attach_args *pa)
+{
+       struct arm_pci_msi *msip;
+       uint32_t devid, frameid;
+       int b, d, f;
+
+       pci_decompose_tag(pa->pa_pc, pa->pa_tag, &b, &d, &f);
+
+       devid = (b << 8) | (d << 3) | f;
+        devid = pci_get_devid(pa->pa_pc, devid);
+       frameid = pci_get_frameid(pa->pa_pc, devid);
+
+       SIMPLEQ_FOREACH(msip, &arm_pci_msi_list, msi_link)
+               if (frameid == msip->msi_id)
+                       return msip;
+
+       return NULL;
+}
+
 static int
 arm_pci_msi_alloc_common(pci_intr_handle_t **ihps, int *count, const struct pci_attach_args *pa, bool exact)
 {
@@ -68,7 +88,7 @@
        if ((pa->pa_flags & PCI_FLAGS_MSI_OKAY) == 0)
                return ENODEV;
 
-       msi = SIMPLEQ_FIRST(&arm_pci_msi_list);         /* XXX multiple frame support */
+       msi = arm_pci_msi_lookup(pa);
        if (msi == NULL || msi->msi_alloc == NULL)
                return EINVAL;
 
@@ -90,7 +110,7 @@
        if ((pa->pa_flags & PCI_FLAGS_MSIX_OKAY) == 0)
                return ENODEV;
 
-       msi = SIMPLEQ_FIRST(&arm_pci_msi_list);         /* XXX multiple frame support */
+       msi = arm_pci_msi_lookup(pa);
        if (msi == NULL || msi->msix_alloc == NULL)
                return EINVAL;
 



Home | Main Index | Thread Index | Old Index