Commit 4b6cfb2a authored by Greg Kurz's avatar Greg Kurz Committed by Michael Ellerman

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: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarGreg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent b1fc9484
...@@ -24,6 +24,7 @@ obj-$(CONFIG_40x) += 40x_mmu.o ...@@ -24,6 +24,7 @@ obj-$(CONFIG_40x) += 40x_mmu.o
obj-$(CONFIG_44x) += 44x_mmu.o obj-$(CONFIG_44x) += 44x_mmu.o
obj-$(CONFIG_PPC_FSL_BOOK3E) += fsl_booke_mmu.o obj-$(CONFIG_PPC_FSL_BOOK3E) += fsl_booke_mmu.o
obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o
obj-$(CONFIG_PPC_SPLPAR) += vphn.o
obj-$(CONFIG_PPC_MM_SLICES) += slice.o obj-$(CONFIG_PPC_MM_SLICES) += slice.o
obj-y += hugetlbpage.o obj-y += hugetlbpage.o
ifeq ($(CONFIG_HUGETLB_PAGE),y) ifeq ($(CONFIG_HUGETLB_PAGE),y)
......
...@@ -1177,6 +1177,9 @@ u64 memory_hotplug_max(void) ...@@ -1177,6 +1177,9 @@ u64 memory_hotplug_max(void)
/* Virtual Processor Home Node (VPHN) support */ /* Virtual Processor Home Node (VPHN) support */
#ifdef CONFIG_PPC_SPLPAR #ifdef CONFIG_PPC_SPLPAR
#include "vphn.h"
struct topology_update_data { struct topology_update_data {
struct topology_update_data *next; struct topology_update_data *next;
unsigned int cpu; unsigned int cpu;
...@@ -1247,64 +1250,6 @@ static int update_cpu_associativity_changes_mask(void) ...@@ -1247,64 +1250,6 @@ static int update_cpu_associativity_changes_mask(void)
return cpumask_weight(changes); return cpumask_weight(changes);
} }
/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers.
*/
#define VPHN_REGISTER_COUNT 6
/*
* 6 64-bit registers unpacked into 12 32-bit associativity values. To form
* the complete property we have to add the length in the first cell.
*/
#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
/*
* Convert the associativity domain numbers returned from the hypervisor
* to the sequence they would appear in the ibm,associativity property.
*/
static int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
{
__be64 be_packed[VPHN_REGISTER_COUNT];
int i, nr_assoc_doms = 0;
const __be16 *field = (const __be16 *) be_packed;
#define VPHN_FIELD_UNUSED (0xffff)
#define VPHN_FIELD_MSB (0x8000)
#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
/* Let's recreate the original stream. */
for (i = 0; i < VPHN_REGISTER_COUNT; i++)
be_packed[i] = cpu_to_be64(packed[i]);
for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
/* All significant fields processed, and remaining
* fields contain the reserved value of all 1's.
* Just store them.
*/
unpacked[i] = *((__be32 *)field);
field += 2;
} else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
/* Data is in the lower 15 bits of this field */
unpacked[i] = cpu_to_be32(
be16_to_cpup(field) & VPHN_FIELD_MASK);
field++;
nr_assoc_doms++;
} else {
/* Data is in the lower 15 bits of this field
* concatenated with the next 16 bit field
*/
unpacked[i] = *((__be32 *)field);
field += 2;
nr_assoc_doms++;
}
}
/* The first cell contains the length of the property */
unpacked[0] = cpu_to_be32(nr_assoc_doms);
return nr_assoc_doms;
}
/* /*
* Retrieve the new associativity information for a virtual processor's * Retrieve the new associativity information for a virtual processor's
* home node. * home node.
......
#include <asm/byteorder.h>
#include "vphn.h"
/*
* Convert the associativity domain numbers returned from the hypervisor
* to the sequence they would appear in the ibm,associativity property.
*/
int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
{
__be64 be_packed[VPHN_REGISTER_COUNT];
int i, nr_assoc_doms = 0;
const __be16 *field = (const __be16 *) be_packed;
#define VPHN_FIELD_UNUSED (0xffff)
#define VPHN_FIELD_MSB (0x8000)
#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
/* Let's recreate the original stream. */
for (i = 0; i < VPHN_REGISTER_COUNT; i++)
be_packed[i] = cpu_to_be64(packed[i]);
for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
/* All significant fields processed, and remaining
* fields contain the reserved value of all 1's.
* Just store them.
*/
unpacked[i] = *((__be32 *)field);
field += 2;
} else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
/* Data is in the lower 15 bits of this field */
unpacked[i] = cpu_to_be32(
be16_to_cpup(field) & VPHN_FIELD_MASK);
field++;
nr_assoc_doms++;
} else {
/* Data is in the lower 15 bits of this field
* concatenated with the next 16 bit field
*/
unpacked[i] = *((__be32 *)field);
field += 2;
nr_assoc_doms++;
}
}
/* The first cell contains the length of the property */
unpacked[0] = cpu_to_be32(nr_assoc_doms);
return nr_assoc_doms;
}
#ifndef _ARCH_POWERPC_MM_VPHN_H_
#define _ARCH_POWERPC_MM_VPHN_H_
/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers.
*/
#define VPHN_REGISTER_COUNT 6
/*
* 6 64-bit registers unpacked into 12 32-bit associativity values. To form
* the complete property we have to add the length in the first cell.
*/
#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
extern int vphn_unpack_associativity(const long *packed, __be32 *unpacked);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment