[Skiboot] [PATCH] p8-i2c: Don't write the watermark register at init

Oliver O'Halloran oohall at gmail.com
Fri Nov 10 13:50:36 AEDT 2017


On P9 the I2C master is shared with the OCC. Currently the watermark
values are set once at init time which is bad for two reasons:

a) We don't take the OCC master lock before setting it. Which
   may cause issues if the OCC is currently using the master.
b) The OCC might change the watermark levels and we need to reset
   them.

Change this so that we set the watermark value when a new transaction
is started rather than at init time.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 hw/p8-i2c.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index ce56b268154a..ec2f7fc0b47c 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -1223,6 +1223,14 @@ static int p8_i2c_start_request(struct p8_i2c_master *master,
 	if (rc)
 		return rc;
 
+	/* program the watermark register */
+	rc = p8_i2c_prog_watermark(master);
+	if (rc) {
+		log_simple_error(&e_info(OPAL_RC_I2C_INIT),
+			 "I2C: Failed to program the WATERMARK_REG\n");
+		return rc;
+	}
+
 	/* Initialize bytes_sent */
 	master->bytes_sent = 0;
 
@@ -1680,22 +1688,10 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type)
 		      master->irq_ok ? "" : "non-");
 	}
 
-	/* Program the watermark register */
-	rc = p8_i2c_prog_watermark(master);
-
 	/* Re-enable the sensor cache, we aren't touching HW anymore */
 	if (master->type == I2C_CENTAUR)
 		centaur_enable_sensor_cache(master->chip_id);
 
-	/* Handle errors from p8_i2c_prog_watermark */
-	if (rc) {
-		log_simple_error(&e_info(OPAL_RC_I2C_INIT),
-				 "I2C: Failed to program the "
-				 "WATERMARK_REG\n");
-		free(master);
-		return;
-	}
-
 	/* Allocate ports driven by this master */
 	count = 0;
 	dt_for_each_child(i2cm, i2cm_port)
-- 
2.9.5



More information about the Skiboot mailing list