xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: vijay.kilari@gmail.com
To: julien.grall@arm.com, sstabellini@kernel.org,
	andre.przywara@arm.com, dario.faggioli@citrix.com
Cc: xen-devel@lists.xenproject.org, Vijaya Kumar K <Vijaya.Kumar@cavium.com>
Subject: [RFC PATCH v1 15/21] ARM: NUMA: Extract MPIDR from MADT table
Date: Thu,  9 Feb 2017 21:27:07 +0530	[thread overview]
Message-ID: <1486655834-9708-16-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1486655834-9708-1-git-send-email-vijay.kilari@gmail.com>

From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>

Parse MADT table and extract MPIDR for all
CPU IDs in MADT ACPI_MADT_TYPE_GENERIC_INTERRUPT entries
and store in cpu_uid_to_hwid[].

This mapping is used by SRAT table parsing to
extract MPIDR of the CPU ID.

Signed-off-by: Vijaya Kumar <Vijaya.Kumar@cavium.com>
---
 xen/arch/arm/Makefile      |   1 +
 xen/arch/arm/acpi_numa.c   | 122 +++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/numa.c        |   1 +
 xen/include/asm-arm/acpi.h |   2 +
 4 files changed, 126 insertions(+)

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 7694485..8c5e67b 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -51,6 +51,7 @@ obj-y += vpsci.o
 obj-y += vuart.o
 obj-$(CONFIG_NUMA) += numa.o
 obj-$(CONFIG_NUMA) += dt_numa.o
+obj-$(CONFIG_ACPI_NUMA) += acpi_numa.o
 
 #obj-bin-y += ....o
 
diff --git a/xen/arch/arm/acpi_numa.c b/xen/arch/arm/acpi_numa.c
new file mode 100644
index 0000000..3ee87f2
--- /dev/null
+++ b/xen/arch/arm/acpi_numa.c
@@ -0,0 +1,122 @@
+/*
+ * ACPI based NUMA setup
+ *
+ * Copyright (C) 2016 - Cavium Inc.
+ * Vijaya Kumar K <Vijaya.Kumar@cavium.com>
+ *
+ * Reads the ACPI MADT and SRAT table to setup NUMA information.
+ *
+ * Contains Excerpts from x86 implementation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <xen/init.h>
+#include <xen/mm.h>
+#include <xen/inttypes.h>
+#include <xen/nodemask.h>
+#include <xen/acpi.h>
+#include <xen/numa.h>
+#include <xen/pfn.h>
+#include <xen/srat.h>
+#include <asm/page.h>
+#include <asm/acpi.h>
+
+extern nodemask_t numa_nodes_parsed;
+struct uid_to_mpidr {
+    u32 uid;
+    u64 mpidr;
+};
+
+/* Holds mapping of CPU id to MPIDR read from MADT */
+static struct uid_to_mpidr cpu_uid_to_hwid[NR_CPUS] __read_mostly;
+
+static __init void bad_srat(void)
+{
+    int i;
+
+    printk(KERN_ERR "SRAT: SRAT not used.\n");
+    acpi_numa = -1;
+    for (i = 0; i < ARRAY_SIZE(pxm2node); i++)
+        pxm2node[i].node = NUMA_NO_NODE;
+}
+
+static u64 acpi_get_cpu_mpidr(int uid)
+{
+    int i;
+
+    if ( uid < ARRAY_SIZE(cpu_uid_to_hwid) && cpu_uid_to_hwid[uid].uid == uid &&
+         cpu_uid_to_hwid[uid].mpidr != MPIDR_INVALID )
+        return cpu_uid_to_hwid[uid].mpidr;
+
+    for ( i = 0; i < NR_CPUS; i++ )
+    {
+        if ( cpu_uid_to_hwid[i].uid == uid )
+            return cpu_uid_to_hwid[i].mpidr;
+    }
+
+    return MPIDR_INVALID;
+}
+
+static void __init
+acpi_map_cpu_to_mpidr(struct acpi_madt_generic_interrupt *processor)
+{
+    static int cpus = 0;
+
+    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
+
+    if ( mpidr == MPIDR_INVALID )
+    {
+        printk("Skip MADT cpu entry with invalid MPIDR\n");
+        bad_srat();
+        return;
+    }
+
+    cpu_uid_to_hwid[cpus].mpidr = mpidr;
+    cpu_uid_to_hwid[cpus].uid = processor->uid;
+
+    cpus++;
+}
+
+static int __init acpi_parse_madt_handler(struct acpi_subtable_header *header,
+                                          const unsigned long end)
+{
+    struct acpi_madt_generic_interrupt *p =
+               container_of(header, struct acpi_madt_generic_interrupt, header);
+
+    if ( BAD_MADT_ENTRY(p, end) )
+    {
+        /* Though MADT is invalid, we disable NUMA by calling bad_srat() */
+        bad_srat();
+        return -EINVAL;
+    }
+
+    acpi_table_print_madt_entry(header);
+    acpi_map_cpu_to_mpidr(p);
+
+    return 0;
+}
+
+void __init acpi_map_uid_to_mpidr(void)
+{
+    int i;
+
+    for ( i  = 0; i < NR_CPUS; i++ )
+    {
+        cpu_uid_to_hwid[i].mpidr = MPIDR_INVALID;
+        cpu_uid_to_hwid[i].uid = -1;
+    }
+
+    acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
+                    acpi_parse_madt_handler, 0);
+}
+
+void __init acpi_numa_arch_fixup(void) {}
diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
index 31dc552..5c49347 100644
--- a/xen/arch/arm/numa.c
+++ b/xen/arch/arm/numa.c
@@ -20,6 +20,7 @@
 #include <xen/mm.h>
 #include <xen/nodemask.h>
 #include <xen/pfn.h>
+#include <xen/acpi.h>
 #include <asm/mm.h>
 #include <xen/numa.h>
 #include <asm/acpi.h>
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 9f954d3..b1f36f4 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -68,6 +68,8 @@ static inline void enable_acpi(void)
 {
     acpi_disabled = 0;
 }
+
+void acpi_map_uid_to_mpidr(void);
 #else
 #define acpi_disabled (1)
 #define disable_acpi()
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-02-09 15:59 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-09 15:56 [RFC PATCH v1 00/21] ARM: Add Xen NUMA support vijay.kilari
2017-02-09 15:56 ` [RFC PATCH v1 01/21] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA vijay.kilari
2017-02-20 11:39   ` Julien Grall
2017-02-22  9:18     ` Vijay Kilari
2017-02-22 10:49       ` Julien Grall
2017-02-09 15:56 ` [RFC PATCH v1 02/21] x86: NUMA: Refactor NUMA code vijay.kilari
2017-02-09 16:11   ` Jan Beulich
2017-02-20 11:41     ` Julien Grall
2017-02-27 11:43     ` Vijay Kilari
2017-02-27 14:58       ` Jan Beulich
2017-02-20 12:37   ` Julien Grall
2017-02-22 10:04     ` Vijay Kilari
2017-02-22 10:55       ` Julien Grall
2017-02-09 15:56 ` [RFC PATCH v1 03/21] NUMA: Move arch specific NUMA code as common vijay.kilari
2017-02-09 16:15   ` Jan Beulich
2017-02-20 12:47   ` Julien Grall
2017-02-22 10:08     ` Vijay Kilari
2017-02-22 11:07       ` Julien Grall
2017-02-09 15:56 ` [RFC PATCH v1 04/21] NUMA: Refactor generic and arch specific code of numa_setup vijay.kilari
2017-02-20 13:39   ` Julien Grall
2017-02-22 10:27     ` Vijay Kilari
2017-02-22 11:09       ` Julien Grall
2017-02-09 15:56 ` [RFC PATCH v1 05/21] ARM: efi: Do not delete memory node from fdt vijay.kilari
2017-02-20 13:42   ` Julien Grall
2017-02-09 15:56 ` [RFC PATCH v1 06/21] ARM: NUMA: Parse CPU NUMA information vijay.kilari
2017-02-20 17:32   ` Julien Grall
2017-02-22 10:46     ` Vijay Kilari
2017-02-22 11:10       ` Julien Grall
2017-02-20 17:36   ` Julien Grall
2017-02-09 15:56 ` [RFC PATCH v1 07/21] ARM: NUMA: Parse memory " vijay.kilari
2017-02-20 18:05   ` Julien Grall
2017-03-02 12:25     ` Vijay Kilari
2017-03-02 14:48       ` Julien Grall
2017-03-02 15:08         ` Vijay Kilari
2017-03-02 15:19           ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 08/21] ARM: NUMA: Parse NUMA distance information vijay.kilari
2017-02-20 18:28   ` Julien Grall
2017-02-22 11:38     ` Vijay Kilari
2017-02-22 11:44       ` Julien Grall
2017-03-02 12:10         ` Vijay Kilari
2017-03-02 12:17           ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 09/21] ARM: NUMA: Add CPU NUMA support vijay.kilari
2017-02-20 18:32   ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 10/21] ARM: NUMA: Add memory " vijay.kilari
2017-03-02 16:05   ` Julien Grall
2017-03-02 16:23     ` Vijay Kilari
2017-02-09 15:57 ` [RFC PATCH v1 11/21] ARM: NUMA: Add fallback on NUMA failure vijay.kilari
2017-03-02 16:09   ` Julien Grall
2017-03-02 16:25     ` Vijay Kilari
2017-02-09 15:57 ` [RFC PATCH v1 12/21] ARM: NUMA: Do not expose numa info to DOM0 vijay.kilari
2017-02-20 18:36   ` Julien Grall
2017-03-02 12:30     ` Vijay Kilari
2017-02-09 15:57 ` [RFC PATCH v1 13/21] ACPI: Refactor acpi SRAT and SLIT table handling code vijay.kilari
2017-03-02 15:30   ` Julien Grall
2017-03-02 16:31     ` Vijay Kilari
2017-03-02 16:32       ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 14/21] ACPI: Move srat_disabled to common code vijay.kilari
2017-02-09 15:57 ` vijay.kilari [this message]
2017-03-02 16:28   ` [RFC PATCH v1 15/21] ARM: NUMA: Extract MPIDR from MADT table Julien Grall
2017-03-02 16:41     ` Vijay Kilari
2017-03-02 16:49       ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 16/21] ARM: NUMA: Extract proximity from SRAT table vijay.kilari
2017-03-02 17:21   ` Julien Grall
2017-03-03 12:39     ` Vijay Kilari
2017-03-03 13:44       ` Julien Grall
2017-03-03 13:50         ` Vijay Kilari
2017-03-03 13:52           ` Julien Grall
2017-03-03 14:45             ` Vijay Kilari
2017-03-03 14:52               ` Julien Grall
2017-03-03 15:16                 ` Vijay Kilari
2017-03-03 15:22                   ` Jan Beulich
2017-03-10 10:53                     ` Vijay Kilari
2017-02-09 15:57 ` [RFC PATCH v1 17/21] ARM: NUMA: Extract memory " vijay.kilari
2017-02-10 17:33   ` Konrad Rzeszutek Wilk
2017-02-10 17:35     ` Konrad Rzeszutek Wilk
2017-03-02 14:41       ` Vijay Kilari
2017-02-09 15:57 ` [RFC PATCH v1 18/21] ARM: NUMA: update node_distance with ACPI support vijay.kilari
2017-03-02 17:24   ` Julien Grall
2017-03-03 12:43     ` Vijay Kilari
2017-03-03 13:46       ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 19/21] ARM: NUMA: Initialize ACPI NUMA vijay.kilari
2017-03-02 17:25   ` Julien Grall
2017-03-03 12:44     ` Vijay Kilari
2017-02-09 15:57 ` [RFC PATCH v1 20/21] ARM: NUMA: Enable CONFIG_NUMA config vijay.kilari
2017-03-02 17:27   ` Julien Grall
2017-02-09 15:57 ` [RFC PATCH v1 21/21] ARM: NUMA: Enable CONFIG_ACPI_NUMA config vijay.kilari
2017-03-02 17:31   ` Julien Grall
2017-02-09 16:31 ` [RFC PATCH v1 00/21] ARM: Add Xen NUMA support Julien Grall
2017-02-09 16:59   ` Vijay Kilari
2017-02-10 17:30 ` Konrad Rzeszutek Wilk
2017-03-02 14:49   ` Vijay Kilari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486655834-9708-16-git-send-email-vijay.kilari@gmail.com \
    --to=vijay.kilari@gmail.com \
    --cc=Vijaya.Kumar@cavium.com \
    --cc=andre.przywara@arm.com \
    --cc=dario.faggioli@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).