[DEBUG 05/10] powerpc/mm: Identify isolation seeking coherent memory nodes during boot

From: Anshuman Khandual
Date: Mon Oct 24 2016 - 00:43:53 EST


Isolation seeking coherent memory nodes which wish to be MNODE_ISOLATION
in core VM will have "ibm,hotplug-aperture" as one of the compatible
properties in their respective device nodes in device tree. Detect them
during platform NUMA initialization and mark their respective coherent
mask in pglist_data structure as MNODE_ISOLATION.

Signed-off-by: Anshuman Khandual <khandual@xxxxxxxxxxxxxxxxxx>
---
arch/powerpc/mm/numa.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 5010181..89ae64c 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -64,6 +64,7 @@ static int form1_affinity;
static int distance_ref_points_depth;
static const __be32 *distance_ref_points;
static int distance_lookup_table[MAX_NUMNODES][MAX_DISTANCE_REF_POINTS];
+static int node_to_phys_device_map[MAX_NUMNODES];

/*
* Allocate node_to_cpumask_map based on number of available nodes
@@ -714,6 +715,17 @@ static const struct of_device_id memory_match[] = {
{ /* sentinel */ }
};

+int arch_get_memory_phys_device(unsigned long start_pfn)
+{
+ return node_to_phys_device_map[pfn_to_nid(start_pfn)];
+}
+
+int special_mem_node(int nid)
+{
+ return node_to_phys_device_map[nid];
+}
+EXPORT_SYMBOL(special_mem_node);
+
static int __init parse_numa_properties(void)
{
struct device_node *memory;
@@ -789,6 +801,9 @@ static int __init parse_numa_properties(void)
if (nid < 0)
nid = default_nid;

+ if (of_device_is_compatible(memory, "ibm,hotplug-aperture"))
+ node_to_phys_device_map[nid] = 1;
+
fake_numa_create_new_node(((start + size) >> PAGE_SHIFT), &nid);
node_set_online(nid);

@@ -908,6 +923,11 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn)
NODE_DATA(nid)->node_id = nid;
NODE_DATA(nid)->node_start_pfn = start_pfn;
NODE_DATA(nid)->node_spanned_pages = spanned_pages;
+
+#ifdef CONFIG_COHERENT_DEVICE
+ if (special_mem_node(nid))
+ set_cdm_isolation(nid);
+#endif
}

void __init initmem_init(void)
--
2.1.0