aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorGreg Kurz <gkurz@linux.vnet.ibm.com>2015-02-23 10:14:31 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2015-03-17 19:48:59 -0400
commit4b6cfb2a8cd7520e8a747718e5c1da047697ca31 (patch)
tree4c11bb5e691f12eec899ae7350a743920541e96b /arch
parentb1fc9484aa339c19bd57702dc88fb046702b6092 (diff)
powerpc/vphn: move VPHN parsing logic to a separate file
The goal behind this patch is to be able to write userland tests for the VPHN parsing code. Suggested-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/mm/Makefile1
-rw-r--r--arch/powerpc/mm/numa.c61
-rw-r--r--arch/powerpc/mm/vphn.c50
-rw-r--r--arch/powerpc/mm/vphn.h16
4 files changed, 70 insertions, 58 deletions
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 438dcd3fd0d1..9c8770b5f96f 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_40x) += 40x_mmu.o
24obj-$(CONFIG_44x) += 44x_mmu.o 24obj-$(CONFIG_44x) += 44x_mmu.o
25obj-$(CONFIG_PPC_FSL_BOOK3E) += fsl_booke_mmu.o 25obj-$(CONFIG_PPC_FSL_BOOK3E) += fsl_booke_mmu.o
26obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o 26obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o
27obj-$(CONFIG_PPC_SPLPAR) += vphn.o
27obj-$(CONFIG_PPC_MM_SLICES) += slice.o 28obj-$(CONFIG_PPC_MM_SLICES) += slice.o
28obj-y += hugetlbpage.o 29obj-y += hugetlbpage.o
29ifeq ($(CONFIG_HUGETLB_PAGE),y) 30ifeq ($(CONFIG_HUGETLB_PAGE),y)
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 59196c5a0984..c68471c33731 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1177,6 +1177,9 @@ u64 memory_hotplug_max(void)
1177 1177
1178/* Virtual Processor Home Node (VPHN) support */ 1178/* Virtual Processor Home Node (VPHN) support */
1179#ifdef CONFIG_PPC_SPLPAR 1179#ifdef CONFIG_PPC_SPLPAR
1180
1181#include "vphn.h"
1182
1180struct topology_update_data { 1183struct topology_update_data {
1181 struct topology_update_data *next; 1184 struct topology_update_data *next;
1182 unsigned int cpu; 1185 unsigned int cpu;
@@ -1247,64 +1250,6 @@ static int update_cpu_associativity_changes_mask(void)
1247 return cpumask_weight(changes); 1250 return cpumask_weight(changes);
1248} 1251}
1249 1252
1250/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers.
1251 */
1252#define VPHN_REGISTER_COUNT 6
1253
1254/*
1255 * 6 64-bit registers unpacked into 12 32-bit associativity values. To form
1256 * the complete property we have to add the length in the first cell.
1257 */
1258#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
1259
1260/*
1261 * Convert the associativity domain numbers returned from the hypervisor
1262 * to the sequence they would appear in the ibm,associativity property.
1263 */
1264static int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
1265{
1266 __be64 be_packed[VPHN_REGISTER_COUNT];
1267 int i, nr_assoc_doms = 0;
1268 const __be16 *field = (const __be16 *) be_packed;
1269
1270#define VPHN_FIELD_UNUSED (0xffff)
1271#define VPHN_FIELD_MSB (0x8000)
1272#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
1273
1274 /* Let's recreate the original stream. */
1275 for (i = 0; i < VPHN_REGISTER_COUNT; i++)
1276 be_packed[i] = cpu_to_be64(packed[i]);
1277
1278 for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
1279 if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
1280 /* All significant fields processed, and remaining
1281 * fields contain the reserved value of all 1's.
1282 * Just store them.
1283 */
1284 unpacked[i] = *((__be32 *)field);
1285 field += 2;
1286 } else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
1287 /* Data is in the lower 15 bits of this field */
1288 unpacked[i] = cpu_to_be32(
1289 be16_to_cpup(field) & VPHN_FIELD_MASK);
1290 field++;
1291 nr_assoc_doms++;
1292 } else {
1293 /* Data is in the lower 15 bits of this field
1294 * concatenated with the next 16 bit field
1295 */
1296 unpacked[i] = *((__be32 *)field);
1297 field += 2;
1298 nr_assoc_doms++;
1299 }
1300 }
1301
1302 /* The first cell contains the length of the property */
1303 unpacked[0] = cpu_to_be32(nr_assoc_doms);
1304
1305 return nr_assoc_doms;
1306}
1307
1308/* 1253/*
1309 * Retrieve the new associativity information for a virtual processor's 1254 * Retrieve the new associativity information for a virtual processor's
1310 * home node. 1255 * home node.
diff --git a/arch/powerpc/mm/vphn.c b/arch/powerpc/mm/vphn.c
new file mode 100644
index 000000000000..c49ed519c381
--- /dev/null
+++ b/arch/powerpc/mm/vphn.c
@@ -0,0 +1,50 @@
1#include <asm/byteorder.h>
2#include "vphn.h"
3
4/*
5 * Convert the associativity domain numbers returned from the hypervisor
6 * to the sequence they would appear in the ibm,associativity property.
7 */
8int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
9{
10 __be64 be_packed[VPHN_REGISTER_COUNT];
11 int i, nr_assoc_doms = 0;
12 const __be16 *field = (const __be16 *) be_packed;
13
14#define VPHN_FIELD_UNUSED (0xffff)
15#define VPHN_FIELD_MSB (0x8000)
16#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
17
18 /* Let's recreate the original stream. */
19 for (i = 0; i < VPHN_REGISTER_COUNT; i++)
20 be_packed[i] = cpu_to_be64(packed[i]);
21
22 for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
23 if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
24 /* All significant fields processed, and remaining
25 * fields contain the reserved value of all 1's.
26 * Just store them.
27 */
28 unpacked[i] = *((__be32 *)field);
29 field += 2;
30 } else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
31 /* Data is in the lower 15 bits of this field */
32 unpacked[i] = cpu_to_be32(
33 be16_to_cpup(field) & VPHN_FIELD_MASK);
34 field++;
35 nr_assoc_doms++;
36 } else {
37 /* Data is in the lower 15 bits of this field
38 * concatenated with the next 16 bit field
39 */
40 unpacked[i] = *((__be32 *)field);
41 field += 2;
42 nr_assoc_doms++;
43 }
44 }
45
46 /* The first cell contains the length of the property */
47 unpacked[0] = cpu_to_be32(nr_assoc_doms);
48
49 return nr_assoc_doms;
50}
diff --git a/arch/powerpc/mm/vphn.h b/arch/powerpc/mm/vphn.h
new file mode 100644
index 000000000000..96af9a474693
--- /dev/null
+++ b/arch/powerpc/mm/vphn.h
@@ -0,0 +1,16 @@
1#ifndef _ARCH_POWERPC_MM_VPHN_H_
2#define _ARCH_POWERPC_MM_VPHN_H_
3
4/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers.
5 */
6#define VPHN_REGISTER_COUNT 6
7
8/*
9 * 6 64-bit registers unpacked into 12 32-bit associativity values. To form
10 * the complete property we have to add the length in the first cell.
11 */
12#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
13
14extern int vphn_unpack_associativity(const long *packed, __be32 *unpacked);
15
16#endif