diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-11-23 16:45:59 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-11-24 16:47:16 +1100 |
commit | 441ddb9b4719a092bbbf81fcf775632f282a3fca (patch) | |
tree | 437302f687eb23d881e59013e62464956533b622 /hw/p8-i2c.c | |
parent | 2981a7bfc9dc3b1b642a868b09a75d011c49063a (diff) | |
download | skiboot-441ddb9b4719a092bbbf81fcf775632f282a3fca.zip skiboot-441ddb9b4719a092bbbf81fcf775632f282a3fca.tar.gz skiboot-441ddb9b4719a092bbbf81fcf775632f282a3fca.tar.bz2 |
i2c: Add i2c_run_req() to crank the state machine for a request
Doing everything asynchronously is brilliant, it's exactly what we
want to do.
Except... the tpm driver wants to do things synchronously, which isn't
so cool.
For reasons that are not yet completely known, we spend an awful lot of
time in the main thread *not* running pollers (potentially seconds), which
doesn't bode well for I2C timeouts.
Since the TPM measure is done in a secondary thread, we do *not* run pollers
there either (as of 323c8aeb54bd4e0b9004091fcbb4a9daeda2f576 - which is
roughly as of skiboot 2.1.1).
But we still need to crank the i2c state machine, so we introduce a call
to do just that. It will return how long the poll interval should be, so
that we can time_wait() for a more appropriate time for whatever i2c
implementation is sitting behind things.
Without this, it was "easy" to get to a situation where the i2c state machine
wasn't cranked at all, and you'd hit the i2c timeout (for the issued operation)
before the poller to crank i2c was ever called.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Tested-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/p8-i2c.c')
-rw-r--r-- | hw/p8-i2c.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 4e29432..12a4d1a 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -1064,6 +1064,23 @@ static void p8_i2c_set_request_timeout(struct i2c_request *req, request->timeout = msecs_to_tb(duration); } +static uint64_t p8_i2c_run_request(struct i2c_request *req) +{ + struct i2c_bus *bus = req->bus; + struct p8_i2c_master_port *port = + container_of(bus, struct p8_i2c_master_port, bus); + struct p8_i2c_master *master = port->master; + uint64_t poll_interval = 0; + + lock(&master->lock); + p8_i2c_check_status(master); + p8_i2c_check_work(master); + poll_interval = master->poll_interval; + unlock(&master->lock); + + return poll_interval; +} + static inline uint32_t p8_i2c_get_bit_rate_divisor(uint32_t lb_freq, uint32_t bus_speed) { @@ -1399,6 +1416,7 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) port->bus.alloc_req = p8_i2c_alloc_request; port->bus.free_req = p8_i2c_free_request; port->bus.set_req_timeout = p8_i2c_set_request_timeout; + port->bus.run_req = p8_i2c_run_request; i2c_add_bus(&port->bus); /* Add OPAL properties to the bus node */ |