[Skiboot] [PATCH] pci: Describe PHB diag data size in device tree

Russell Currey ruscur at russell.cc
Thu Apr 20 16:46:41 AEST 2017


Linux hardcodes the PHB diag data buffer at (as of this commit) 8192 bytes.
This has been enough for P7IOC and PHB3, but the 512 PEs of PHB4 pushes
the diag data blob over this size.  Rather than just increasing the
hardcoded size in Linux, provide the size of the diag data blob in the
device tree so that the OS can dynamically allocate as much as it needs.
This both enables more space for PHB4 and less wasted memory for P7IOC
and PHB3.

P7IOC communicates both hub and PHB data using this buffer, so when
setting the size, use whichever struct is largest.

Signed-off-by: Russell Currey <ruscur at russell.cc>
---
 hw/p7ioc-phb.c | 9 +++++++++
 hw/phb3.c      | 3 +++
 hw/phb4.c      | 3 +++
 3 files changed, 15 insertions(+)

diff --git a/hw/p7ioc-phb.c b/hw/p7ioc-phb.c
index 21f6c3e1..6c074518 100644
--- a/hw/p7ioc-phb.c
+++ b/hw/p7ioc-phb.c
@@ -2597,6 +2597,15 @@ static void p7ioc_pcie_add_node(struct p7ioc_phb *p)
 	dt_add_property_cells(np, "ibm,opal-tce-kill",
 			      hi32(tkill), lo32(tkill));
 
+	/*
+	 * Linux may use this property to allocate the diag data buffer, which
+	 * can be used for either of these structs.  Pass the largest to ensure
+	 * they can both fit in this buffer.
+	 */
+	dt_add_property_cells(np, "ibm,phb-diag-data-size",
+			      MAX(sizeof(struct OpalIoP7IOCPhbErrorData),
+				  sizeof(struct OpalIoP7IOCErrorData)));
+
 	/* Add associativity properties */
 	add_chip_dev_associativity(np);
 
diff --git a/hw/phb3.c b/hw/phb3.c
index 9bc9d78b..deb0d38a 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -4598,6 +4598,9 @@ static void phb3_add_properties(struct phb3 *p)
 		IVT_TABLE_STRIDE);
 	dt_add_property_cells(np, "ibm,opal-rba-table",
 		hi32(p->tbl_rba), lo32(p->tbl_rba), RBA_TABLE_SIZE);
+
+	dt_add_property_cells(np, "ibm,phb-diag-data-size",
+			      sizeof(struct OpalIoPhb3ErrorData));
 }
 
 static bool phb3_calculate_windows(struct phb3 *p)
diff --git a/hw/phb4.c b/hw/phb4.c
index 59fd6407..f7128d12 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -3091,6 +3091,9 @@ static void phb4_add_properties(struct phb4 *p)
 		hi32(p->tbl_peltv), lo32(p->tbl_peltv), p->tbl_peltv_size);
 	dt_add_property_cells(np, "ibm,opal-pest-table",
 		hi32(p->tbl_pest), lo32(p->tbl_pest), p->tbl_pest_size);
+
+	dt_add_property_cells(np, "ibm,phb-diag-data-size",
+			      sizeof(struct OpalIoPhb4ErrorData));
 }
 
 static bool phb4_calculate_windows(struct phb4 *p)
-- 
2.12.2



More information about the Skiboot mailing list