<div dir="ltr">I've applied locally and it looks like this reduces the number of i2c conflicts we have with the occ but it's not perfect and we fail to read some of the dimm spds.<div><br></div><div>I've noticed lots of these type messages, which appear to mostly be useful for information but shouldn't be at error or warning level:</div><div><div><div>[ 1742.429554610,3] I2C: c0e3: Master in use by OCC</div><div>[ 1742.446787039,3] I2C: c0e3: Master in use by OCC</div><div>[ 1742.446849435,3] I2C: c0e3: Master in use by OCC</div><div>[ 1742.459099356,3] I2C: c0e3: Master in use by OCC</div><div>[ 1742.459146931,3] I2C: c0e3: Master in use by OCC</div><div>[ 1742.490614096,3] I2C: c0e3: Master in use by OCC</div><div>[ 1742.490682664,3] I2C: c0e3: Master in use by OCC</div></div><div><br></div><div>I noticed that in the cases where we have broken spd data the skiboot message buffer contains the following interlaced with the above messages:</div></div><div>[ 1743.471148533,3] I2C: Request complete with residual data req=1 done=2<br></div><div><br></div><div>It appears that we get 2 of those extra data messages when we get bad SPD data on the userspace side.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 23, 2017 at 7:11 AM Oliver O'Halloran <<a href="mailto:oohall@gmail.com" target="_blank">oohall@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's a few issues with the Host<->OCC I2C bus handshaking. First up,<br>
skiboot is currently examining the wrong bit when checking if the OCC<br>
is currently using the bus. Secondly, when we need to wait for the OCC<br>
to release the bus we are scheduling a recovery timer to run zero<br>
timebase ticks after the current moment so the next poller run will<br>
always time out the current request. The is also an issue with the<br>
order of operations in the recovery timeout handler which can cause<br>
an assertion failure when the cause of the recovery is a timeout<br>
waiting for the OCC.<br>
<br>
This patch addresses all these issues and sets the recovery timeout to<br>
10ms.<br>
<br>
Signed-off-by: Oliver O'Halloran <<a href="mailto:oohall@gmail.com" target="_blank">oohall@gmail.com</a>><br>
---<br>
 hw/p8-i2c.c | 22 +++++++++++++++-------<br>
 1 file changed, 15 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c<br>
index f4666e24953e..69d0984e65cb 100644<br>
--- a/hw/p8-i2c.c<br>
+++ b/hw/p8-i2c.c<br>
@@ -1063,8 +1063,11 @@ static int occ_i2c_lock(struct p8_i2c_master *master)<br>
<br>
        busflag = PPC_BIT(16 + (master->engine_id - 1) * 2);<br>
<br>
-       DBG("occflags = %llx (locks = %.6llx)\n", (u64)occflags,<br>
-           GETFIELD(PPC_BITMASK(16, 22), occflags));<br>
+       DBG("I2C: c%de%d: occflags = %llx (locks = %x:%x:%x)\n",<br>
+               master->chip_id, master->engine_id, (u64) occflags,<br>
+               (u32) GETFIELD(PPC_BITMASK(16, 17), occflags),<br>
+               (u32) GETFIELD(PPC_BITMASK(18, 19), occflags),<br>
+               (u32) GETFIELD(PPC_BITMASK(20, 21), occflags));<br>
<br>
        rc = xscom_write(master->chip_id, OCCFLG_SET, busflag);<br>
        if (rc) {<br>
@@ -1073,8 +1076,11 @@ static int occ_i2c_lock(struct p8_i2c_master *master)<br>
        }<br>
<br>
        /* If the OCC also has this bus locked then wait for IRQ */<br>
-       if (occflags & (busflag << 1))<br>
+       if (occflags & (busflag >> 1)) {<br>
+               prerror("I2C: c%de%d: Master in use by OCC\n",<br>
+                       master->chip_id, master->engine_id);<br>
                return 1;<br>
+       }<br>
<br>
        master->occ_lock_acquired = true;<br>
<br>
@@ -1161,7 +1167,7 @@ static int p8_i2c_start_request(struct p8_i2c_master *master,<br>
        if (rc > 0) {<br>
                /* Wait for OCC IRQ */<br>
                master->state = state_occache_dis;<br>
-               schedule_timer(&master->recovery, rc);<br>
+               schedule_timer(&master->recovery, msecs_to_tb(10));<br>
                return 0;<br>
        }<br>
<br>
@@ -1298,11 +1304,13 @@ void p9_i2c_bus_owner_change(u32 chip_id)<br>
                        continue;<br>
                }<br>
<br>
-               /* Run the state machine */<br>
-               p8_i2c_check_status(master);<br>
+               /* clear the existing wait timer */<br>
+               cancel_timer(&master->recovery);<br>
<br>
-               /* Check for new work */<br>
+               /* start the request now that we own the master */<br>
+               master->state = state_idle;<br>
                p8_i2c_check_work(master);<br>
+               p8_i2c_check_status(master);<br>
<br>
                unlock(&master->lock);<br>
        }<br>
--<br>
2.9.5<br>
<br>
_______________________________________________<br>
Skiboot mailing list<br>
<a href="mailto:Skiboot@lists.ozlabs.org" target="_blank">Skiboot@lists.ozlabs.org</a><br>
<a href="https://lists.ozlabs.org/listinfo/skiboot" rel="noreferrer" target="_blank">https://lists.ozlabs.org/listinfo/skiboot</a><br>
</blockquote></div></div>