p8-i2c: fix wrong request status when a reset is needed

Message ID 20180606153754.17365-1-fbarrat@linux.ibm.com
State Accepted
Headers show
Series
  • p8-i2c: fix wrong request status when a reset is needed
Related show

Commit Message

Frederic Barrat June 6, 2018, 3:37 p.m.
If the bus is found in error state when starting a new request, the
engine is reset and we enter recovery. However, once complete, the
reset operation shows a status of complete in the status register. So
any badly-timed called to check_status() will think the current top
request is complete, even though it hasn't run yet.

So don't update any request status while we are in recovery, as
nothing useful for the request is supposed to happen in that state.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 hw/p8-i2c.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Stewart Smith June 19, 2018, 5:38 a.m. | #1
Frederic Barrat <fbarrat@linux.ibm.com> writes:
> If the bus is found in error state when starting a new request, the
> engine is reset and we enter recovery. However, once complete, the
> reset operation shows a status of complete in the status register. So
> any badly-timed called to check_status() will think the current top
> request is complete, even though it hasn't run yet.
>
> So don't update any request status while we are in recovery, as
> nothing useful for the request is supposed to happen in that state.
>
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>

THanks, merged to master as of c2ce576152b4d88a7f9cf2cff57e173d1b975592.

Patch

diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index 1bcd7cc8..23d54a04 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -826,10 +826,13 @@  static void p8_i2c_check_status(struct p8_i2c_master *master)
 
 	/*
 	 * When idle or waiting for the occ to release the bus there's
-	 * nothing to check. Error states are handled when starting
-	 * a new request.
+	 * nothing to check. Also ignore recovery state, as the bus
+	 * can be reset in that state, and a request can think it's
+	 * complete when it just means the reset is complete.
+	 * Error states are handled when starting a new request.
 	 */
-	if (master->state == state_idle || master->state == state_occache_dis)
+	if (master->state == state_idle || master->state == state_occache_dis ||
+		master->state == state_recovery)
 		return;
 
 	/* A non-idle master should always have a pending request */