diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2017-06-06 15:25:10 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-09 11:42:43 +0200 |
commit | d7f781bfdbf4eb7c5706c9974b8bf6d3c82e69c1 (patch) | |
tree | 8c54daf319dfa19c3b07e382b1d027adc6b67ee6 /drivers/thunderbolt/tb.h | |
parent | 81a54b5e1986d02da33c59133556ce9fe2032049 (diff) | |
download | linux-d7f781bfdbf4eb7c5706c9974b8bf6d3c82e69c1.tar.gz linux-d7f781bfdbf4eb7c5706c9974b8bf6d3c82e69c1.tar.bz2 linux-d7f781bfdbf4eb7c5706c9974b8bf6d3c82e69c1.zip |
thunderbolt: Rework control channel to be more reliable
If a request times out the response might arrive right after the request
is failed. This response is pushed to the kfifo and next request will
read it instead. Since it most likely will not pass our validation
checks in parse_header() the next request will fail as well, and
response to that request will be pushed to the kfifo, ad infinitum.
We end up in a situation where all requests fail and no devices can be
added anymore until the driver is unloaded and reloaded again.
To overcome this, rework the control channel so that we will have a
queue of outstanding requests. Each request will be handled in turn and
the response is validated against what is expected. Unexpected packets
(for example responses for requests that have been timed out) are
dropped. This model is copied from Greybus implementation with small
changes here and there to get it cope with Thunderbolt control packets.
In addition the configuration packets support sequence number which the
switch is supposed to copy from the request to response. We use this to
drop responses that are already timed out. Taking advantage of the
sequence number, we automatically retry configuration read/write 4 times
before giving up.
Also timeout is not a programming error so there is no need to trigger a
scary backtrace (WARN), instead we just log a warning. After all
Thunderbolt devices are hot-pluggable by definition which means user can
unplug a device any time and that is totally acceptable.
With this change there is no need to take the global domain lock when
sending configuration packets anymore. This is useful when we add
support for cross-domain (XDomain) communication later on.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
Reviewed-by: Michael Jamet <michael.jamet@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/thunderbolt/tb.h')
-rw-r--r-- | drivers/thunderbolt/tb.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 5bb9a5d60d2c..98a405384596 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -132,7 +132,7 @@ struct tb_cm_ops { /** * struct tb - main thunderbolt bus structure * @dev: Domain device - * @lock: Big lock. Must be held when accessing cfg or any struct + * @lock: Big lock. Must be held when accessing any struct * tb_switch / struct tb_port. * @nhi: Pointer to the NHI structure * @ctl: Control channel for this domain |