[PORT FROM R2] hsi_ffl_tty.c: streamlining the TX timeout and stop TX timer management
authorOlivier Stoltz Douchet <olivierx.stoltz-douchet@intel.com>
Wed, 7 Dec 2011 17:05:39 +0000 (18:05 +0100)
committerbuildbot <buildbot@intel.com>
Mon, 23 Jan 2012 13:16:36 +0000 (05:16 -0800)
commit68c4c2d9db30fea39ab29ba29f22eab3fbcd47af
tree7b31d707ed4040db41565e837a5589584bae90fe
parent5ba2c6b6a24d99dd0c2cef5160b3dd95aa580c15
[PORT FROM R2] hsi_ffl_tty.c: streamlining the TX timeout and stop TX timer management

BZ: 15222

This patch is cleaning and factorising the TX timeout and stop TX timer
management to limit the number of code sections where those timers are updated
In more details, this patch is:
 - also directly killing the stop TX timer in the _ffl_from_wait_to_ctrl()
   function upon successful insertion of HSI message in the controller at the
   very same location where the TX timeout timer is updated;
 - adding a _ffl_update_state_tx() function aimed at factorising those timers
   management, mainly killing the hangup timer when there is no left HSI
   message in the controller and starting the stop TX timer when the full write
   pipeline is empty. This helper function is the sibling of the
   _ffl_update_state_rx() function;
 - this _ffl_update_state_tx() is now called wherever the wait FIFO and the
   controller FIFO are updated: in the _ffl_pop_wait_push_ctrl() function,
   which is transferring as much TX messages as possible from the wait FIFO and
   the controller as well as in the ffl_destruct_frame() callback;
 - the _ffl_tx_ctx_is_empty() helper function has been removed as it was only
   used once in this new code version, and its internal code has been directly
   carbon copied in the ffl_tx_full_pipe_is_clean() function;
 - the TX timeout and stop TX timer management has been removed from the
   ffl_complete_tx() function for it is now included in the
   _ffl_pop_wait_push_ctrl() call;
 - the ffl_throw_tty_hangup() function has been dropped as it was mistakenly
   used with a spinlock_irq_save in the ISR (which is bad) and was only used
   once elsewhere. The content of this initial function has been copied to the
   ISR without the _irqsave modifier, and was updated in the
   ffl_tty_tx_timeout() timer handler callback to only throw a TTY hangup if
   the HSI controller FIFO is not empty - which is safer than the current
   implementation.

This latter modification is further ensuring that no unexpected TX timeout
hangup can happen when the HSI controller FIFO is empty - maybe due to a race
condition between the del_timer() and mod_timer() functions.

This new hangup management is simpler than the previous one as it does not
update the TX timeout timer upon reception on a frame, but only when adding a
new frame in the controller.

Finally, this new version is also adding better traces for RESET_OUT and
CORE_DUMP, adding the cause information.

In a nutshell, the purpose of this patch is to bind the TX timeout and stop TX
timer management to ensure a full coherency in this respect, to simplify the
TX timeout management and to filter out potential spurious TX timeout hangups.

Change-Id: I0cc4e5ca720a1fee4060681780c59aeada476193
Orig-change-Id: Id53abc766cd9687321f3f21195fe7f898e24948f
Orig-Change-Id: I6e1ce86acbde63f96b744d972a31fcb53afb1205
Signed-off-by: Olivier Stoltz Douchet <olivierx.stoltz-douchet@intel.com>
Reviewed-on: http://android.intel.com:8080/31445
Reviewed-by: Predon, Frederic <frederic.predon@intel.com>
Reviewed-by: Lebsir, SamiX <samix.lebsir@intel.com>
Tested-by: Lebsir, SamiX <samix.lebsir@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/hsi/clients/hsi_ffl_tty.c