[Pdbg] [PATCH 5/7] libpdbg: Add bmc /dev/scom* backend
Amitay Isaacs
amitay at ozlabs.org
Wed Apr 10 18:08:52 AEST 2019
From: Benjamin Herrenschmidt <benh at kernel.crashing.org>
Avoid using the CFAM in raw mode, thus avoiding racing with
other users of the CFAM PIB bridge. Also a bit faster.
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
libpdbg/kernel.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
p9-kernel.dts.m4 | 6 ++++--
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/libpdbg/kernel.c b/libpdbg/kernel.c
index 9ff0174..a759c3c 100644
--- a/libpdbg/kernel.c
+++ b/libpdbg/kernel.c
@@ -149,3 +149,59 @@ static struct fsi kernel_fsi = {
.write = kernel_fsi_putcfam,
};
DECLARE_HW_UNIT(kernel_fsi);
+
+static int kernel_pib_getscom(struct pib *pib, uint64_t addr, uint64_t *value)
+{
+ int rc;
+
+ rc = pread(pib->fd, value, 8, addr);
+ if (rc < 0) {
+ rc = errno;
+ PR_ERROR("Failed to read scom");
+ return rc;
+ }
+ return 0;
+}
+
+static int kernel_pib_putscom(struct pib *pib, uint64_t addr, uint64_t value)
+{
+ int rc;
+
+ rc = pwrite(pib->fd, &value, 8, addr);
+ if (rc < 0) {
+ rc = errno;
+ PR_ERROR("Failed to write scom");
+ return rc;
+ }
+ return 0;
+}
+
+static int kernel_pib_probe(struct pdbg_target *target)
+{
+ struct pib *pib = target_to_pib(target);
+ const char *scom_path;
+
+ scom_path = pdbg_target_property(target, "device-path", NULL);
+ assert(scom_path);
+
+ pib->fd = open(scom_path, O_RDWR | O_SYNC);
+ if (pib->fd < 0) {
+ PR_ERROR("Unable to open %s\n", scom_path);
+ return -1;
+ }
+
+ lseek(pib->fd, 0, SEEK_SET);
+ return 0;
+}
+
+struct pib kernel_pib = {
+ .target = {
+ .name = "Kernel based FSI SCOM",
+ .compatible = "ibm,kernel-pib",
+ .class = "pib",
+ .probe = kernel_pib_probe,
+ },
+ .read = kernel_pib_getscom,
+ .write = kernel_pib_putscom,
+};
+DECLARE_HW_UNIT(kernel_pib);
diff --git a/p9-kernel.dts.m4 b/p9-kernel.dts.m4
index 195be59..aec0881 100644
--- a/p9-kernel.dts.m4
+++ b/p9-kernel.dts.m4
@@ -18,7 +18,8 @@
#size-cells = <0x1>;
reg = <0x0 0x1000 0x7>;
index = <0x0>;
- compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib";
+ compatible = "ibm,kernel-pib";
+ device-path = "/dev/scom1";
include(p9-pib.dts.m4)dnl
};
@@ -35,7 +36,8 @@
#size-cells = <0x1>;
reg = <0x0 0x1000 0x7>;
index = <0x1>;
- compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib";
+ compatible = "ibm,kernel-pib";
+ device-path = "/dev/scom2";
include(p9-pib.dts.m4)dnl
};
};
--
2.20.1
More information about the Pdbg
mailing list