pci: Describe PHB diag data size in device tree

Submitted by Russell Currey on April 20, 2017, 6:46 a.m.

Details

Message ID 20170420064641.4982-1-ruscur@russell.cc
State Accepted
Headers show

Commit Message

Russell Currey April 20, 2017, 6:46 a.m.
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@russell.cc>
---
 hw/p7ioc-phb.c | 9 +++++++++
 hw/phb3.c      | 3 +++
 hw/phb4.c      | 3 +++
 3 files changed, 15 insertions(+)

Comments

Gavin Shan April 20, 2017, 11:46 p.m.
On Thu, Apr 20, 2017 at 04:46:41PM +1000, Russell Currey wrote:
>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@russell.cc>

Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>

"pci" in the subject means you're changing the code in core/pci*.c,
but I usually use "core/pci" for this case. For this particular one,
it would be: hw/phb: xxxxxxxxxxxxxxxxxxxx. Don't have to change this
time as it's just nit-picky comments.

Cheers,
Gavin
Stewart Smith May 1, 2017, 4:02 a.m.
Russell Currey <ruscur@russell.cc> writes:
> 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@russell.cc>

Thanks, merged to master as of c205afe6143c017cf88f60d5f5ea038fa928ff01

Patch hide | download patch | download mbox

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)