summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorgkoehler <gkoehler@cvs.openbsd.org>2020-12-30 06:06:32 +0000
committergkoehler <gkoehler@cvs.openbsd.org>2020-12-30 06:06:32 +0000
commit39f39fdbfb82696a9b8a04f41c139f91c64b1b50 (patch)
tree4e7523d1b680cadb3d64a16be369d0e41ec957bd /sys/dev
parenta640deed8a9d460a51db6c891d3c4f153fc30ea9 (diff)
Enter power-saving mode on POWER9 (ISA v3)
When opal(4) attaches, look in the device tree for a psscr value. In cpu_idle_cycle(), use this psscr value and the stop instruction to wait for the next interrupt. In mp kernels, cpu_unidle() now sends an interrupt. In "sysctl hw.sensors", the power and temperature sensors from opalsens(4) may show lower values. The cpu may exit stop at the system reset vector after losing user registers. If so, restore some registers. For now, ignore deeper stop states that would lose hypervisor registers. Our mp kernel uses only the first hardware thread of each core. Take the extra threads from the firmware and stop them forever; this may switch the core from SMT4 to single-thread mode and increase performance. partly by kettenis@, ok kettenis@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ofw/fdt.c18
-rw-r--r--sys/dev/ofw/openfirm.h3
2 files changed, 19 insertions, 2 deletions
diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c
index 9646d74eeb8..62ca7392c45 100644
--- a/sys/dev/ofw/fdt.c
+++ b/sys/dev/ofw/fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdt.c,v 1.25 2020/07/18 09:44:59 kettenis Exp $ */
+/* $OpenBSD: fdt.c,v 1.26 2020/12/30 06:06:31 gkoehler Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
@@ -1005,6 +1005,22 @@ OF_getpropint64(int handle, char *prop, uint64_t defval)
}
int
+OF_getpropint64array(int handle, char *prop, uint64_t *buf, int buflen)
+{
+ int len;
+ int i;
+
+ len = OF_getprop(handle, prop, buf, buflen);
+ if (len < 0 || (len % sizeof(uint64_t)))
+ return -1;
+
+ for (i = 0; i < len / sizeof(uint64_t); i++)
+ buf[i] = betoh64(buf[i]);
+
+ return len;
+}
+
+int
OF_nextprop(int handle, char *prop, void *nextprop)
{
void *node = (char *)tree.header + handle;
diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h
index 57022b05c85..ea631c2f0e4 100644
--- a/sys/dev/ofw/openfirm.h
+++ b/sys/dev/ofw/openfirm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: openfirm.h,v 1.16 2020/07/06 15:18:03 kettenis Exp $ */
+/* $OpenBSD: openfirm.h,v 1.17 2020/12/30 06:06:31 gkoehler Exp $ */
/* $NetBSD: openfirm.h,v 1.1 1996/09/30 16:35:10 ws Exp $ */
/*
@@ -53,6 +53,7 @@ int OF_getprop(int handle, char *prop, void *buf, int buflen);
uint32_t OF_getpropint(int handle, char *, uint32_t);
int OF_getpropintarray(int, char *, uint32_t *, int);
uint64_t OF_getpropint64(int handle, char *, uint64_t);
+int OF_getpropint64array(int, char *, uint64_t *, int);
int OF_setprop(int, char *, const void *, int);
int OF_nextprop(int, char *, void *);
int OF_finddevice(char *name);