Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for powerpc and POWER9 indirect type 1 scom accesses #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.o
iotools
2 changes: 2 additions & 0 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ runon(int argc, const char *argv[], const struct cmd_info *info)
return -1;
}

#ifdef ARCH_X86
MAKE_PREREQ_PARAMS_VAR_ARGS(cpuid_params, 3, 4, "<cpu> <function> [index]", 0);
#endif /* #ifdef ARCH_X86 */
MAKE_PREREQ_PARAMS_VAR_ARGS(runon_params, 3, INT_MAX, "<cpu> <cmd> [args]", 0);

static const struct cmd_info misc_cmds[] = {
Expand Down
29 changes: 17 additions & 12 deletions scom.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,27 @@
#include "commands.h"
#include "platform.h"

static off64_t xscom_mangle_addr(off64_t addr)
{
off64_t tmp;

/*
* Shift the top 4 bits (indirect mode) down by 4 bits so we
* don't lose going through the debugfs interfaces.
*/
tmp = (addr & 0xf000000000000000) >> 4;
addr &= 0x00ffffffffffffff;
addr |= tmp;

/* Shift up by 3 for debugfs */
return addr << 3;
}

static int
open_and_seek(int chip, uint64_t scom, int mode, int *fd)
{
char dev[512];
/* Shift scom address to align to 8 byte boundary, mask high bit */
off64_t offset = (scom & ((1ULL << 63) - 1)) << 3;
/* Handle high bit (indirect SCOM) by shifting the bit right one bit.
File offsets are signed, and this is how the kernel expects us to
mangle it.
Note we set bit 62 instead of bit 59 because of a bug in the kernel
scom.c that shifts the whole value right 3 before looking for
bit 59 set.
*/
if (scom & (1ULL << 63)) {
offset |= 1ULL << 62;
}
off64_t offset = xscom_mangle_addr(scom);

snprintf(dev, sizeof(dev), "/sys/kernel/debug/powerpc/scom/%08x/access",
chip);
Expand Down