Skip to content

Commit c2e404a

Browse files
oohalstewartsmith
authored andcommitted
p8-i2c: Limit number of retry attempts
Current we will attempt to start an I2C transaction until it succeeds. In the event that the OCC does not release the lock on an I2C bus this results in an async token being held forever and the kernel thread that started the transaction will block forever while waiting for an async completion message. Fix this by limiting the number of attempts to start the transaction. Signed-off-by: Oliver O'Halloran <[email protected]> Signed-off-by: Stewart Smith <[email protected]>
1 parent e947593 commit c2e404a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

hw/p8-i2c.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1303,8 +1303,16 @@ static void p8_i2c_check_work(struct p8_i2c_master *master)
13031303
while (master->state == state_idle && !list_empty(&master->req_list)) {
13041304
req = list_top(&master->req_list, struct i2c_request, link);
13051305
rc = p8_i2c_start_request(master, req);
1306-
if (rc && rc != OPAL_BUSY)
1307-
p8_i2c_complete_request(master, req, rc);
1306+
if (rc) {
1307+
/*
1308+
* If it didn't work the first three times then
1309+
* odds are it's not going to work on the 4th.
1310+
*/
1311+
if (rc && req->retries > 3)
1312+
p8_i2c_complete_request(master, req, rc);
1313+
else
1314+
req->retries++;
1315+
}
13081316
}
13091317
}
13101318

include/i2c.h

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct i2c_request {
6464
void (*completion)( /* Completion callback */
6565
int rc, struct i2c_request *req);
6666
void *user_data; /* Client data */
67+
int retries;
6768
};
6869

6970
/* Generic i2c */

0 commit comments

Comments
 (0)