From: Greg Kurz <gkurz@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v2 0/4] VPHN parsing fixes
Date: Wed, 17 Dec 2014 10:40:46 +0100 [thread overview]
Message-ID: <20141217094007.16957.70423.stgit@bahia.local> (raw)
Hi,
This series addresses remarks from Ben and Michael (see individual patches).
The most notable changes are:
- the parsing code being pull out into a separate file in patch 3/4. This
allows to write userland tests like the one below.
- a full rewrite of the parsing logic in patch 4/4
--
#include <stdio.h>
#include <byteswap.h>
typedef unsigned long u64;
typedef unsigned int u32;
typedef unsigned short u16;
typedef enum { false = 0, true } bool;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define cpu_to_be32(x) bswap_32(x)
#define be32_to_cpu(x) bswap_32(x)
#define be16_to_cpup(x) bswap_16(*x)
#define cpu_to_be64(x) bswap_64(x)
#else
#define cpu_to_be32(x) (x)
#define be32_to_cpu(x) (x)
#define be16_to_cpup(x) (*x)
#define cpu_to_be64(x) (x)
#endif
#define pr_debug(...) printf(__VA_ARGS__)
#include "vphn.c"
void print_packed(const long *packed)
{
char *p = (char*) packed;
int i;
printf("\nRegisters:\n");
for (i = 0; i < VPHN_REGISTER_COUNT; i++)
printf("0x%016lx\n", packed[i]);
printf("\nMemory layout:\n");
for (i = 0; i < 6; i++) {
printf("0x %02hhx %02hhx %02hhx %02hhx"
" %02hhx %02hhx %02hhx %02hhx\n",
*(p + 0), *(p + 1), *(p + 2), *(p + 3),
*(p + 4), *(p + 5), *(p + 6), *(p + 7));
p += 8;
}
putchar('\n');
}
void print_unpacked(const __be32 *unpacked)
{
int i;
printf("\nVPHN associativity:\n");
for (i = 0; i <= be32_to_cpu(unpacked[0]); i++)
printf("0x%08x\n", be32_to_cpu(unpacked[i]));
putchar('\n');
}
int main(int argc, char **argv)
{
int i;
struct {
const char *descr;
long packed[VPHN_REGISTER_COUNT];
} data[] = {
{
"16-bit and 32-bit",
0x8001800280038004,
0x8005800680078008,
0x000000090000000a,
0x0000000b0000000c,
0xffffffffffffffff,
0xffffffffffffffff
},
{
"filled with 16-bit",
0x8001800280038004,
0x8005800680078008,
0x8009800a800b800c,
0x800d800e800f8010,
0x8011801280138014,
0x8015801680178018,
},
{
"filled with 32-bit",
0x0000000100000002,
0x0000000300000004,
0x0000000500000006,
0x0000000700000008,
0x000000090000000a,
0x0000000b0000000c,
},
{
"32-bit has all ones in 16 lower bits",
0x0001ffff80028003,
0xffffffffffffffff,
0xffffffffffffffff,
0xffffffffffffffff,
0xffffffffffffffff,
0xffffffffffffffff,
},
{
"32-bit accross two 64-bit registers",
0x8001000000020000,
0x0003000000048005,
0xffffffffffffffff,
0xffffffffffffffff,
0xffffffffffffffff,
0xffffffffffffffff,
},
{
"Truncated last 32-bit",
0x0000000100000002,
0x0000000300000004,
0x0000000500000006,
0x0000000700000008,
0x000000090000000a,
0x0000000b800c0bad,
},
};
for (i = 0; i < sizeof(data) / sizeof(data[0]); i++) {
__be32 unpacked[VPHN_ASSOC_BUFSIZE] = { 0 };
printf("\n==================================================\n");
printf("\nSet #%d: %s\n", i, data[i].descr);
printf("\n==================================================\n");
print_packed(data[i].packed);
vphn_unpack_associativity(data[i].packed, unpacked);
print_unpacked(unpacked);
}
return 0;
}
---
Greg Kurz (4):
powerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API
powerpc/vphn: move endianness fixing to vphn_unpack_associativity()
powerpc/vphn: move VPHN parsing logic to a separate file
powerpc/vphn: parsing code rewrite
arch/powerpc/mm/Makefile | 1 +
arch/powerpc/mm/numa.c | 55 ++----------------------------------
arch/powerpc/mm/vphn.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++
arch/powerpc/mm/vphn.h | 16 +++++++++++
4 files changed, 90 insertions(+), 52 deletions(-)
create mode 100644 arch/powerpc/mm/vphn.c
create mode 100644 arch/powerpc/mm/vphn.h
--
Greg
next reply other threads:[~2014-12-17 16:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-17 9:40 Greg Kurz [this message]
2014-12-17 9:41 ` [PATCH v2 1/4] powerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API Greg Kurz
2014-12-17 9:42 ` [PATCH v2 2/4] powerpc/vphn: move endianness fixing to vphn_unpack_associativity() Greg Kurz
2014-12-17 9:42 ` [PATCH v2 3/4] powerpc/vphn: move VPHN parsing logic to a separate file Greg Kurz
2014-12-17 9:43 ` [PATCH v2 4/4] powerpc/vphn: parsing code rewrite Greg Kurz
2015-01-29 18:03 ` [PATCH v2 0/4] VPHN parsing fixes Greg Kurz
2015-02-03 2:47 ` Michael Ellerman
2015-02-03 7:46 ` Greg Kurz
2015-02-04 0:42 ` Michael Ellerman
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=20141217094007.16957.70423.stgit@bahia.local \
--to=gkurz@linux.vnet.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.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).