diff mbox series

[v2] skiboot/hw/imc: Add nest_memory region to "exports" node

Message ID 1505216759-15076-1-git-send-email-maddy@linux.vnet.ibm.com
State Accepted
Headers show
Series [v2] skiboot/hw/imc: Add nest_memory region to "exports" node | expand

Commit Message

maddy Sept. 12, 2017, 11:45 a.m. UTC
Exports the In-Memory Collection counter nest memory to
the OS. This allows the OS to view the nest counter
region directly. This helps in nest microcode debug
and to check counter raw value.

Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
Changelog v1:
- Fixed the chip index in file name
- Moved from dt_root to opal_node when searching for "exports"
- Moved the logic to imc_dt_update_nest_node()

 hw/imc.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Stewart Smith Sept. 13, 2017, 7:01 a.m. UTC | #1
Madhavan Srinivasan <maddy@linux.vnet.ibm.com> writes:
> Exports the In-Memory Collection counter nest memory to
> the OS. This allows the OS to view the nest counter
> region directly. This helps in nest microcode debug
> and to check counter raw value.

Good for debug. Thanks. Merged to master as of
167e65d570a7c0361c359ba082e044813e9d2fca.
diff mbox series

Patch

diff --git a/hw/imc.c b/hw/imc.c
index 60fc39d6b761..99293ee36f9e 100644
--- a/hw/imc.c
+++ b/hw/imc.c
@@ -402,6 +402,9 @@  static void imc_dt_update_nest_node(struct dt_node *dev)
 	int i=0, nr_chip = nr_chips();
 	struct dt_node *node;
 	const struct dt_property *type;
+	uint32_t offset = 0, size = 0;
+	uint64_t baddr;
+	char namebuf[32];
 
 	/* Add the base_addr and chip-id properties for the nest node */
 	base_addr = malloc(sizeof(uint64_t) * nr_chip);
@@ -417,8 +420,27 @@  static void imc_dt_update_nest_node(struct dt_node *dev)
 		if (type && is_nest_node(node)) {
 			dt_add_property(node, "base-addr", base_addr, (i * sizeof(u64)));
 			dt_add_property(node, "chip-id", chipids, (i * sizeof(u32)));
+			offset = dt_prop_get_u32(node, "offset");
+			size = dt_prop_get_u32(node, "size");
 		}
 	}
+
+	/*
+	 * Enable only if we have active nest pmus.
+	 */
+	if (!size)
+		return;
+
+	node = dt_find_by_name(opal_node, "exports");
+	if (!node)
+		return;
+
+	for_each_chip(chip) {
+		snprintf(namebuf, sizeof(namebuf), "imc_nest_chip_%x", chip->id);
+		baddr = chip->homer_base;
+		baddr += offset;
+		dt_add_property_u64s(node, namebuf, baddr, size);
+	}
 }
 
 /*