[Skiboot] [PATCH v3 6/6] skiboot: Add chip id to HOMER reserved region

Hemant Kumar hemant at linux.vnet.ibm.com
Tue Dec 6 05:10:31 AEDT 2016


From: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>

This patch adds a "ibm,chip-id" property to HOMER reserved region. That
helps us in relating the HOMER reserved region to the chip that its
associated with.

This patch is required for nest IMC counters since, the counter values
are stored in an offset inside the HOMER region. To read those values
from the kernel for a chip, we need to associate the region to its
associated chip.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 core/init.c       |  3 +++
 hw/homer.c        | 30 ++++++++++++++++++++++++++++++
 include/skiboot.h |  1 +
 3 files changed, 34 insertions(+)

diff --git a/core/init.c b/core/init.c
index 07f4568..fc4b5f6 100644
--- a/core/init.c
+++ b/core/init.c
@@ -960,6 +960,9 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
 
 	prd_register_reserved_memory();
 
+	/* Add ibm,chip-id porperty to homer reserved region */
+	homer_fixup_dt();
+
 	load_and_boot_kernel(false);
 }
 
diff --git a/hw/homer.c b/hw/homer.c
index 84eb536..c7b17c4 100644
--- a/hw/homer.c
+++ b/hw/homer.c
@@ -116,6 +116,36 @@ static void homer_init_chip(struct proc_chip *chip)
 	}
 }
 
+void homer_fixup_dt(void)
+{
+	struct mem_region *region;
+	struct proc_chip *chip;
+
+	lock(&mem_region_lock);
+
+	for (region = mem_region_next(NULL); region;
+	     region = mem_region_next(region)) {
+		if (region->type != REGION_HW_RESERVED)
+			continue;
+
+		if (!region->node)
+			continue;
+
+		if (strncmp("ibm,homer-image",
+			    region->node->name, strlen("ibm,homer-image")))
+			continue;
+
+		for_each_chip(chip) {
+			if (region->start == chip->homer_base) {
+				dt_add_property_cells(region->node,
+						      "ibm,chip-id", chip->id);
+				break;
+			}
+		}
+	}
+	unlock(&mem_region_lock);
+}
+
 void homer_init(void)
 {
 	struct proc_chip *chip;
diff --git a/include/skiboot.h b/include/skiboot.h
index 2ef7677..7b9b39e 100644
--- a/include/skiboot.h
+++ b/include/skiboot.h
@@ -258,6 +258,7 @@ extern void prd_tmgt_interrupt(uint32_t proc);
 extern void prd_occ_reset(uint32_t proc);
 extern void prd_init(void);
 extern void prd_register_reserved_memory(void);
+extern void homer_fixup_dt(void);
 
 /* Flatten device-tree */
 extern void *create_dtb(const struct dt_node *root, bool exclusive);
-- 
2.7.4



More information about the Skiboot mailing list